-
-
Notifications
You must be signed in to change notification settings - Fork 108
custom component switch gets unavailable after changing the state in HA #1721
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
Comments
Is there a reason you're not using the switch node which will handle all the background tasks for you? The issue with the switch entity lies in the communication protocol. The discovery call, intended to be a subscription call, should establish a two-way path. This path would allow Home Assistant to send data back to Node-RED, such as updates on the switch's state. However, the API node in Node-RED can only make one-way calls and cannot receive subscriptions. Consequently, when the switch's state changes in Home Assistant and this information is sent to Node-RED, Node-RED expects a response. Since the two-way communication was never established and Node-RED never received the update from Home Assistant, it cannot update Home Assistant accordingly. Home Assistant then interprets this lack of response as the switch becoming unavailable. |
Hi @zachowj , thank you for your quick response. I really appreciate your detailed explanations. I'm using the switch node a lot, as well as the other nodes (binary sensor, sensor, number ...), for instance to process data from my entities within nodered and have the possibility to view the result and interact from HA dashboards. At some point in time, as flows got bigger, I started to generalize the functionality by introducing a As a core functionality for my In principle I'm trying to re-produce the Anoher solution could be to listen for switch changes by the
Do you see any workaround that I could implement? Thank you a lot in advance. |
Describe the bug
Creating a switch with API:
nodered/discovery
works as expected.Also changing the state in nodered through API:
nodered/entity
works well, the switch is shown in homeassistant dashboards and the state is reflected correctly.But when changing the switch state in homeassistant, it immediately gets "unavailable".
Then, also any further change through API:
nodered/entity
has no effect.To Reproduce
Expected behavior
The switch should schange the state and be available
Screenshots
Switch in homeassistant after registering with

nodered/discovery
Switch after trying to change state in HA

Note: "German "nicht verfügbar" = "not available"
Example Flow
Environment Information
Version: 0.74.2
Home Assistant version: 2024.12.5
Companion version: 4.1.2
Node-RED version: 4.0.3
Docker: yes
Add-on: 18.1.1
Node.js version: v18.20.4 arm64 linux
OS: Linux 6.6.62-haos-raspi arm64
Additional context
No response
The text was updated successfully, but these errors were encountered: