thomasloven / hass-plejd

🔹 Plejd BLE integration for Home Assistant
81 stars 10 forks source link

Reload of integration triggers all events #53

Open bnordli opened 5 months ago

bnordli commented 5 months ago

When I manually reload the integration (to get updated information from Plejd) all scenario and button events are triggered.

This is quite unfortunate, as this leads to all hooks for those events being triggered in HA.

This is a snapshot of my logbook just during the reload:

image

the logbook continues with all button press events being fired, then all (Plejd) scenario events being fired, then all button press events being fired (again!), then lights turning unknown (this is expected), then lights going to their actual state (also expected).

oleost commented 5 months ago

This is issue for me aswell, using a Plejd scenario to control my screens up and down with double click of a button. Reloading integration makes my screens move.

igalg99 commented 4 months ago

I had this problem too , in automation in trigger I had to add "not_from" , "not_to"

platform: state
entity_id: event.bedroom_low_light_activated
not_from:
  - unknown
  - unavailable
not_to:
  - unknown
  - unavailable

You can refer to this topic: https://community.home-assistant.io/t/help-with-triggering-an-automation-only-when-date-is-changed-in-the-state/630111/9

I Hope I understood your problem and my comments are relevant

bnordli commented 4 months ago

This is a very helpful trick! I think it is impossible for this integration to get around this, since I assume HA sets all entities belonging to any integration as "unavailable" while the integration is reloading.

thomasloven commented 4 months ago

That's exactly right. I've raised this issue with the core team, and while there's no good ideas right now, at least there's hope. image