[SOLVED] Mqtt (1x) - should it "relay" back out?


I’ve got the following:

Switch   Kitchen_sw_Chand          "Kitchen Chandelier"         (g_persist_change, g_KitchenCeiling)        {

Switch  Kitchen_sw_Breakfast 	        "Kitchen Breakfast Bar" 	<wallswitch>	(
                                                                                g_KitchenCeiling, g_Lights_Random, gLights, g_persist_change, gAlexaHouseStatusNotOn, g_KitchenCeilingProxy

I was hoping, but not expecting, this to work. Idea is that when someone turns on the breakfast bar lights the chandelier must also turn on.

When someone turns on the breakfast bar lights a message is published on mqtt, status = 1. This works fine. OH reads this message and the Kitchen_sw_Chand item goes from off to on. All good.

However, the ON is not published back to the new topic. Should it be?

The same happens when you turn it off; the message is published, the item changes to OFF but a new message is not published.

It’s worth noting that the thing doing the publishing is a sonoff I have on the lighting circuit which publishes when it connects and the LWT message when it dies (someone turned the lights off)

I thought I could avoid a rule doing it this way. Does the 2.x binding support this? Reason to finally make the move…?


IMHO you would need to send an outbound message via mqtt in order to switch the device. Like the first two lines of your “Kitchen_sw_Chand”.

Sorry, only just saw this reply…

Not sure that would do it. When the switch (Breakfast Bar) gets the OFF command it sends it to rfxcomm channel which then turns the physical light off.
When the mqtt gets the OFF command it turns the switch off (You can see it change in events log) but the OFF is not sent to the channel. It’s like the channel did not pick it up.

Not sure if I misunderstood you?

That is correct, it’s by design. In general, bindings listen for openHAB commands to Items, and transmit them on to whatever the medium is. Incoming events from the medium cause state updates to Items.

The cleanest way to do this is with a rule. Also has the advantage that you can add some conditions e.g. not before 6am and only if weekdays.

Well, it does allow the exception to the rule.
See the postCommand option for a channel.

Yup, where I wanted additional logic, rules are used. This though is just linking two lights together.


Guess I’ll start the change over to mqtt 2 binding now :slight_smile: