icanos / hassio-plejd

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

Light Persistence #294

Closed spripe closed 9 months ago

spripe commented 10 months ago

Description

This PR addresses an issue in the hassio-plejd integration where dim levels and lighting states are inadvertently changed upon restarting the service. Currently, if a light (e.g., Light A) was on just before hassio-plejd was stopped, and the lighting is turned off via plejd during the downtime, upon restarting hassio-plejd, the light's state does not revert to the last known state as expected. Instead, the integration seems to set the lighting to a presumed state without consulting the actual last-known state.

Expected Behavior

The ideal functionality would be for the integration not to make assumptions about the desired lighting state or dimming level upon restart. It should instead 'listen' to the current state and update the actual value via MQTT before setting any values actively.

Ignoring received MQTT messages while doing discovery seems to work: https://github.com/tomjaimz/hassio-plejd/commit/f827806c362293c51aa8725f04e8a50470f63ffb

Solution?

SweVictor commented 10 months ago

@spripe - what does "This PR" refer to? This is an issue and not a PR. Feel free to open a new PR towards the develop branch if you have a suggested code fix in mind.

There is a PR #268 that might work, but I think it's at best a partial fix.

There is also #260.

The issue has been discussed at length in #218. I've added what I consider to be the best way forward in https://github.com/icanos/hassio-plejd/issues/218#issuecomment-1683747009. I started some work in this direction (MQTT mainly), but got derailed when a new HA update suddenly caused this addon to stop working (now resolved).

SweVictor commented 9 months ago

This issue should be resolved in the latest update to the develop branch through PR #297 .