MQTT + ZWAVE BINDING + InBound

I have these bindings for my ZWAVE Switch:

Switch  Aeon    "Switch"        <switch>  {zwave="4:command=switch_binary"}
Switch  Aeon    "Switch[%s]" <switch>     {mqtt="<[octopus:hgm_andrea/items/switch/on:command:ON]"}
Switch  Aeon    "Switch[%s]" <switch>     {mqtt="<[octopus:hgm_andrea/items/switch/off:command:OFF]"}

works well. But I would like to use one channel only to send commands from the mqtt broker.
I tried this but not work:

    Switch  Aeon    "Switch[%s]" <switch>     {mqtt="<[octopus:hgm_andrea/items/switch:command:ON]"} 
    Switch  Aeon    "Switch[%s]" <switch>     {mqtt="<[octopus:hgm_andrea/items/switch:command:OFF]"}

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.

Switch Aeon "Switch [%s]" <switch> { zwave="4:command=switch_binary", mqtt="<[octopus:hgm_andrea/items/switch:command:ON]", mqtt="<[octopus:hgm_andrea/items/switch:command:OFF]" }

However, I also notice that the two MQTT bindings can be simplified to:

mqtt="<[octopus:hgm_andrea/items/switch:command:default]"

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

1 Like

This:

`Switch Aeon "Switch [%s]" <switch> { zwave="4:command=switch_binary", mqtt="<[octopus:hgm_andrea/items/switch:command:default]"}`

does not work.
When I send a message from the web, the open logs say:

`2016-09-19 18:36:34.547 [WARN ] [.c.i.events.EventPublisherImpl] - given command is NULL, couldn't post command to 'Aeon'`

I I use your suggestion:

`> Switch Aeon "Switch [%s]" <switch> { zwave="4:command=switch_binary", mqtt="<[octopus:hgm_andrea/items/switch:command:ON]", mqtt="<[octopus:hgm_andrea/items/switch:command:OFF]" }`

same result: the switch goes to ON and to OFF for anything I send from the broker.

It works with

Switch Aeon "Switch [%s]" <switch> { zwave="4:command=switch_binary", mqtt="<[octopus:hgm_andrea/items/switch:command:default]"}

The problem was the NULL terminated string. By sending the “pure” string without any NULL, everything works.
Thank you.