Good Day to you all,
TLDR; I moved to HA from Google Home after becoming disenchanted with the automation options available within the Google ecosystem. I’ve been attempting unsuccessfully to harness the power of my entities but keep finding my logic within Node Red shortcoming. I’ve spent a while trying to work it out myself however feel it’s time to see if any more learned folk can help.
- What are you trying to achieve using Node Red?
- I have a group of lights in the lounge which I want to turn on when the LUX value falls to < 130 LUX.
- I want the lights to come on when I am in the home and a binary motion sensor is activated between Golden hour -60 minutes and 06:00 the following day.
- I want the lights to switch off when i enter the bedroom when either a binary motion sensor is triggered or a Google TV dongle is activated on my bedroom TV.
- I am trying to avoid sending multiple on or off commands to the group of lights once any of the above scenarios have been satisfied. (IE once the motion sensor detects once it doesn’t need to trigger the same message over and over each time motion detected).
Here is the output of my most recent attempt, previous attempts have been cast aside and deleted:
[
{
"id": "de4bad951531f479",
"type": "tab",
"label": "Lounge lighting",
"disabled": true,
"info": "",
"env": []
},
{
"id": "ab2afe209edc24c5",
"type": "group",
"z": "de4bad951531f479",
"name": "Turn lights on",
"style": {
"stroke": "#92d04f",
"fill": "#ffffff",
"label": true,
"color": "#000000"
},
"nodes": [
"df9c720eacb956c6",
"031c68077bc18dac",
"1617355ebacc4db2",
"88930498b53f17e3",
"789a1733450dc243",
"ea91d5e05a174083",
"96bfc1504188fcac"
],
"x": 14,
"y": 59,
"w": 752,
"h": 182
},
{
"id": "de13bd6c88f923d0",
"type": "group",
"z": "de4bad951531f479",
"name": "Turn lights off ",
"style": {
"stroke": "#ff0000",
"fill": "#ffffff",
"label": true,
"color": "#000000"
},
"nodes": [
"f9c374f9ad311072",
"0cb74b0f0cc19e6b",
"2124e5dbfff90f15",
"32456236fa902737",
"07d1d970d74a53c9"
],
"x": 14,
"y": 259,
"w": 612,
"h": 162
},
{
"id": "3564d90281a0a6e7",
"type": "group",
"z": "de4bad951531f479",
"name": "Bedroom TV on?",
"style": {
"stroke": "#ff0000",
"fill": "#ffffff",
"label": true,
"color": "#000000"
},
"nodes": [
"9875a68d5b7e2b35",
"0f93a5417d18341f",
"c2a808b1132d86ae"
],
"x": 14,
"y": 439,
"w": 612,
"h": 82
},
{
"id": "df9c720eacb956c6",
"type": "api-current-state",
"z": "de4bad951531f479",
"g": "ab2afe209edc24c5",
"name": "LUX level <130",
"server": "c87d326ff07b7f8c",
"version": 3,
"outputs": 2,
"halt_if": "130",
"halt_if_type": "num",
"halt_if_compare": "lt",
"entity_id": "sensor.lux_sensor_illuminance",
"state_type": "num",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 340,
"y": 100,
"wires": [
[
"1617355ebacc4db2"
],
[]
]
},
{
"id": "031c68077bc18dac",
"type": "inject",
"z": "de4bad951531f479",
"g": "ab2afe209edc24c5",
"name": "Interval",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "60",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 100,
"wires": [
[
"df9c720eacb956c6"
]
]
},
{
"id": "1617355ebacc4db2",
"type": "time-range-switch",
"z": "de4bad951531f479",
"g": "ab2afe209edc24c5",
"name": "",
"lat": "oops",
"lon": "oops",
"startTime": "08:00",
"endTime": "06:00",
"startOffset": "-60",
"endOffset": 0,
"x": 540,
"y": 100,
"wires": [
[
"ea91d5e05a174083"
],
[]
]
},
{
"id": "88930498b53f17e3",
"type": "trigger-state",
"z": "de4bad951531f479",
"g": "ab2afe209edc24c5",
"name": "Lounge Sensor",
"server": "b2dc7545.2e5d78",
"version": 4,
"inputs": 1,
"outputs": 2,
"exposeAsEntityConfig": "",
"entityId": "binary_sensor.lounge_motion_sensor_motion",
"entityIdType": "exact",
"debugEnabled": false,
"constraints": [
{
"targetType": "this_entity",
"targetValue": "",
"propertyType": "current_state",
"propertyValue": "new_state.state",
"comparatorType": "is",
"comparatorValueDatatype": "str",
"comparatorValue": "on"
}
],
"customOutputs": [],
"outputInitially": false,
"stateType": "str",
"enableInput": true,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"x": 300,
"y": 200,
"wires": [
[
"96bfc1504188fcac"
],
[]
]
},
{
"id": "789a1733450dc243",
"type": "api-call-service",
"z": "de4bad951531f479",
"g": "ab2afe209edc24c5",
"name": "Switch lights on",
"server": "c87d326ff07b7f8c",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_on",
"areaId": [
"living_room"
],
"deviceId": [],
"entityId": [
"light.group_living_room_lights"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 660,
"y": 200,
"wires": [
[]
]
},
{
"id": "ea91d5e05a174083",
"type": "api-current-state",
"z": "de4bad951531f479",
"g": "ab2afe209edc24c5",
"name": "Home?",
"server": "c87d326ff07b7f8c",
"version": 3,
"outputs": 2,
"halt_if": "0",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "zone.home",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 120,
"y": 200,
"wires": [
[
"88930498b53f17e3"
],
[]
]
},
{
"id": "f9c374f9ad311072",
"type": "trigger-state",
"z": "de4bad951531f479",
"g": "de13bd6c88f923d0",
"name": "Bedroom Sensor",
"server": "b2dc7545.2e5d78",
"version": 4,
"inputs": 1,
"outputs": 2,
"exposeAsEntityConfig": "",
"entityId": "binary_sensor.lounge_motion_sensor_motion",
"entityIdType": "exact",
"debugEnabled": false,
"constraints": [
{
"targetType": "this_entity",
"targetValue": "",
"propertyType": "current_state",
"propertyValue": "new_state.state",
"comparatorType": "is",
"comparatorValueDatatype": "str",
"comparatorValue": "on"
}
],
"customOutputs": [],
"outputInitially": false,
"stateType": "str",
"enableInput": true,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"x": 120,
"y": 380,
"wires": [
[
"07d1d970d74a53c9"
],
[]
]
},
{
"id": "0cb74b0f0cc19e6b",
"type": "api-call-service",
"z": "de4bad951531f479",
"g": "de13bd6c88f923d0",
"name": "Switch lights off",
"server": "c87d326ff07b7f8c",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_off",
"areaId": [
"living_room"
],
"deviceId": [],
"entityId": [
"light.group_living_room_lights"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 520,
"y": 380,
"wires": [
[]
]
},
{
"id": "2124e5dbfff90f15",
"type": "api-current-state",
"z": "de4bad951531f479",
"g": "de13bd6c88f923d0",
"name": "Home?",
"server": "c87d326ff07b7f8c",
"version": 3,
"outputs": 2,
"halt_if": "0",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "zone.home",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 380,
"y": 300,
"wires": [
[
"f9c374f9ad311072"
],
[]
]
},
{
"id": "32456236fa902737",
"type": "time-range-switch",
"z": "de4bad951531f479",
"g": "de13bd6c88f923d0",
"name": "",
"lat": "oops",
"lon": "-oops",
"startTime": "21:00",
"endTime": "06:00",
"startOffset": "",
"endOffset": 0,
"x": 120,
"y": 300,
"wires": [
[
"2124e5dbfff90f15"
],
[]
]
},
{
"id": "96bfc1504188fcac",
"type": "rbe",
"z": "de4bad951531f479",
"g": "ab2afe209edc24c5",
"name": "Send once",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"septopics": true,
"property": "payload",
"topi": "topic",
"x": 490,
"y": 200,
"wires": [
[
"789a1733450dc243"
]
]
},
{
"id": "07d1d970d74a53c9",
"type": "rbe",
"z": "de4bad951531f479",
"g": "de13bd6c88f923d0",
"name": "Send once",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"septopics": true,
"property": "payload",
"topi": "topic",
"x": 330,
"y": 380,
"wires": [
[
"0cb74b0f0cc19e6b"
]
]
},
{
"id": "9875a68d5b7e2b35",
"type": "trigger-state",
"z": "de4bad951531f479",
"g": "3564d90281a0a6e7",
"name": "Is bedroom TV on?",
"server": "c87d326ff07b7f8c",
"version": 4,
"inputs": 0,
"outputs": 2,
"exposeAsEntityConfig": "",
"entityId": "media_player.bedroom_tv",
"entityIdType": "exact",
"debugEnabled": false,
"constraints": [
{
"targetType": "this_entity",
"targetValue": "",
"propertyType": "current_state",
"propertyValue": "new_state.state",
"comparatorType": "is",
"comparatorValueDatatype": "str",
"comparatorValue": "playing"
}
],
"customOutputs": [],
"outputInitially": false,
"stateType": "str",
"enableInput": false,
"x": 130,
"y": 480,
"wires": [
[
"0f93a5417d18341f"
],
[]
]
},
{
"id": "0f93a5417d18341f",
"type": "rbe",
"z": "de4bad951531f479",
"g": "3564d90281a0a6e7",
"name": "Send once",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"septopics": true,
"property": "payload",
"topi": "topic",
"x": 330,
"y": 480,
"wires": [
[
"c2a808b1132d86ae"
]
]
},
{
"id": "c2a808b1132d86ae",
"type": "api-call-service",
"z": "de4bad951531f479",
"g": "3564d90281a0a6e7",
"name": "",
"server": "c87d326ff07b7f8c",
"version": 5,
"debugenabled": false,
"domain": "switch",
"service": "turn_off",
"areaId": [
"living_room"
],
"deviceId": [
"8f8b21c54afc68aba4c7830cdc41772a"
],
"entityId": [
"switch.smart_switch_2009220813078290831148e1e9346b7e_outlet"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 520,
"y": 480,
"wires": [
[]
]
},
{
"id": "c87d326ff07b7f8c",
"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": ": ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "default",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": false
},
{
"id": "b2dc7545.2e5d78",
"type": "server",
"name": "Home Assistant",
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true
}
]
Currently, my lights do not behave as intended and do not respect the timer. Any help on this would be gratefully received.
Best Wishes,