node-red-contrib-home-assistant-websocket
node-red-contrib-home-assistant-websocket copied to clipboard
'call service' nodes are failing after upgrade: required key not provided
Describe the bug
After Upgrading the Node-Red Addon from v16.0.2 to 17.0.2, the "call service" nodes are failing, e.g.:
[error] [api-call-service:TV: Source Live TV] HomeAssistantError: required key not provided @ data['source']
The data for that node wasn't changed during the update and still contains: {"source":"LiveTV"}
.
To Reproduce
Upgrade Node-Red addon from 16.0.2 to 17.x.x
Expected behavior
"call service" nodes should still be working.
Screenshots
No response
Example Flow
No response
Environment Information
Version: 0.62.3
Home Assistant version: 2024.1.3 Companion version: 0.0.0
Node-RED version: 3.1.3 Docker: yes Add-on: undefined
Node.js version: v18.19.0 arm64 linux OS: Linux 6.1.63-haos-raspi arm64
Additional context
Probably related: https://github.com/hassio-addons/addon-node-red/issues/1802
If you turn on debugging in the call-service node what does the debug tab show it is sending to Home Assistant?
Probably related: https://github.com/hassio-addons/addon-node-red/issues/1802
That error is probably due to using an outdated version of this package.
If you turn on debugging in the call-service node what does the debug tab show it is sending to Home Assistant?
This weird. As soon as I activate debugging for that node and deploy, the error is gone and it works like it should. The debug output is:
14.1.2024, 23:39:33TV: Source Live TV
msg :
object
domain: "media_player"
service: "select_source"
target: object
entity_id: "media_player.tv"
data: object
source: "LiveTV"
I restored 16.0.2 again, upgraded and the error is there again. To see if the deployment fixed it, I just moved the node a bit, without making any other change and deployed it. The error was still there. As soon I activate debugging and deploy, the error is again gone.
Turning on debug does not change anything other than prints to the debug console. Is the call-service being activated the same? Do you override the data field by accident?
I did more testing. It has nothing to do with the debug option. If I open the node, making no changes and hit done, something is changed (behind the scenes). Because after that, the deploy button turns red so I can deploy. If I then open the node again, making no changes and hit done, the deploy button remains "disabled". This is not something specific to that specific "call service" node, other nodes with the same issue behave the same. I can now "fix" all not working nodes, but I'm still wondering, what went wrong in my setup.
I did more testing. I reverted back to the working 16.0.2 addon version. Then I exported the node as json. After that, I upgrade to 17.0.3 and fixed the node by just opening them and clicking done. As earlier noticed, this alone changed something in the node. To confirm that, I exported the node again.
Node Export 16.0.2
[
{
"id": "f3b62135.127aa",
"type": "api-call-service",
"z": "1c9d28fa.d1c817",
"name": "TV: Source Live TV",
"server": "81dba471.c33528",
"version": 5,
"domain": "media_player",
"service": "select_source",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.tv"
],
"data": "{\"source\":\"LiveTV\"}",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 850,
"y": 280,
"wires": [
[
"116c5b62.93bd2d",
"14eafb16.d8a37d"
]
]
},
{
"id": "81dba471.c33528",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": "at: ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "h23",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": true
}
]
Node Export 17.0.3
[
{
"id": "f3b62135.127aa",
"type": "api-call-service",
"z": "1c9d28fa.d1c817",
"name": "TV: Source Live TV",
"server": "81dba471.c33528",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "select_source",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.tv"
],
"data": "{\"source\":\"LiveTV\"}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 850,
"y": 280,
"wires": [
[
"116c5b62.93bd2d",
"14eafb16.d8a37d"
]
]
},
{
"id": "81dba471.c33528",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": "at: ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "h23",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": true
}
]
The second export has these two additional lines:
"debugenabled": false,
"dataType": "jsonata",
Having the same issue for a long time. Run both HA and node-red in docker. Currently: Home Assistant: 2024.1.6 Node-red: 3.1.3 node-red-contrib-home-assistant-websocket: 0.63.0 It seems to resolve by restarting the HA docker container. No change by restarting the node-red docker container. If I restart HA from the UI the issue returns. But sometimes it is the nodes with light domain and sometimes the climate domain. If I close the node dialog by clicking Cancel the Deploy button stays grey. If I close the node dialog by clicking in the flow area the Deploy button becomes red.
This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Is literally the only way to fix this to go to every home assistant node, resave it and deploy?! I've got hundreds of nodes, is there not a way to quickly do this with a command or something?
That error is probably due to using an outdated version of this package.
@brettjenkins What version of the HA nodes are you running? This is old bug that has been fixed.
Is literally the only way to fix this to go to every home assistant node, resave it and deploy?! I've got hundreds of nodes, is there not a way to quickly do this with a command or something?
Unfortunately, I didn't find another solution. Going through each node would take a lot of time, that's why I currently still stick with the last working version 16.0.2 of the node red addon.