[SOLVED] Switch item with 3 triggers

Hello everybody!

I’m new to openHAB and currently trying to learn it with some ‘simple’ automations. At least so I thought. :wink:

I’m trying to power on/off my tv from the basicui page.

To power on the TV i run a script with the exec binding to perform wake on lan. To shutdown it down I use a different script, also using exec. To see if the TV is on I use the network binding. I’d like to have all this functionality combined in a single switch that updates when the TV is shutdown through an external event e.g. someone uses the standard remote, and is also able to trigger the turn on/off event itself when pressed.

I currently have two switches, one displaying the on/off state and one to manually turn it on/off.

Is there an easy way to combine the two or is this not possible at all, using different bindings/triggers on the same item.

Thanks in advance!

You can use a proxy or dummy item.

Create a dummy switch.
Map your on / off thinking to that.
Create a rule which fires when the switch changed.
Now, in your rule, if dummy switched got switched on and the network binding says TV is off, run script to turn TV on.
Else, if dummy switch off and network binding says TV is on, run shutdown script.
Else, return.

That’s the basic logic and why rules become very powerful.

Thank you, this approach worked! I created three rules, one for the on/off switch through openHAB and two rules for the manual on/off detection.