rule "Toggle L01"
when
BP01.state changed
then
if (BP01.state == ON)
{
if (L01.state == ON)
{
L01.sendCommand(OFF)
}
if (BP01.state == OFF)
{
L01.sendCommand(ON)
}
}
end
This is basic but it works, my lamp turn on and off.
What I want :
A switch (SW01) on a sitemap to turn ON and OFF my lamp (L01) too
SW01 should reflect L01 status
If I toggle L01 with BP01, SW01 is updated
I tried to read topics discussing about “PROXY”, but I have difficulties to adapt this to my need :
If yes: you can setup a SW01 that publishes the command to the proper topic and also subscribes to the status topic.
In this way, it doesn’t matter which action (BP01 or SW01 or another) switched the L01 ON or OFF, since L01 will report its current state and SW01 will be updated accordingly.
…if no: you can still do the same with SW01, but you won’t have a way to synchronize/update the SW01 state with the real state of L01
For troubleshooting purposes, I wouldn’t use the MQTT-Event Bus integration but rather focused MQTT item configs.
Due to “event-bus”, my MQTT topics look like something like that :
Try_04/input/${item}/state
Try_04/input/${item}/command
Try_04/output/${item}/state
Try_04/output/${item}/command
I understand that your proposal is based on “MQTT item configs” not on Event-bus.
Reagarding my need, which kind of problem could I have ?
You won’t have any problem using the MQTT-Event Bus integration method. It will work just fine.
I just mentioned that to be able to check easier the situation, I would switch to an item based config first and then you can switch back to the Bus method.
In this example:
L01 should publish its state on topic: Try_04/input/L01/state
L01 should subscribe for commands on topic: Try_04/output/L01/command
When you flick the SW01 switch to ON (or OFF), it will publish the payload ON (or OFF) to the command topic.
SW01 item will also subscribe to status updates on the state topic
Ps: You can name your OH2 switch item “L01” if you want.
Keep in mind that the MQTT Event Bus method will publish and subscribe based on the $item name (so if you use SW01, it will publish on Try_04/output/SW01/command and sub to Try_04/input/SW01/state