I think I found a bug in the NodeRed code.
26 Oct 11:03:16 - [info] [server:Home Assistant] Connected to http://supervisor/core
26 Oct 11:03:47 - [error] [ha-get-entities:Get current scene] Attempted to invoke a non-function
26 Oct 11:03:47 - [red] Uncaught Exception:
26 Oct 11:03:47 - [error] Error:
at applyInner (/opt/node_modules/jsonata/jsonata.js:4959:29)
at applyInner.next (<anonymous>)
at apply (/opt/node_modules/jsonata/jsonata.js:4896:26)
at apply.next (<anonymous>)
at evaluateFunction (/opt/node_modules/jsonata/jsonata.js:4871:30)
at evaluateFunction.next (<anonymous>)
at evaluate (/opt/node_modules/jsonata/jsonata.js:3522:34)
at evaluate.next (<anonymous>)
at thenHandler (/opt/node_modules/jsonata/jsonata.js:5562:37)
[11:03:47] INFO: Service Node-RED exited with code 1 (by signal 0)
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
My HA node red add on has been crashing for a few days, I finally tracked this error - invalid input in a get entities node.
What I was trying to do
I set up an environment variable - roominfo - on the flow of a json object representing several room specific values:
{
"area": "steves_office",
"dimmers": [
{
"name": "dimmer1",
"type": "Hue v1",
"device_ieee": "00:17:88:01:04:af:95:a0"
},
{
"name": "dimmer2",
"type": "Hue v2",
"device_ieee": "00:17:88:01:0b:59:ef:1a"
}
],
"illuminance_sensors": [
{
"name": "sensor.steves_office_sensor_illuminance"
},
{
"name": "sensor.steves_office_sensor2_illuminance"
}
],
"light": "light.steves_office",
"occupancy_sensors": [
{
"name": "binary_sensor.steves_office_sensor_occupancy"
},
{
"name": "binary_sensor.steves_office_sensor2_occupancy"
}
],
"occupancy_timer": "timer.steves_office_occupancy",
"scene_helper": "input_text.steves_office_last_scene",
"scene_motion_sensor_enabled": "input_boolean.steves_office_motion_sensor_enabled"
}
I was trying to access the scene_helper
entity id value using the following jsonata string $(roominfo.scene_helper) - I previously had a separate env variable called scene_helper and I could access the value using this jsonata $(scene_helper) - this was trying to reduce the number of env variables.
I corrected my flow to use a change node to set msg.payload to { "entityId": $$.roominfo.light }
and leave the get entities node Property field blank.
I looks like the field is not checking for a valid jsonata string, and then crashes. No sure if this is bug in the HA nodes or node-red or the jsonata lib.
p.s. why is it entityId in some places and entity_id in others?