quazzie / tellstick-plugin-mqtt-hass

Plugin for tellstick, connect to homeassistant via mqtt with autodiscovery.
39 stars 7 forks source link

Config messages are (re-) published on LAN/WAN being reestablished #12

Closed uphillbattle closed 4 years ago

uphillbattle commented 4 years ago

I'm not sure this is a bug or even undesired, but I thought I'd put the question out there:

Yesterday, I first rebooted my internet modem and later in the evening my router.

On both occassions, I noticed that automations that trigger on state changes for MQTT entities (from the Telldus Znet Lite v2) triggered. I have a few Nexa 433 MHz remotes that I use to trigger automations (switching lights on and off), and I rely on the expire_after feature for that. I found that after LAN/WAN has been reestablished, all config messages are republished.

When the config messages are published, the MQTT entities in HA go from unavailable to whatever status the remote has in the Telldus hub (so if the last button push on the remote was OFF, the entity's state in HA goes from unavailable to OFF). Or maybe it goes from unavailable to the last available state in HA instead of the current state in the Telldus hub - but the two should be the same. Either way, going from unavailable to a state triggers the automation.

Furthermore, the entity's state in HA does not expire after going from unavailable to a state after a config message has been issued. This is a HA problem. I've raised HA issue #28634, but I have not got any response.

Anyway, back to the republishing of config messages: Is this a desired behavior?

quazzie commented 4 years ago

I thinks its desired behavior because the plugin does not know what configs/entities is retained and such, and as it's the same config it should not be a problem. But i think i also publish state at the same time and i think that is causing you problems. I think it should not send remote state on connect.

quazzie commented 4 years ago

Uhm no, just as i posted this i see that i do not publish the state for remote on connect.

uphillbattle commented 4 years ago

I thought so, that it might be desired behavior. It should, however, be filtered at the HA end - that the state should not change on a config message.

And, no, you're correct, for remotes (aka binary_sensor) you do not publish the state, so it's just the fact that HA changes the entities' states on config messages that cause the problem.

Anyway, thanks for trading thoughts on this. I'll close the issue and hope it gets sorted on the HA end of things.