Rework front porch light flow with function nodes

This commit is contained in:
2023-03-27 17:00:04 -04:00
parent 1be81352bc
commit a418df78b2

View File

@ -685,7 +685,9 @@
"37f1c11c59a6ce16"
],
"x": 94,
"y": 339
"y": 339,
"w": 1872,
"h": 622
},
{
"id": "39a7ac02f2727f1d",
@ -732,9 +734,7 @@
"1c98de289e42377f"
],
"x": 14,
"y": 719,
"w": 1292,
"h": 642
"y": 719
},
{
"id": "e065b1ed4938b477",
@ -806,9 +806,7 @@
"a3ef2faca9922113"
],
"x": 14,
"y": 19,
"w": 2112,
"h": 682
"y": 19
},
{
"id": "5c50443a84910fb7",
@ -844,7 +842,9 @@
"486bca43ddc48fb8"
],
"x": 34,
"y": 159
"y": 159,
"w": 1072,
"h": 482
},
{
"id": "477e752fcd2e2a19",
@ -1070,7 +1070,9 @@
"1e1891c23a6e7e64"
],
"x": 34,
"y": 239
"y": 239,
"w": 1132,
"h": 382
},
{
"id": "1ca205a84922c8c2",
@ -1142,34 +1144,30 @@
"nodes": [
"091390f43bfeddf5",
"7a7229eb69c9b1a3",
"edef3ad58f6e9bbd",
"780ad4c1a1d5204b",
"51237623ed73ba98",
"f34816b23181f21e",
"aaac8068997af1a5",
"de4f1b15ce906809",
"bd75b077a1c76fce",
"dda150ba32752234",
"b69eeb738bbd4bdb",
"cfdcc7c9c168dc17",
"8f3c66f06ed3f7b2",
"16029ccf061bdd10",
"d2751bc2cfc5af8f",
"435280acadb9f364",
"ec5937bc60874009",
"defcae57f9916394",
"dfa6bff034d7d522",
"94faa23771cc9cd6",
"459433738b64d14d",
"cfd6c59d35ffa1dc",
"a2ec35a79d79bf2f",
"9a8c39dc1a0c20e6",
"3e6caa91031ab102",
"8c29a2e1a06c5524",
"c7a8df4ebeb3b5c5"
"c7a8df4ebeb3b5c5",
"77759257dd9c9465",
"3a5bb57569e07beb",
"76815f07ec2f3eef",
"f5fb96bf1a33b3cd"
],
"x": 54,
"y": 19
"y": 19,
"w": 1492,
"h": 282
},
{
"id": "0c81dfaed25d225c",
@ -1224,7 +1222,9 @@
"b281061a4b08d2eb"
],
"x": 14,
"y": 539
"y": 539,
"w": 612,
"h": 202
},
{
"id": "550e5b2d99316b12",
@ -1247,7 +1247,9 @@
"4829663e9913e2aa"
],
"x": 34,
"y": 639
"y": 639,
"w": 1072,
"h": 202
},
{
"id": "f519aff597ece351",
@ -1404,7 +1406,9 @@
"1a278235669d49ac"
],
"x": 34,
"y": 659
"y": 659,
"w": 952,
"h": 302
},
{
"id": "19b0e082db0643ac",
@ -6107,6 +6111,11 @@
"b2d071ca42e4a3c6",
"b8ca8a1a2655570b"
]
],
"outputLabels": [
"Basement",
"Kallen Bedroom",
"Otherwise"
]
},
{
@ -14095,11 +14104,11 @@
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 1270,
"x": 790,
"y": 120,
"wires": [
[
"dda150ba32752234"
"3a5bb57569e07beb"
]
]
},
@ -14127,132 +14136,12 @@
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 1710,
"x": 1250,
"y": 260,
"wires": [
[]
]
},
{
"id": "edef3ad58f6e9bbd",
"type": "api-current-state",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "Early Night Mode",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "binary_sensor.early_night_mode",
"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": 650,
"y": 120,
"wires": [
[
"780ad4c1a1d5204b"
],
[]
]
},
{
"id": "780ad4c1a1d5204b",
"type": "api-current-state",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "Front Porch Toggle",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_boolean.front_porch_light_on",
"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": 870,
"y": 120,
"wires": [
[
"94faa23771cc9cd6"
],
[]
]
},
{
"id": "51237623ed73ba98",
"type": "api-current-state",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "Front Porch Toggle",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_boolean.front_porch_light_on",
"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": 1090,
"y": 260,
"wires": [
[
"3e6caa91031ab102"
],
[]
]
},
{
"id": "f34816b23181f21e",
"type": "link in",
@ -14270,52 +14159,6 @@
]
]
},
{
"id": "aaac8068997af1a5",
"type": "api-current-state",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "Delivery Mode",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_boolean.delivery_mode",
"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": 1620,
"y": 60,
"wires": [
[
"de4f1b15ce906809"
],
[]
]
},
{
"id": "de4f1b15ce906809",
"type": "api-call-service",
@ -14338,7 +14181,7 @@
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1810,
"x": 1130,
"y": 60,
"wires": [
[
@ -14369,44 +14212,12 @@
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 2020,
"x": 1340,
"y": 60,
"wires": [
[]
]
},
{
"id": "dda150ba32752234",
"type": "switch",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "If Motion",
"property": "detect",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "motion",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 1440,
"y": 120,
"wires": [
[
"aaac8068997af1a5"
],
[
"d2751bc2cfc5af8f"
]
]
},
{
"id": "b69eeb738bbd4bdb",
"type": "server-state-changed",
@ -14491,46 +14302,7 @@
"459433738b64d14d"
],
[
"8f3c66f06ed3f7b2"
]
]
},
{
"id": "8f3c66f06ed3f7b2",
"type": "api-current-state",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "Delay",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_number.front_porch_motion_off_delay",
"state_type": "num",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "duration",
"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": 350,
"y": 260,
"wires": [
[
"cfd6c59d35ffa1dc"
"76815f07ec2f3eef"
]
]
},
@ -14559,11 +14331,11 @@
"y": 120,
"wires": [
[
"edef3ad58f6e9bbd",
"c7a8df4ebeb3b5c5"
"c7a8df4ebeb3b5c5",
"77759257dd9c9465"
],
[
"edef3ad58f6e9bbd"
"77759257dd9c9465"
]
]
},
@ -14589,7 +14361,7 @@
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1610,
"x": 1130,
"y": 120,
"wires": [
[]
@ -14617,7 +14389,7 @@
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1900,
"x": 1440,
"y": 200,
"wires": [
[]
@ -14645,7 +14417,7 @@
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1280,
"x": 800,
"y": 60,
"wires": [
[]
@ -14673,7 +14445,7 @@
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1710,
"x": 1250,
"y": 200,
"wires": [
[
@ -14681,61 +14453,6 @@
]
]
},
{
"id": "dfa6bff034d7d522",
"type": "function",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "Holiday Code",
"func": "var holidaymode = global.get('holidaymode')\nvar currentholiday = global.get('currentholiday')\nvar holiday = currentholiday.toLowerCase()\n\nif (holidaymode === 'on') {\n msg.holiday = holiday\n return [msg,null]\n} else {\n return [null,msg]\n}",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1500,
"y": 260,
"wires": [
[
"defcae57f9916394"
],
[
"7a7229eb69c9b1a3"
]
],
"outputLabels": [
"Holiday On",
"Holiday Off"
]
},
{
"id": "94faa23771cc9cd6",
"type": "function",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "Holiday Code",
"func": "var holidaymode = global.get('holidaymode')\nvar currentholiday = global.get('currentholiday')\nvar holiday = currentholiday.toLowerCase()\n\nif (holidaymode === 'on') {\n msg.holiday = holiday\n return [msg,null]\n} else {\n return [null,msg]\n}",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1080,
"y": 120,
"wires": [
[
"091390f43bfeddf5",
"ec5937bc60874009"
],
[
"091390f43bfeddf5"
]
],
"outputLabels": [
"Holiday On",
"Holiday Off"
]
},
{
"id": "459433738b64d14d",
"type": "api-call-service",
@ -14764,27 +14481,6 @@
[]
]
},
{
"id": "cfd6c59d35ffa1dc",
"type": "function",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "Convert to seconds",
"func": "msg.duration = msg.duration * 60\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 455,
"y": 260,
"wires": [
[
"a2ec35a79d79bf2f"
]
],
"l": false
},
{
"id": "a2ec35a79d79bf2f",
"type": "api-call-service",
@ -14807,7 +14503,7 @@
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 570,
"x": 510,
"y": 260,
"wires": [
[]
@ -14847,54 +14543,10 @@
"y": 260,
"wires": [
[
"51237623ed73ba98"
"f5fb96bf1a33b3cd"
]
]
},
{
"id": "3e6caa91031ab102",
"type": "api-current-state",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "Delivery Mode",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 2,
"halt_if": "off",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_boolean.delivery_mode",
"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": 1300,
"y": 260,
"wires": [
[
"dfa6bff034d7d522"
],
[]
],
"outputLabels": [
"Off",
"On"
]
},
{
"id": "8c29a2e1a06c5524",
"type": "server-state-changed",
@ -14943,7 +14595,7 @@
"y": 200,
"wires": [
[
"51237623ed73ba98"
"f5fb96bf1a33b3cd"
],
[]
]
@ -14970,11 +14622,343 @@
"y": 260,
"wires": [
[
"8f3c66f06ed3f7b2"
"76815f07ec2f3eef"
]
],
"l": false
},
{
"id": "77759257dd9c9465",
"type": "function",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "Check Parameters",
"func": "var states = global.get('homeassistant.homeAssistant.states')\nvar earlyNightMode = states['binary_sensor.early_night_mode'].state\nvar frontPorchToggle = states['input_boolean.front_porch_light_on'].state\nvar holidaymode = states['input_boolean.holiday_mode'].state\nvar currentholiday = states['input_select.holiday_animation'].state\nvar holiday = currentholiday.toLowerCase()\n\nif (earlyNightMode === 'on' && frontPorchToggle === 'on') {\n if (holidaymode === 'on') {\n msg.holiday = holiday\n return[msg,null]\n } else {\n return[null,msg]\n }\n} else {\n return null\n}",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 590,
"y": 120,
"wires": [
[
"ec5937bc60874009",
"091390f43bfeddf5"
],
[
"091390f43bfeddf5"
]
],
"outputLabels": [
"Holiday",
"Otherwise"
]
},
{
"id": "edef3ad58f6e9bbd",
"type": "api-current-state",
"z": "b5717a86ce55bc29",
"d": true,
"name": "Early Night Mode",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "binary_sensor.early_night_mode",
"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": 170,
"y": 440,
"wires": [
[
"780ad4c1a1d5204b"
],
[]
]
},
{
"id": "780ad4c1a1d5204b",
"type": "api-current-state",
"z": "b5717a86ce55bc29",
"d": true,
"name": "Front Porch Toggle",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_boolean.front_porch_light_on",
"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": 390,
"y": 440,
"wires": [
[
"94faa23771cc9cd6"
],
[]
]
},
{
"id": "94faa23771cc9cd6",
"type": "function",
"z": "b5717a86ce55bc29",
"d": true,
"name": "Holiday Code",
"func": "var holidaymode = global.get('holidaymode')\nvar currentholiday = global.get('currentholiday')\nvar holiday = currentholiday.toLowerCase()\n\nif (holidaymode === 'on') {\n msg.holiday = holiday\n return [msg,null]\n} else {\n return [null,msg]\n}",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 600,
"y": 440,
"wires": [
[],
[]
],
"outputLabels": [
"Holiday On",
"Holiday Off"
]
},
{
"id": "3a5bb57569e07beb",
"type": "function",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "If Motion",
"func": "var states = global.get('homeassistant.homeAssistant.states')\nvar deliveryMode = states['input_boolean.delivery_mode'].state\nvar detect = msg.detect\n\nif (detect === 'motion') {\n if (deliveryMode === 'on') {\n return[msg,null]\n } else {\n return null\n }\n} else {\n return[null,msg]\n}",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 960,
"y": 120,
"wires": [
[
"de4f1b15ce906809"
],
[
"d2751bc2cfc5af8f"
]
],
"outputLabels": [
"Motion",
"Otherwise"
]
},
{
"id": "0ee23da3fa6a6183",
"type": "comment",
"z": "b5717a86ce55bc29",
"name": "Old Check Parameters",
"info": "",
"x": 180,
"y": 380,
"wires": []
},
{
"id": "76815f07ec2f3eef",
"type": "function",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "Delay",
"func": "var states = global.get('homeassistant.homeAssistant.states')\nvar delay = states['input_number.front_porch_motion_off_delay'].state\nvar duration = delay * 60\n\nmsg.duration = duration\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 350,
"y": 260,
"wires": [
[
"a2ec35a79d79bf2f"
]
]
},
{
"id": "f5fb96bf1a33b3cd",
"type": "function",
"z": "b5717a86ce55bc29",
"g": "eeafd13be593ae69",
"name": "Shut Off",
"func": "var states = global.get('homeassistant.homeAssistant.states')\nvar frontPorchToggle = states['input_boolean.front_porch_light_on'].state\nvar deliveryMode = states['input_boolean.delivery_mode'].state\nvar holidaymode = states['input_boolean.holiday_mode'].state\nvar currentholiday = states['input_select.holiday_animation'].state\nvar holiday = currentholiday.toLowerCase()\n\nif (frontPorchToggle === 'on' && deliveryMode === 'off') {\n if (holidaymode === 'on') {\n return[msg,null]\n } else {\n return[null,msg]\n }\n} else {\n return null\n}",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1080,
"y": 260,
"wires": [
[
"defcae57f9916394"
],
[
"7a7229eb69c9b1a3"
]
],
"outputLabels": [
"Holiday",
"Otherwise"
]
},
{
"id": "51237623ed73ba98",
"type": "api-current-state",
"z": "b5717a86ce55bc29",
"d": true,
"name": "Front Porch Toggle",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_boolean.front_porch_light_on",
"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": 910,
"y": 440,
"wires": [
[
"3e6caa91031ab102"
],
[]
]
},
{
"id": "dfa6bff034d7d522",
"type": "function",
"z": "b5717a86ce55bc29",
"d": true,
"name": "Holiday Code",
"func": "var holidaymode = global.get('holidaymode')\nvar currentholiday = global.get('currentholiday')\nvar holiday = currentholiday.toLowerCase()\n\nif (holidaymode === 'on') {\n msg.holiday = holiday\n return [msg,null]\n} else {\n return [null,msg]\n}",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1320,
"y": 440,
"wires": [
[],
[]
],
"outputLabels": [
"Holiday On",
"Holiday Off"
]
},
{
"id": "3e6caa91031ab102",
"type": "api-current-state",
"z": "b5717a86ce55bc29",
"d": true,
"name": "Delivery Mode",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 2,
"halt_if": "off",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_boolean.delivery_mode",
"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": 1120,
"y": 440,
"wires": [
[
"dfa6bff034d7d522"
],
[]
],
"outputLabels": [
"Off",
"On"
]
},
{
"id": "072d53ce4582a2f9",
"type": "comment",
"z": "b5717a86ce55bc29",
"name": "Old Shut Off",
"info": "",
"x": 890,
"y": 380,
"wires": []
},
{
"id": "cd04bdb407311eb5",
"type": "ha-button",