MQTT Eventbus and retain

Can the MQTT Event bus out states be set as retain?

I’m using the Event bus for populating an home assistant instance, mostly for the homekit integration. It works really well. But on restart of homeassistant (which is much more frequent the OH due to the way it works), it doesn’t retain states…and some items never push out a state update, ie a zwave switch that is turned on at the start of the day.

I couldn’t see anything in the event bus config that allowed for the setting of the retain flag. Or is there where MQTT Persistence should be used? But I got the impression that I had to set up a new mqtt topic path for the persistence.

I guess a third option is a command the forces all items to post an update?

Set the retain flag to true in mqtt.cfg. You can only set the retain flag for an entire broker. If you need some messages to be retained and some not retained you need to configure two broker configurations in mqtt.cfg, one with the retain flag set and one without. Then select the one with the flag set in the mqtt-eventbus.cfg.

1 Like

oh awesome idea…
SO two brokers to same MQTT server, one with retain, one without, and use the 2nd for the eventbus…

I assume I can’t be selective in any way about the event bus? it’s all or nothing right?

Correct, it’s all or nothing.

No problem.

That solution works well. Now when home assistant restarts, it remembers the last setting if it had been updated via openhab.

Now THAT is a very good application
There are several users of HA and openHAB
Could you write up a tutorial on how you configured your system to do that.
I am sure that others will be interested.

I might be able to. Now that things have stablised I can write it up…

Done: Using the MQTT Event Bus for driving another OpenHAB or Home Assistant