Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group items state after reboot / powercycle #99

Closed
nagyrobi opened this issue Mar 18, 2021 · 4 comments
Closed

Group items state after reboot / powercycle #99

nagyrobi opened this issue Mar 18, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@nagyrobi
Copy link
Collaborator

nagyrobi commented Mar 18, 2021

Group items state is lost after reboot. To reproduce:

  • Put a toggle button or switch object, and a relay in the same group.
  • touch the object, it's value will be on the relay turns on
  • reboot the plate (from the web interface)
  • during boot the relay stays on (correctly), but after boot the object displays as off, state in MQTT is on (as no update came)

Also inconsistent state occurs after power-cycling. To reproduce:

  • Put a toggle button or switch object, and a relay in the same group.
  • touch the object, it's value will be on the relay turns on
  • power-cycle the plate. The relay turns off due to power loss
  • during boot the relay stays off (correctly), after boot the object displays as off, state in MQTT is on, incorrect (as no update came)

I don't think we should save the state to the flash, instead we should check the state of the GPIO outputs in the group after boot and set the state of the objects accordingly. Also send an MQTT update about these to make sure real state is correct after reboot or power cycling and MQTT server reconnection.

It's important imho not to rely exclusively on the HA system to update states of the objects, when we're talking about outputs and objects on the same device. Reboots and power cycles are situations close to (prolonged) offline status. A plate boots in 1-2 seconds, a HA system can boot for minutes until plates are ready to connect. And states in the HA system can be really messed up after a boot.

@nagyrobi nagyrobi added the bug Something isn't working label Mar 18, 2021
@nagyrobi
Copy link
Collaborator Author

Please note that Github labels the issues automatically as bug and assigns them to @fvanroie , it was not me who puts these labels on. I don't have permission to change these afterwards.

@fvanroie fvanroie added enhancement New feature or request and removed bug Something isn't working labels Mar 18, 2021
@fvanroie fvanroie removed their assignment Mar 18, 2021
@fvanroie
Copy link
Collaborator

Please note that Github labels the issues automatically as bug and assigns them to @fvanroie , it was not me who puts these labels on. I don't have permission to change these afterwards.

When you open a bug report, these get added automatically. Opening a Feature request or question will add the appropriate labels too. When in doubt, join our discussion forum or Discord channel and we'll happily discuss it there first.

@fvanroie
Copy link
Collaborator

Moved from #123

Is your feature request related to a problem? Please describe.
Similar to group items, moodlight color, state (and brightness after implemented) should be remembered after reboot / powercycle.
If HA and plate both reboot while the moodlight was turned off, nobody remembers what was the pre-selected moodlight attribute. At HA reboot, the current of moodlight color is read from the plate because HA doesn't keep the color attribute when light is off. If plate also reboots during this time (eg. power outage affecting all devices), nobody remembers what was the pre-selected color.

Describe the solution you'd like
When moodlight command comes in with color key, check if moodlight color info is saved to the flash. If moodlight color info in flash is different of what came with the command, write to flash the new color info (save flash writes if every {"state":"true"} command comes with the same color info every time...)
At boot restore moodlight color info (and state) from flash.

Describe alternatives you've considered
Only this

Additional context
Not applicable

@fvanroie
Copy link
Collaborator

Atm, joining an object or gpio to a group will not set the item to the last known group state.
In fact, the group state is not kept at all but only fired on change events.

So this would require keeping the last group state, on join: set new members of the group to that state and advertise the new value of the item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants