Hey,
I want to apologize for any confusion earlier. In the meantime, I managed to make some progress with my setup by following this guide. Just to provide some context, I’m running Home Assistant OS on a Raspberry Pi 4 with 8GB of RAM, and here are the current versions of my components:
Home Assistant 2023.9.2
Supervisor 2023.09.2
Operating System 10.5
Frontend 20230911.0 - latest
Node Red Version: 14.5.0
Here's the json code of the current setup:
[
{
"id": "5d3e6a926ed1e358",
"type": "tab",
"label": "Küche",
"disabled": false,
"info": "",
"env": []
},
{
"id": "d1c515eeffd52499",
"type": "api-call-service",
"z": "5d3e6a926ed1e358",
"name": "Kitchen Light on",
"server": "296e23cb.be16fc",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"light.kuche"
],
"data": "{\"brightness\":msg.data.attributes.brightness}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 810,
"y": 440,
"wires": [
[]
]
},
{
"id": "911c51d0705ea6a7",
"type": "api-call-service",
"z": "5d3e6a926ed1e358",
"name": "Kitchen lights off",
"server": "296e23cb.be16fc",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_off",
"areaId": [],
"deviceId": [],
"entityId": [
"light.kuche"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 810,
"y": 280,
"wires": [
[]
]
},
{
"id": "7fcd4a91fe0f5606",
"type": "server-state-changed",
"z": "5d3e6a926ed1e358",
"name": "Motion detected",
"server": "296e23cb.be16fc",
"version": 4,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfilter": "binary_sensor.bewegungssensor_kuche_motion",
"entityidfiltertype": "exact",
"outputinitially": false,
"state_type": "str",
"haltifstate": "off",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 2,
"output_only_on_state_change": true,
"for": "50",
"forType": "num",
"forUnits": "seconds",
"ignorePrevStateNull": false,
"ignorePrevStateUnknown": false,
"ignorePrevStateUnavailable": false,
"ignoreCurrentStateUnknown": true,
"ignoreCurrentStateUnavailable": true,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
},
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "triggerId"
}
],
"x": 100,
"y": 320,
"wires": [
[
"e090a184b861a09c"
],
[
"e090a184b861a09c",
"2ce0a46d82e48b9d"
]
]
},
{
"id": "e090a184b861a09c",
"type": "trigger",
"z": "5d3e6a926ed1e358",
"name": "wait 10s",
"op1": "dimm",
"op2": "off",
"op1type": "str",
"op2type": "str",
"duration": "10",
"extend": false,
"overrideDelay": false,
"units": "s",
"reset": "on",
"bytopic": "all",
"topic": "topic",
"outputs": 2,
"x": 580,
"y": 240,
"wires": [
[
"c50a8a857ee5bc73"
],
[
"911c51d0705ea6a7"
]
]
},
{
"id": "790b9a5334cf65e6",
"type": "api-call-service",
"z": "5d3e6a926ed1e358",
"name": "dimm kitchen lights",
"server": "296e23cb.be16fc",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"light.kuche"
],
"data": "{\"brightness\":msg.data.attributes.brightness/2}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1060,
"y": 200,
"wires": [
[]
]
},
{
"id": "c50a8a857ee5bc73",
"type": "api-current-state",
"z": "5d3e6a926ed1e358",
"name": "current brightness",
"server": "296e23cb.be16fc",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "light.kuche",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
},
{
"property": "lightBrightness",
"propertyType": "flow",
"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": 810,
"y": 200,
"wires": [
[
"790b9a5334cf65e6"
]
]
},
{
"id": "2ce0a46d82e48b9d",
"type": "change",
"z": "5d3e6a926ed1e358",
"name": "",
"rules": [
{
"t": "set",
"p": "data",
"pt": "msg",
"to": "lightBrightness",
"tot": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 580,
"y": 440,
"wires": [
[
"d1c515eeffd52499"
]
]
},
{
"id": "72e5e5091f7292e8",
"type": "time-range-switch",
"z": "5d3e6a926ed1e358",
"name": "Between time",
"lat": "53.522449",
"lon": "8.479580",
"startTime": "sunset",
"endTime": "sunrise",
"startOffset": "- 00:30:00",
"endOffset": 0,
"x": 280,
"y": 600,
"wires": [
[],
[]
]
},
{
"id": "ed58edceae64ce76",
"type": "api-current-state",
"z": "5d3e6a926ed1e358",
"name": "lower than 20lux",
"server": "296e23cb.be16fc",
"version": 3,
"outputs": 2,
"halt_if": "20",
"halt_if_type": "num",
"halt_if_compare": "lt",
"entity_id": "sensor.bewegungssensor_kuche_illuminance",
"state_type": "str",
"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": 290,
"y": 660,
"wires": [
[],
[]
]
},
{
"id": "296e23cb.be16fc",
"type": "server",
"name": "Home Assistant",
"addon": true
}
]
However, I’m now facing a challenge. I’d like to incorporate two conditions into my existing Node-RED flow, but I’m not quite sure where to integrate them. To be honest, the flow I’ve set up based on the guide feels somewhat unintuitive, to say the least. The two conditions I want to add are:
- A “time range” condition (specifically, between sunset and sunrise).
- An “if illuminance sensor <20 lux” condition.
They should act as “Or-Conditions”. So if one or both of them are true, trigger.
Setting up the time range node seems straightforward, and I hope using a"current state" node for the illuminance condition is the right way to do it.
My question is, where should I place these conditions within my existing flow? I’ve tried a few configurations, but each time, I encountered strange behavior, such as the lights turning on when there was no motion detected. Everything works smoothly without these conditions, so I’m a bit puzzled.
Any guidance on where to implement these conditions would be greatly appreciated!
Thanks in advance.