icanos / hassio-plejd

Hass.io add-on for Plejd home automation devices
Apache License 2.0
126 stars 36 forks source link

MQTT startup bugfix #268

Closed pierrei closed 8 months ago

pierrei commented 1 year ago

I got this issue myself where lights would automatically would turn on when HA restarted.

It seems like the problem is that when the MQTT client is set up it's directly hooked up to listen to updates from MQTT even before we do the HA "discovery". The discovery sends things to MQTT and it seems to trigger the unwanted update where we will receive state changes on lights when they actually didn't change at all.

There are many ways to fix this problem but I figured it would be easiest to just ignore any incoming messages from MQTT while the discovery is running.

I tried this at home and before this fix I had the bug described in the issue:

  1. Turning on a light in HA
  2. Restarting the Plejd add-on
  3. Turning off the light with the Plejd app
  4. When the Plejd add-on starts up it turns on the light

With this fix the light no longer comes on.

pierrei commented 1 year ago

I'm actually having some issues with this fix so I'm investigating. The bug is no longer there since it seems it cannot connect to MQTT at all now for some reason 😆

pierrei commented 1 year ago

The client ID fix that I tried first didn't actually fix the problem. Investigated some more and figured out the problem is because we're listening to MQTT messages when the discovery is running that's pushing stuff to MQTT. PR updated to fix this instead and PR description and title was updated too.

timjackson commented 1 year ago

Is this a competing fix for pull #260 ? Or are they addressing different aspects of the same problem?

pierrei commented 1 year ago

@timjackson I had a look and it seems they're not conflicting changes but might solve the same issue but from two different angles. I'd ask the owner/creator of this project to chime in on this and make a call, but unfortunately it seems like he's not very active. I'm running this branch on my own Home Assistant and it's working great, so if you ask me we should merge this one! :)

SweVictor commented 1 year ago

Has anyone apart from @pierrei tried this fix for any length of time? Plejd mesh/comms issues is typically quite tricky. Not saying that there are issues with the fix, just wondering how many have tried it.

Mats1717 commented 1 year ago

Hi to this conserns This fork works for my garage door not opening on restart or power failure. Please integrate this in this verision. All other forks get the garage door open in random time due to restart or power failure. Have som lights also and no problem with this fork. Tried the 10 version today and garage door was opend directliccly.

https://github.com/tomjaimz/hassio-plejd tomjaimz good jobb

SweVictor commented 8 months ago

Closing this since #297 is in the develop branch. Please test that and we'll reopen this if it's still needed