Function to turn off first floor lights when Kallen leaves for school

#29
This commit is contained in:
2025-03-22 16:01:01 -04:00
parent 61c34a2a96
commit 8a9b4669a6

View File

@ -1962,7 +1962,10 @@
"20b3699a56b0e901",
"f3df71ec460b7609",
"775777f1c01e424c",
"334c28e08be1db12"
"334c28e08be1db12",
"de09ef54cbab864a",
"5c919106ebd7c9d4",
"75072695f27adae7"
],
"x": 14,
"y": 239,
@ -9181,7 +9184,7 @@
"id": "26f15fc8d75a4020",
"type": "link out",
"z": "3abb5ae57afb4761",
"name": "Presence Detection Output",
"name": "Presence Detection for Front Porch",
"mode": "link",
"links": [
"f34816b23181f21e"
@ -10795,7 +10798,9 @@
"z": "3abb5ae57afb4761",
"name": "Kallen Presence - Out",
"mode": "link",
"links": [],
"links": [
"de09ef54cbab864a"
],
"x": 335,
"y": 940,
"wires": []
@ -26249,6 +26254,75 @@
]
]
},
{
"id": "de09ef54cbab864a",
"type": "link in",
"z": "5c4ac37140a54ac9",
"g": "f4057835848d0904",
"name": "Kallen Presence to Goodnight Flow",
"links": [
"547753c8de135e69"
],
"x": 105,
"y": 460,
"wires": [
[
"5c919106ebd7c9d4"
]
]
},
{
"id": "5c919106ebd7c9d4",
"type": "function",
"z": "5c4ac37140a54ac9",
"g": "f4057835848d0904",
"name": "Filter",
"func": "const states = global.get('homeassistant.homeAssistant.states')\nconst schoolToday = states['input_boolean.kallen_school_today'].state\nconst kallen = states['person.kallen_stork'].state\nconst morning = states['binary_sensor.morning'].state\nconst masterBedroomSleeping = states['input_boolean.master_bedroom_sleeping'].state\nconst payload = msg.payload\n\nlet presence = {}\n\nif (payload === 'home') {\n presence = 'on'\n} else if (payload != 'unavailable' && payload != 'unknown') {\n presence = 'off'\n}\n\nif (schoolToday === 'on' && kallen != 'home' && morning === 'on') {\n if (presence === 'off' && masterBedroomSleeping === 'on') {\n node.send(msg)\n node.status({fill:'green',shape:'dot',text:'Kallen left, first floor lights off'})\n } else {\n return null\n }\n} else {\n return null\n}",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 175,
"y": 460,
"wires": [
[
"75072695f27adae7"
]
],
"l": false
},
{
"id": "75072695f27adae7",
"type": "api-call-service",
"z": "5c4ac37140a54ac9",
"g": "f4057835848d0904",
"name": "First Floor Lights Off",
"server": "9e87348d.9c1c48",
"version": 7,
"debugenabled": false,
"action": "script.goodnight_on_first_floor",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [],
"labelId": [],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"blockInputOverrides": false,
"domain": "script",
"service": "goodnight_on_first_floor",
"x": 320,
"y": 460,
"wires": [
[]
]
},
{
"id": "6a37c598ccfec0c7",
"type": "google-home",