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

Trigger switches don't correctly restore state after restart #223

Closed
mdegat01 opened this issue Mar 29, 2020 · 1 comment
Closed

Trigger switches don't correctly restore state after restart #223

mdegat01 opened this issue Mar 29, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@mdegat01
Copy link

Version of the custom_component

0.4.1

Configuration

I have an events: all node and an events: state node, both of which I have checked the box to "expose to home assistant". I can confirm that I see the switches in home assistant and when I toggle them they do what I expect (disable or enable the nodes).

Describe the bug

The issue occurs when I restart home assistant. Whenever home assistant is restarted, it doesn't seem to keep track of what state the switches were in. It always seems to restore the switches back to the same state regardless of what state they were in prior to shutdown. I believe restoring them back to the state they were in last time I deployed that flow in Node RED. It doesn't seem to have anything to do with what state they were actually in at restart, the only way I've been able to change the initial state is by redeploying the flow in Node RED after adjusting the switches

This creates a problem because now I get into situations where the switches are out of sync with node RED. Here's what I see in node RED right now for these two nodes:
Screen Shot 2020-03-29 at 12 31 38 AM
Here's the config panel for the node named "Person detected downstairs" that is disabled:
Screen Shot 2020-03-29 at 12 05 45 AM
And here's the config panel for the node named "Dark out" that is enabled:
Screen Shot 2020-03-29 at 12 05 37 AM

And now here is what I see for those matching switches in HA right now:
Screen Shot 2020-03-29 at 12 32 34 AM
Screen Shot 2020-03-29 at 12 32 47 AM

You can see that according to Home Assistant the switches are in the exact opposite state which their corresponding nodes are actually in.

This makes it pretty difficult to use this feature in the UI since I obviously have to restart HA pretty often to make changes to it. So when looking at the UI of HA I can't really trust the state I'm seeing without confirming in Node RED.

I would note that its not all bad. It's more important to me that Node RED keeps those nodes in the correct state then that HA does. And if I redeploy the flow in Node RED it keeps the state of my nodes and fixes the switches, it does not restore the nodes to the incorrect state of the switches. Also service calls still work correctly (if I do switch turn on and the switch says on but the node is disabled then the node still re-enables even though the switch state didn't change).

But still I would expect that either the state of the switches restore to what they were after a restart. Or that they're state is set to the state of their matching node in Node RED during startup.

Debug log

Here's the debug log I see during startup creating those switches

2020-03-29 00:25:49 DEBUG (MainThread) [custom_components.nodered.discovery] Discovery message: {'type': 'nodered/discovery', 'server_id': 'cc03735a.94933', 'node_id': 'f12b7d0e.98eae8', 'component': 'switch', 'state': True, 'config': {'name': 'Downstairs presence lights', 'icon': 'mdi:motion-sensor'}, 'id': 10}
2020-03-29 00:25:49 INFO (MainThread) [custom_components.nodered.discovery] Creating switch cc03735a.94933 f12b7d0e.98eae8
2020-03-29 00:25:49 DEBUG (MainThread) [custom_components.nodered.discovery] Discovery message: {'type': 'nodered/discovery', 'server_id': 'cc03735a.94933', 'node_id': '32243bbe.2f6c24', 'component': 'switch', 'state': False, 'config': {'name': 'Sunset watcher', 'icon': 'mdi:weather-sunset'}, 'id': 11}
2020-03-29 00:25:49 INFO (MainThread) [custom_components.nodered.discovery] Creating switch cc03735a.94933 32243bbe.2f6c24
@zachowj zachowj transferred this issue from zachowj/hass-node-red Mar 30, 2020
@github-actions
Copy link
Contributor

@mdegat01: hello! 👋

This issue is being automatically closed because it does not follow the issue template.

Fixing this with automatically reopen the issue.

@zachowj zachowj reopened this Mar 30, 2020
@zachowj zachowj added bug Something isn't working and removed 🙁 Not following issue template labels Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants