but it does not work as expected: after sending ON, the device switch first to ON and then to OFF.
It looks like it receives both commands while it should not.
Any help appreciated.
First of all, I’m not sure how anything is working at all because in your first example you have three Items with the same name and in the second you have two Items with the same name.
Items must have a unique name.
If you want multiple bindings for the same binding you can list them all between the curly brackets, spearated by commas.
So, assuming I’m wrong and this is a new feature of OH 2 (I assume you are using OH 2 as you refer to “channels” even though in none of the cases above are you using Channels) …
Both of the MQTT Items are bound to incoming messages, not outgoing messages. So how are you publishing ON?
It could be that you may want to use “state” rather than “command” in the binding config for MQTT. This will cause the incoming message to only set the state of the Item internal to openHAB and not forward the command to the bindings and causing the light to toggle.
It really isn’t clear exactly what you are after here so I’m mainly just guessing.
Thank you Koshak.
I send ON command from the web, by publishing a message to the items’channel (octopus:hgm_andrea/items/switch).
But, I will try your suggestions and let you know.
G