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

Switches created in NR marked unavailable in global context after node red restart #292

Open
dpgh947 opened this issue Aug 12, 2024 · 3 comments

Comments

@dpgh947
Copy link

dpgh947 commented Aug 12, 2024

Describe the bug

This is a strange problem, not sure where the problem lies, so I'm starting here: I use the "expose as" settings on nodes that support it a lot, it creates a switch in HA which can be used to disable the node (for example, events: state node), this gives an easy way to turn NR automation routines on/off from HA.

I also make use a lot of the entity states available under global context (for example, global.homeassistant.homeAssistant.states["switch.automatic_study_light_control"].state) to get an entity state in various nodes without having to use a separate "current state" node. I have noticed that the state of all these switches created by "expose as" is showing "unavailable" in the global context after a node red addon restart (EG: for an upgrade). Any explicit get for a state returns the current setting in HA as expected, it is just the global context value that is out of step. If I then restart HA, they all get set correctly.

To Reproduce

Create an "expose as" switch on an events state node. Look at the state in HA and in the global context (Global - homeassistant - homeAssistant - states). Note how the switch disables the node. Then restart the node red addon, and look at the states again. HA will say ON or OFF as expected, the context will say unavailable. If you toggle the switch in HA, it corrects the context, as does an HA restart.

Expected behavior

The global context values for these switches should reflect the HA values after a node red restart, shouldn't be "unavailable".

Screenshots

No response

Example Flow

No response

Environment Information

Version: 0.65.1

Home Assistant version: 2024.8.1
Companion version: 4.0.1

Node-RED version: 4.0.2
Docker: yes
Add-on: no

Node.js version: v18.20.3 arm64 linux
OS: Linux 6.6.31-haos-raspi arm64

Additional context

No response

@dpgh947
Copy link
Author

dpgh947 commented Aug 12, 2024

I have had this happen twice, today I figured it was after a restart to upgrade node red, but I have been testing how to find all the unavailable global context states, I have that working but now I cannot reproduce the problem by restarting node red, so I don't know what causes this...

Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Oct 12, 2024
@zachowj zachowj removed the Stale label Oct 12, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Dec 12, 2024
@zachowj zachowj removed the Stale label Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants