Set item based on Power and IR command

I’m trying to make a dumb TV smart. And have the following configuration:
1 Dumb TV
1 Shelly Plug, where the power cord of my tv plugs in and measures the power usage of the tv
1 Sonoff with IR led on it.

I want to have an item(Switch) to turn the tv on and off. When pressing this item the IR Led must send a on/off command to the tv.
Based on the power consumption of the tv, I want to set the state of the switch, if power usage is higher than x, then set state of item to ON, else set state to OFF.

I’ve tried to create a rule for this, but the problem I have here is that when I set the state of the item (when the power changes over the treashold, this triggers the other rule that the state of the item has changed will send an IR command turning the tv off again.

I only want to sent the command when i manually press the item, and not when I set it from the power changed rule. Does anyone know how I should change my rule(s) to fix this:

//Set item state based on power usage
rule "Tv State changed by power"
when
        Item ShellyWoonkamerTvPower changed
then
        val currentPowerConsumption = ShellyWoonkamerTvPower.state as Number
        val previousPowerConsumption = ShellyWoonkamerTvPower.previousState().state as Number
        if(currentPowerConsumption >= 50 && previousPowerConsumption < 50) {    //Tv just turned on
                postUpdate(WoonkamerTvSwitch, ON)
        }
        else if(currentPowerConsumption < 50 && previousPowerConsumption > 50){    //Tv just turned off
                postUpdate(WoonkamerTvSwitch, OFF)
        }
end

//Send IR command when item is pressed
rule "Tv State changed item"
when
        Item WoonkamerTvSwitch changed
then
        SonoffWoonkamerTvIRIRCode.sendCommand("{\"Protocol\":\"SONY\",\"Bits\":12,\"Data\":0xA90}")
end
Item WoonkamerTvSwitch received command ON

I knew it had to be something simple, thanks this solved my problem :slight_smile: