diff --git a/flows.json b/flows.json index ccdea45..105242e 100644 --- a/flows.json +++ b/flows.json @@ -1,11 +1,4 @@ [ - { - "id": "a9edb9da.ccb6d", - "type": "tab", - "label": "Motion detection", - "disabled": true, - "info": "" - }, { "id": "bbf25964.5edb38", "type": "tab", @@ -1693,1145 +1686,6 @@ "x": 520, "y": 100 }, - { - "id": "f3a37054.39c5e", - "type": "server-state-changed", - "z": "a9edb9da.ccb6d", - "name": "Bathroom Motion", - "wires": [ - [ - "a621255c.9f3f68" - ] - ], - "server": "657c7463.48e1e4", - "version": 6, - "outputs": 1, - "exposeAsEntityConfig": "", - "entities": { - "entity": [ - "binary_sensor.bathroom_motion" - ], - "substring": [], - "regex": [] - }, - "outputInitially": true, - "stateType": "str", - "ifState": "", - "ifStateType": "str", - "ifStateOperator": "is", - "outputOnlyOnStateChange": true, - "for": "0", - "forType": "num", - "forUnits": "minutes", - "outputProperties": [ - { - "property": "payload", - "propertyType": "msg", - "value": "", - "valueType": "entityState" - }, - { - "property": "data", - "propertyType": "msg", - "value": "", - "valueType": "eventData" - }, - { - "property": "topic", - "propertyType": "msg", - "value": "", - "valueType": "triggerId" - } - ], - "x": 160, - "y": 180 - }, - { - "id": "a621255c.9f3f68", - "type": "switch", - "z": "a9edb9da.ccb6d", - "name": "On or Off", - "wires": [ - [ - "3d6da756.4dd7d8", - "2a6b709d.d09008" - ], - [ - "2a6b709d.d09008" - ] - ], - "property": "payload", - "propertyType": "msg", - "rules": [ - { - "t": "eq", - "v": "on", - "vt": "str" - }, - { - "t": "eq", - "v": "off", - "vt": "str" - } - ], - "checkall": "true", - "repair": false, - "outputs": 2, - "x": 340, - "y": 180 - }, - { - "id": "a4c3349e.8a322", - "type": "api-call-service", - "z": "a9edb9da.ccb6d", - "name": "Turn on", - "wires": [ - [] - ], - "server": "657c7463.48e1e4", - "version": 7, - "debugenabled": false, - "action": "script.{{payload}}", - "floorId": [], - "areaId": [], - "deviceId": [], - "entityId": [], - "labelId": [], - "data": "", - "dataType": "json", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "blockInputOverrides": false, - "domain": "script", - "service": "{{payload}}", - "output_location": "", - "output_location_type": "none", - "x": 1140, - "y": 160 - }, - { - "id": "53fec2fd.96730c", - "type": "api-call-service", - "z": "a9edb9da.ccb6d", - "name": "Turn off", - "wires": [ - [] - ], - "server": "657c7463.48e1e4", - "version": 7, - "debugenabled": false, - "action": "light.turn_off", - "floorId": [], - "areaId": [], - "deviceId": [], - "entityId": [ - "light.bathroom" - ], - "labelId": [], - "data": "", - "dataType": "json", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "blockInputOverrides": false, - "domain": "light", - "service": "turn_off", - "output_location": "", - "output_location_type": "none", - "x": 1020, - "y": 300 - }, - { - "id": "3d6da756.4dd7d8", - "type": "api-current-state", - "z": "a9edb9da.ccb6d", - "name": "Bathroom light status", - "wires": [ - [ - "251c7437.a18554" - ], - [] - ], - "server": "657c7463.48e1e4", - "version": 3, - "outputs": 2, - "halt_if": "off", - "halt_if_type": "str", - "halt_if_compare": "is", - "entity_id": "light.bathroom", - "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", - "x": 620, - "y": 60 - }, - { - "id": "2a6b709d.d09008", - "type": "stoptimer-varidelay", - "z": "a9edb9da.ccb6d", - "name": "", - "wires": [ - [ - "d550e021.fe23a" - ], - [], - [] - ], - "duration": "120", - "durationType": "num", - "units": "Second", - "payloadtype": "num", - "payloadval": "0", - "x": 710, - "y": 240 - }, - { - "id": "b2bc4296.7de718", - "type": "server-state-changed", - "z": "a9edb9da.ccb6d", - "name": "Hallway Motion", - "wires": [ - [ - "a15cb282.9b59a8" - ] - ], - "server": "657c7463.48e1e4", - "version": 6, - "outputs": 1, - "exposeAsEntityConfig": "", - "entities": { - "entity": [ - "binary_sensor.hallway_motion" - ], - "substring": [], - "regex": [] - }, - "outputInitially": true, - "stateType": "str", - "ifState": "", - "ifStateType": "str", - "ifStateOperator": "is", - "outputOnlyOnStateChange": true, - "for": "0", - "forType": "num", - "forUnits": "minutes", - "outputProperties": [ - { - "property": "payload", - "propertyType": "msg", - "value": "", - "valueType": "entityState" - }, - { - "property": "data", - "propertyType": "msg", - "value": "", - "valueType": "eventData" - }, - { - "property": "topic", - "propertyType": "msg", - "value": "", - "valueType": "triggerId" - } - ], - "x": 180, - "y": 460 - }, - { - "id": "a15cb282.9b59a8", - "type": "switch", - "z": "a9edb9da.ccb6d", - "name": "On or Off", - "wires": [ - [ - "e13f2dd9.12937", - "8d847d6b.3e76c8" - ], - [ - "8d847d6b.3e76c8" - ] - ], - "property": "payload", - "propertyType": "msg", - "rules": [ - { - "t": "eq", - "v": "on", - "vt": "str" - }, - { - "t": "eq", - "v": "off", - "vt": "str" - } - ], - "checkall": "true", - "repair": false, - "outputs": 2, - "x": 380, - "y": 460 - }, - { - "id": "8a2e7e1b.11471", - "type": "api-call-service", - "z": "a9edb9da.ccb6d", - "name": "Turn off", - "wires": [ - [] - ], - "server": "657c7463.48e1e4", - "version": 7, - "debugenabled": false, - "action": "light.turn_off", - "floorId": [], - "areaId": [], - "deviceId": [], - "entityId": [ - "light.hallway" - ], - "labelId": [], - "data": "", - "dataType": "json", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "blockInputOverrides": false, - "domain": "light", - "service": "turn_off", - "output_location": "", - "output_location_type": "none", - "x": 1160, - "y": 600 - }, - { - "id": "e13f2dd9.12937", - "type": "api-current-state", - "z": "a9edb9da.ccb6d", - "name": "Hallway light status", - "wires": [ - [ - "74e4cae8.021cc4" - ], - [] - ], - "server": "657c7463.48e1e4", - "version": 3, - "outputs": 2, - "halt_if": "off", - "halt_if_type": "str", - "halt_if_compare": "is", - "entity_id": "light.hallway", - "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", - "x": 610, - "y": 420 - }, - { - "id": "8d847d6b.3e76c8", - "type": "stoptimer-varidelay", - "z": "a9edb9da.ccb6d", - "name": "", - "wires": [ - [ - "84dd47fc.401908" - ], - [], - [] - ], - "duration": "120", - "durationType": "num", - "units": "Second", - "payloadtype": "num", - "payloadval": "0", - "persist": false, - "x": 670, - "y": 560 - }, - { - "id": "2a492dfb.c1d1aa", - "type": "subflow:e52c44dc.71cb5", - "z": "a9edb9da.ccb6d", - "name": "", - "wires": [ - [ - "2046a794.95dbf8" - ], - [ - "2046a794.95dbf8" - ] - ], - "env": [], - "x": 630, - "y": 160 - }, - { - "id": "251c7437.a18554", - "type": "change", - "z": "a9edb9da.ccb6d", - "name": "Day Mode", - "wires": [ - [ - "a4c3349e.8a322" - ] - ], - "rules": [ - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "lights_bathroom_default", - "tot": "str" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 870, - "y": 180 - }, - { - "id": "2046a794.95dbf8", - "type": "change", - "z": "a9edb9da.ccb6d", - "name": "NIght Mode", - "wires": [ - [ - "a4c3349e.8a322" - ] - ], - "rules": [ - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "lights_bathroom_night", - "tot": "str" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 870, - "y": 140 - }, - { - "id": "f75b8e7d.5a41", - "type": "api-call-service", - "z": "a9edb9da.ccb6d", - "name": "Turn on", - "wires": [ - [] - ], - "server": "657c7463.48e1e4", - "version": 7, - "debugenabled": false, - "action": "script.{{payload}}", - "floorId": [], - "areaId": [], - "deviceId": [], - "entityId": [], - "labelId": [], - "data": "", - "dataType": "json", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "blockInputOverrides": false, - "domain": "script", - "service": "{{payload}}", - "output_location": "", - "output_location_type": "none", - "x": 1160, - "y": 500 - }, - { - "id": "2ec0419c.2b47de", - "type": "subflow:e52c44dc.71cb5", - "z": "a9edb9da.ccb6d", - "name": "", - "wires": [ - [ - "75d95034.3eedb8" - ], - [ - "75d95034.3eedb8" - ] - ], - "env": [], - "x": 650, - "y": 500 - }, - { - "id": "74e4cae8.021cc4", - "type": "change", - "z": "a9edb9da.ccb6d", - "name": "Day Mode", - "wires": [ - [ - "f75b8e7d.5a41" - ] - ], - "rules": [ - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "lights_hallway_default", - "tot": "str" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 890, - "y": 520 - }, - { - "id": "75d95034.3eedb8", - "type": "change", - "z": "a9edb9da.ccb6d", - "name": "NIght Mode", - "wires": [ - [ - "f75b8e7d.5a41" - ] - ], - "rules": [ - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "lights_hallway_night", - "tot": "str" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 890, - "y": 480 - }, - { - "id": "d81ec1ce.a79708", - "type": "server-state-changed", - "z": "a9edb9da.ccb6d", - "name": "Bathroom Motion", - "wires": [ - [ - "871cbf67.15da1" - ], - [] - ], - "server": "657c7463.48e1e4", - "version": 6, - "outputs": 2, - "exposeAsEntityConfig": "", - "entities": { - "entity": [ - "binary_sensor.bathroom_motion" - ], - "substring": [], - "regex": [] - }, - "outputInitially": true, - "stateType": "str", - "ifState": "on", - "ifStateType": "str", - "ifStateOperator": "is", - "outputOnlyOnStateChange": true, - "for": "", - "forType": "num", - "forUnits": "minutes", - "ignorePrevStateNull": false, - "ignorePrevStateUnknown": false, - "ignorePrevStateUnavailable": false, - "ignoreCurrentStateUnknown": false, - "ignoreCurrentStateUnavailable": false, - "outputProperties": [ - { - "property": "payload", - "propertyType": "msg", - "value": "", - "valueType": "entityState" - }, - { - "property": "data", - "propertyType": "msg", - "value": "", - "valueType": "eventData" - }, - { - "property": "topic", - "propertyType": "msg", - "value": "", - "valueType": "triggerId" - } - ], - "x": 180, - "y": 740 - }, - { - "id": "4f7b5988.be4f98", - "type": "server-state-changed", - "z": "a9edb9da.ccb6d", - "name": "Hallway Motion", - "wires": [ - [ - "968bedf.e30a31" - ], - [] - ], - "server": "657c7463.48e1e4", - "version": 6, - "outputs": 2, - "exposeAsEntityConfig": "", - "entities": { - "entity": [ - "binary_sensor.hallway_motion" - ], - "substring": [], - "regex": [] - }, - "outputInitially": true, - "stateType": "str", - "ifState": "on", - "ifStateType": "str", - "ifStateOperator": "is", - "outputOnlyOnStateChange": true, - "for": "", - "forType": "num", - "forUnits": "minutes", - "ignorePrevStateNull": false, - "ignorePrevStateUnknown": false, - "ignorePrevStateUnavailable": false, - "ignoreCurrentStateUnknown": false, - "ignoreCurrentStateUnavailable": false, - "outputProperties": [ - { - "property": "payload", - "propertyType": "msg", - "value": "", - "valueType": "entityState" - }, - { - "property": "data", - "propertyType": "msg", - "value": "", - "valueType": "eventData" - }, - { - "property": "topic", - "propertyType": "msg", - "value": "", - "valueType": "triggerId" - } - ], - "x": 180, - "y": 800 - }, - { - "id": "b0a84917.d9a89", - "type": "server-state-changed", - "z": "a9edb9da.ccb6d", - "name": "Livingroom Motion", - "wires": [ - [ - "d614641a.552438" - ], - [] - ], - "server": "657c7463.48e1e4", - "version": 6, - "outputs": 2, - "exposeAsEntityConfig": "", - "entities": { - "entity": [ - "binary_sensor.livingroom_motion" - ], - "substring": [], - "regex": [] - }, - "outputInitially": true, - "stateType": "str", - "ifState": "on", - "ifStateType": "str", - "ifStateOperator": "is", - "outputOnlyOnStateChange": true, - "for": "", - "forType": "num", - "forUnits": "minutes", - "ignorePrevStateNull": false, - "ignorePrevStateUnknown": false, - "ignorePrevStateUnavailable": false, - "ignoreCurrentStateUnknown": false, - "ignoreCurrentStateUnavailable": false, - "outputProperties": [ - { - "property": "payload", - "propertyType": "msg", - "value": "", - "valueType": "entityState" - }, - { - "property": "data", - "propertyType": "msg", - "value": "", - "valueType": "eventData" - }, - { - "property": "topic", - "propertyType": "msg", - "value": "", - "valueType": "triggerId" - } - ], - "x": 190, - "y": 860 - }, - { - "id": "871cbf67.15da1", - "type": "change", - "z": "a9edb9da.ccb6d", - "name": "Set Bathroom", - "wires": [ - [ - "7d3df8ac.4610c", - "bce32dc1.85221" - ] - ], - "rules": [ - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "bathroom", - "tot": "str" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 400, - "y": 740 - }, - { - "id": "968bedf.e30a31", - "type": "change", - "z": "a9edb9da.ccb6d", - "name": "Set Hallway", - "wires": [ - [ - "7d3df8ac.4610c", - "bce32dc1.85221" - ] - ], - "rules": [ - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "hallway", - "tot": "str" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 390, - "y": 800 - }, - { - "id": "d614641a.552438", - "type": "change", - "z": "a9edb9da.ccb6d", - "name": "Set Livingroom", - "wires": [ - [ - "7d3df8ac.4610c", - "bce32dc1.85221" - ] - ], - "rules": [ - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "livingroom", - "tot": "str" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 400, - "y": 860 - }, - { - "id": "7d3df8ac.4610c", - "type": "api-call-service", - "z": "a9edb9da.ccb6d", - "name": "Update last motion to value", - "wires": [ - [] - ], - "server": "657c7463.48e1e4", - "version": 7, - "debugenabled": true, - "action": "input_select.select_option", - "floorId": [], - "areaId": [], - "deviceId": [], - "entityId": [ - "input_select.last_motion" - ], - "labelId": [], - "data": "{\"option\":\"{{payload}}\"}", - "dataType": "json", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "blockInputOverrides": false, - "domain": "input_select", - "service": "select_option", - "output_location": "", - "output_location_type": "none", - "x": 770, - "y": 820 - }, - { - "id": "c59f167c.f20e", - "type": "api-call-service", - "z": "a9edb9da.ccb6d", - "name": "Notify via HA", - "wires": [ - [] - ], - "server": "657c7463.48e1e4", - "version": 7, - "debugenabled": false, - "action": "notify.gotify_ha", - "floorId": [], - "areaId": [], - "deviceId": [], - "entityId": [], - "labelId": [], - "data": "{\"title\":\"Info\",\"message\":\"{{{payload}}}\"}", - "dataType": "json", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "blockInputOverrides": false, - "domain": "notify", - "service": "gotify_ha", - "output_location": "", - "output_location_type": "none", - "x": 1010, - "y": 940 - }, - { - "id": "bce32dc1.85221", - "type": "template", - "z": "a9edb9da.ccb6d", - "name": "Motion detected in...", - "wires": [ - [] - ], - "field": "payload", - "fieldType": "msg", - "format": "handlebars", - "syntax": "mustache", - "template": "Motion detected in {{payload}}.", - "output": "str", - "x": 720, - "y": 940 - }, - { - "id": "7529dee.0a6322", - "type": "comment", - "z": "a9edb9da.ccb6d", - "name": "Enable notifications when we have out of home detection", - "wires": [], - "info": "", - "x": 830, - "y": 900 - }, - { - "id": "7b42fe61.f5b758", - "type": "comment", - "z": "a9edb9da.ccb6d", - "name": "Set last motion entity", - "wires": [], - "info": "", - "x": 190, - "y": 700 - }, - { - "id": "d550e021.fe23a", - "type": "api-current-state", - "z": "a9edb9da.ccb6d", - "name": "Still in bathroom?", - "wires": [ - [ - "2a6b709d.d09008" - ], - [ - "53fec2fd.96730c" - ] - ], - "server": "657c7463.48e1e4", - "version": 3, - "outputs": 2, - "halt_if": "bathroom", - "halt_if_type": "str", - "halt_if_compare": "is", - "entity_id": "input_select.last_motion", - "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", - "x": 710, - "y": 320 - }, - { - "id": "3efd032.0055a7c", - "type": "subflow:e52c44dc.71cb5", - "z": "a9edb9da.ccb6d", - "name": "", - "wires": [ - [ - "7c0d40bf.1ee4c" - ], - [ - "7c0d40bf.1ee4c" - ] - ], - "env": [], - "x": 550, - "y": 1100 - }, - { - "id": "a3eba9b6.df5ca8", - "type": "inject", - "z": "a9edb9da.ccb6d", - "name": "", - "wires": [ - [ - "3efd032.0055a7c" - ] - ], - "repeat": "", - "crontab": "", - "once": false, - "onceDelay": 0.1, - "topic": "", - "payload": "", - "payloadType": "date", - "x": 320, - "y": 1080 - }, - { - "id": "7c0d40bf.1ee4c", - "type": "debug", - "z": "a9edb9da.ccb6d", - "name": "", - "wires": [], - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "false", - "x": 860, - "y": 1100 - }, - { - "id": "fc251c5a.cc6918", - "type": "server-state-changed", - "z": "a9edb9da.ccb6d", - "name": "Last motion room updated", - "wires": [ - [ - "e3ecc53a.1c89e8" - ] - ], - "server": "657c7463.48e1e4", - "version": 6, - "outputs": 1, - "exposeAsEntityConfig": "", - "entities": { - "entity": [ - "input_select.last_motion" - ], - "substring": [], - "regex": [] - }, - "outputInitially": true, - "stateType": "str", - "ifState": "", - "ifStateType": "str", - "ifStateOperator": "is", - "outputOnlyOnStateChange": true, - "for": "", - "forType": "num", - "forUnits": "minutes", - "ignorePrevStateNull": false, - "ignorePrevStateUnknown": false, - "ignorePrevStateUnavailable": false, - "ignoreCurrentStateUnknown": false, - "ignoreCurrentStateUnavailable": false, - "outputProperties": [ - { - "property": "payload", - "propertyType": "msg", - "value": "", - "valueType": "entityState" - }, - { - "property": "data", - "propertyType": "msg", - "value": "", - "valueType": "eventData" - }, - { - "property": "topic", - "propertyType": "msg", - "value": "", - "valueType": "triggerId" - } - ], - "x": 210, - "y": 1000 - }, - { - "id": "e3ecc53a.1c89e8", - "type": "template", - "z": "a9edb9da.ccb6d", - "name": "Last motion variable set to...", - "wires": [ - [ - "c59f167c.f20e" - ] - ], - "field": "payload", - "fieldType": "msg", - "format": "handlebars", - "syntax": "mustache", - "template": "Last motion variable set to: {{payload}}.", - "output": "str", - "x": 520, - "y": 1000 - }, - { - "id": "84dd47fc.401908", - "type": "api-current-state", - "z": "a9edb9da.ccb6d", - "name": "Still in Hallway?", - "wires": [ - [ - "8d847d6b.3e76c8" - ], - [ - "8a2e7e1b.11471" - ] - ], - "server": "657c7463.48e1e4", - "version": 3, - "outputs": 2, - "halt_if": "hallway", - "halt_if_type": "str", - "halt_if_compare": "is", - "entity_id": "input_select.last_motion", - "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", - "x": 660, - "y": 640 - }, { "id": "6240870c.31fd5", "type": "server-state-changed", @@ -22722,5 +21576,1215 @@ "output_location_type": "none", "x": 660, "y": 460 + }, + { + "type": "tab", + "label": "Motion detection", + "id": "a9edb9da.ccb6d" + }, + { + "id": "f3a37054.39c5e", + "type": "server-state-changed", + "z": "a9edb9da.ccb6d", + "name": "Bathroom Motion", + "wires": [ + [ + "a621255c.9f3f68" + ] + ], + "server": "657c7463.48e1e4", + "version": 6, + "outputs": 1, + "exposeAsEntityConfig": "", + "entities": { + "entity": [ + "binary_sensor.bathroom_motion" + ], + "substring": [], + "regex": [] + }, + "outputInitially": true, + "stateType": "str", + "ifState": "", + "ifStateType": "str", + "ifStateOperator": "is", + "outputOnlyOnStateChange": true, + "for": "0", + "forType": "num", + "forUnits": "minutes", + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "", + "valueType": "entityState" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "eventData" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + } + ], + "x": 160, + "y": 180 + }, + { + "id": "a621255c.9f3f68", + "type": "switch", + "z": "a9edb9da.ccb6d", + "name": "On or Off", + "wires": [ + [ + "3d6da756.4dd7d8", + "2a6b709d.d09008" + ], + [ + "2a6b709d.d09008" + ] + ], + "property": "payload", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "on", + "vt": "str" + }, + { + "t": "eq", + "v": "off", + "vt": "str" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 340, + "y": 180 + }, + { + "id": "a4c3349e.8a322", + "type": "api-call-service", + "z": "a9edb9da.ccb6d", + "name": "Turn on", + "wires": [ + [] + ], + "server": "657c7463.48e1e4", + "version": 7, + "debugenabled": false, + "action": "script.{{payload}}", + "floorId": [], + "areaId": [], + "deviceId": [], + "entityId": [], + "labelId": [], + "data": "", + "dataType": "json", + "mergeContext": "", + "mustacheAltTags": false, + "outputProperties": [], + "queue": "none", + "blockInputOverrides": false, + "domain": "script", + "service": "{{payload}}", + "output_location": "", + "output_location_type": "none", + "x": 1140, + "y": 160 + }, + { + "id": "53fec2fd.96730c", + "type": "api-call-service", + "z": "a9edb9da.ccb6d", + "name": "Turn off", + "wires": [ + [] + ], + "server": "657c7463.48e1e4", + "version": 7, + "debugenabled": false, + "action": "light.turn_off", + "floorId": [], + "areaId": [], + "deviceId": [], + "entityId": [ + "light.bathroom" + ], + "labelId": [], + "data": "", + "dataType": "json", + "mergeContext": "", + "mustacheAltTags": false, + "outputProperties": [], + "queue": "none", + "blockInputOverrides": false, + "domain": "light", + "service": "turn_off", + "output_location": "", + "output_location_type": "none", + "x": 1020, + "y": 300 + }, + { + "id": "3d6da756.4dd7d8", + "type": "api-current-state", + "z": "a9edb9da.ccb6d", + "name": "Bathroom light status", + "wires": [ + [ + "251c7437.a18554" + ], + [] + ], + "server": "657c7463.48e1e4", + "version": 3, + "outputs": 2, + "halt_if": "off", + "halt_if_type": "str", + "halt_if_compare": "is", + "entity_id": "light.bathroom", + "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", + "x": 620, + "y": 60 + }, + { + "id": "2a6b709d.d09008", + "type": "stoptimer-varidelay", + "z": "a9edb9da.ccb6d", + "name": "", + "wires": [ + [ + "d550e021.fe23a" + ], + [], + [] + ], + "duration": "120", + "durationType": "num", + "units": "Second", + "payloadtype": "num", + "payloadval": "0", + "x": 710, + "y": 240 + }, + { + "id": "b2bc4296.7de718", + "type": "server-state-changed", + "z": "a9edb9da.ccb6d", + "name": "Hallway Motion", + "wires": [ + [ + "a15cb282.9b59a8" + ] + ], + "server": "657c7463.48e1e4", + "version": 6, + "outputs": 1, + "exposeAsEntityConfig": "", + "entities": { + "entity": [ + "binary_sensor.hallway_motion" + ], + "substring": [], + "regex": [] + }, + "outputInitially": true, + "stateType": "str", + "ifState": "", + "ifStateType": "str", + "ifStateOperator": "is", + "outputOnlyOnStateChange": true, + "for": "0", + "forType": "num", + "forUnits": "minutes", + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "", + "valueType": "entityState" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "eventData" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + } + ], + "x": 180, + "y": 460 + }, + { + "id": "a15cb282.9b59a8", + "type": "switch", + "z": "a9edb9da.ccb6d", + "name": "On or Off", + "wires": [ + [ + "e13f2dd9.12937", + "8d847d6b.3e76c8" + ], + [ + "8d847d6b.3e76c8" + ] + ], + "property": "payload", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "on", + "vt": "str" + }, + { + "t": "eq", + "v": "off", + "vt": "str" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 380, + "y": 460 + }, + { + "id": "8a2e7e1b.11471", + "type": "api-call-service", + "z": "a9edb9da.ccb6d", + "name": "Turn off", + "wires": [ + [] + ], + "server": "657c7463.48e1e4", + "version": 7, + "debugenabled": false, + "action": "light.turn_off", + "floorId": [], + "areaId": [], + "deviceId": [], + "entityId": [ + "light.hallway" + ], + "labelId": [], + "data": "", + "dataType": "json", + "mergeContext": "", + "mustacheAltTags": false, + "outputProperties": [], + "queue": "none", + "blockInputOverrides": false, + "domain": "light", + "service": "turn_off", + "output_location": "", + "output_location_type": "none", + "x": 1160, + "y": 600 + }, + { + "id": "e13f2dd9.12937", + "type": "api-current-state", + "z": "a9edb9da.ccb6d", + "name": "Hallway light status", + "wires": [ + [ + "74e4cae8.021cc4" + ], + [] + ], + "server": "657c7463.48e1e4", + "version": 3, + "outputs": 2, + "halt_if": "off", + "halt_if_type": "str", + "halt_if_compare": "is", + "entity_id": "light.hallway", + "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", + "x": 610, + "y": 420 + }, + { + "id": "8d847d6b.3e76c8", + "type": "stoptimer-varidelay", + "z": "a9edb9da.ccb6d", + "name": "", + "wires": [ + [ + "84dd47fc.401908" + ], + [], + [] + ], + "duration": "120", + "durationType": "num", + "units": "Second", + "payloadtype": "num", + "payloadval": "0", + "persist": false, + "x": 670, + "y": 560 + }, + { + "id": "2a492dfb.c1d1aa", + "type": "subflow:e52c44dc.71cb5", + "z": "a9edb9da.ccb6d", + "name": "", + "wires": [ + [ + "2046a794.95dbf8" + ], + [ + "2046a794.95dbf8" + ] + ], + "env": [], + "x": 630, + "y": 160 + }, + { + "id": "251c7437.a18554", + "type": "change", + "z": "a9edb9da.ccb6d", + "name": "Day Mode", + "wires": [ + [ + "a4c3349e.8a322" + ] + ], + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "lights_bathroom_default", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 870, + "y": 180 + }, + { + "id": "2046a794.95dbf8", + "type": "change", + "z": "a9edb9da.ccb6d", + "name": "NIght Mode", + "wires": [ + [ + "a4c3349e.8a322" + ] + ], + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "lights_bathroom_night", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 870, + "y": 140 + }, + { + "id": "f75b8e7d.5a41", + "type": "api-call-service", + "z": "a9edb9da.ccb6d", + "name": "Turn on", + "wires": [ + [] + ], + "server": "657c7463.48e1e4", + "version": 7, + "debugenabled": false, + "action": "script.{{payload}}", + "floorId": [], + "areaId": [], + "deviceId": [], + "entityId": [], + "labelId": [], + "data": "", + "dataType": "json", + "mergeContext": "", + "mustacheAltTags": false, + "outputProperties": [], + "queue": "none", + "blockInputOverrides": false, + "domain": "script", + "service": "{{payload}}", + "output_location": "", + "output_location_type": "none", + "x": 1160, + "y": 500 + }, + { + "id": "2ec0419c.2b47de", + "type": "subflow:e52c44dc.71cb5", + "z": "a9edb9da.ccb6d", + "name": "", + "wires": [ + [ + "75d95034.3eedb8" + ], + [ + "75d95034.3eedb8" + ] + ], + "env": [], + "x": 650, + "y": 500 + }, + { + "id": "74e4cae8.021cc4", + "type": "change", + "z": "a9edb9da.ccb6d", + "name": "Day Mode", + "wires": [ + [ + "f75b8e7d.5a41" + ] + ], + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "lights_hallway_default", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 890, + "y": 520 + }, + { + "id": "75d95034.3eedb8", + "type": "change", + "z": "a9edb9da.ccb6d", + "name": "NIght Mode", + "wires": [ + [ + "f75b8e7d.5a41" + ] + ], + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "lights_hallway_night", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 890, + "y": 480 + }, + { + "id": "d81ec1ce.a79708", + "type": "server-state-changed", + "z": "a9edb9da.ccb6d", + "name": "Bathroom Motion", + "wires": [ + [ + "871cbf67.15da1" + ], + [] + ], + "server": "657c7463.48e1e4", + "version": 6, + "outputs": 2, + "exposeAsEntityConfig": "", + "entities": { + "entity": [ + "binary_sensor.bathroom_motion" + ], + "substring": [], + "regex": [] + }, + "outputInitially": true, + "stateType": "str", + "ifState": "on", + "ifStateType": "str", + "ifStateOperator": "is", + "outputOnlyOnStateChange": true, + "for": "", + "forType": "num", + "forUnits": "minutes", + "ignorePrevStateNull": false, + "ignorePrevStateUnknown": false, + "ignorePrevStateUnavailable": false, + "ignoreCurrentStateUnknown": false, + "ignoreCurrentStateUnavailable": false, + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "", + "valueType": "entityState" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "eventData" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + } + ], + "x": 180, + "y": 740 + }, + { + "id": "4f7b5988.be4f98", + "type": "server-state-changed", + "z": "a9edb9da.ccb6d", + "name": "Hallway Motion", + "wires": [ + [ + "968bedf.e30a31" + ], + [] + ], + "server": "657c7463.48e1e4", + "version": 6, + "outputs": 2, + "exposeAsEntityConfig": "", + "entities": { + "entity": [ + "binary_sensor.hallway_motion" + ], + "substring": [], + "regex": [] + }, + "outputInitially": true, + "stateType": "str", + "ifState": "on", + "ifStateType": "str", + "ifStateOperator": "is", + "outputOnlyOnStateChange": true, + "for": "", + "forType": "num", + "forUnits": "minutes", + "ignorePrevStateNull": false, + "ignorePrevStateUnknown": false, + "ignorePrevStateUnavailable": false, + "ignoreCurrentStateUnknown": false, + "ignoreCurrentStateUnavailable": false, + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "", + "valueType": "entityState" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "eventData" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + } + ], + "x": 180, + "y": 800 + }, + { + "id": "b0a84917.d9a89", + "type": "server-state-changed", + "z": "a9edb9da.ccb6d", + "name": "Livingroom Motion", + "wires": [ + [ + "d614641a.552438" + ], + [] + ], + "server": "657c7463.48e1e4", + "version": 6, + "outputs": 2, + "exposeAsEntityConfig": "", + "entities": { + "entity": [ + "binary_sensor.livingroom_motion" + ], + "substring": [], + "regex": [] + }, + "outputInitially": true, + "stateType": "str", + "ifState": "on", + "ifStateType": "str", + "ifStateOperator": "is", + "outputOnlyOnStateChange": true, + "for": "", + "forType": "num", + "forUnits": "minutes", + "ignorePrevStateNull": false, + "ignorePrevStateUnknown": false, + "ignorePrevStateUnavailable": false, + "ignoreCurrentStateUnknown": false, + "ignoreCurrentStateUnavailable": false, + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "", + "valueType": "entityState" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "eventData" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + } + ], + "x": 190, + "y": 860 + }, + { + "id": "871cbf67.15da1", + "type": "change", + "z": "a9edb9da.ccb6d", + "name": "Set Bathroom", + "wires": [ + [ + "7d3df8ac.4610c", + "bce32dc1.85221" + ] + ], + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "bathroom", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 400, + "y": 740 + }, + { + "id": "968bedf.e30a31", + "type": "change", + "z": "a9edb9da.ccb6d", + "name": "Set Hallway", + "wires": [ + [ + "7d3df8ac.4610c", + "bce32dc1.85221" + ] + ], + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "hallway", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 390, + "y": 800 + }, + { + "id": "d614641a.552438", + "type": "change", + "z": "a9edb9da.ccb6d", + "name": "Set Livingroom", + "wires": [ + [ + "7d3df8ac.4610c", + "bce32dc1.85221" + ] + ], + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "livingroom", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 400, + "y": 860 + }, + { + "id": "7d3df8ac.4610c", + "type": "api-call-service", + "z": "a9edb9da.ccb6d", + "name": "Update last motion to value", + "wires": [ + [] + ], + "server": "657c7463.48e1e4", + "version": 7, + "debugenabled": true, + "action": "input_select.select_option", + "floorId": [], + "areaId": [], + "deviceId": [], + "entityId": [ + "input_select.last_motion" + ], + "labelId": [], + "data": "{\"option\":\"{{payload}}\"}", + "dataType": "json", + "mergeContext": "", + "mustacheAltTags": false, + "outputProperties": [], + "queue": "none", + "blockInputOverrides": false, + "domain": "input_select", + "service": "select_option", + "output_location": "", + "output_location_type": "none", + "x": 770, + "y": 820 + }, + { + "id": "c59f167c.f20e", + "type": "api-call-service", + "z": "a9edb9da.ccb6d", + "name": "Notify via HA", + "wires": [ + [] + ], + "server": "657c7463.48e1e4", + "version": 7, + "debugenabled": false, + "action": "notify.gotify_ha", + "floorId": [], + "areaId": [], + "deviceId": [], + "entityId": [], + "labelId": [], + "data": "{\"title\":\"Info\",\"message\":\"{{{payload}}}\"}", + "dataType": "json", + "mergeContext": "", + "mustacheAltTags": false, + "outputProperties": [], + "queue": "none", + "blockInputOverrides": false, + "domain": "notify", + "service": "gotify_ha", + "output_location": "", + "output_location_type": "none", + "x": 1010, + "y": 940 + }, + { + "id": "bce32dc1.85221", + "type": "template", + "z": "a9edb9da.ccb6d", + "name": "Motion detected in...", + "wires": [ + [] + ], + "field": "payload", + "fieldType": "msg", + "format": "handlebars", + "syntax": "mustache", + "template": "Motion detected in {{payload}}.", + "output": "str", + "x": 720, + "y": 940 + }, + { + "id": "7529dee.0a6322", + "type": "comment", + "z": "a9edb9da.ccb6d", + "name": "Enable notifications when we have out of home detection", + "wires": [], + "info": "", + "x": 830, + "y": 900 + }, + { + "id": "7b42fe61.f5b758", + "type": "comment", + "z": "a9edb9da.ccb6d", + "name": "Set last motion entity", + "wires": [], + "info": "", + "x": 190, + "y": 700 + }, + { + "id": "d550e021.fe23a", + "type": "api-current-state", + "z": "a9edb9da.ccb6d", + "name": "Still in bathroom?", + "wires": [ + [ + "2a6b709d.d09008" + ], + [ + "53fec2fd.96730c" + ] + ], + "server": "657c7463.48e1e4", + "version": 3, + "outputs": 2, + "halt_if": "bathroom", + "halt_if_type": "str", + "halt_if_compare": "is", + "entity_id": "input_select.last_motion", + "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", + "x": 710, + "y": 320 + }, + { + "id": "3efd032.0055a7c", + "type": "subflow:e52c44dc.71cb5", + "z": "a9edb9da.ccb6d", + "name": "", + "wires": [ + [ + "7c0d40bf.1ee4c" + ], + [ + "7c0d40bf.1ee4c" + ] + ], + "env": [], + "x": 550, + "y": 1100 + }, + { + "id": "a3eba9b6.df5ca8", + "type": "inject", + "z": "a9edb9da.ccb6d", + "name": "", + "wires": [ + [ + "3efd032.0055a7c" + ] + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 320, + "y": 1080 + }, + { + "id": "7c0d40bf.1ee4c", + "type": "debug", + "z": "a9edb9da.ccb6d", + "name": "", + "wires": [], + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "x": 860, + "y": 1100 + }, + { + "id": "fc251c5a.cc6918", + "type": "server-state-changed", + "z": "a9edb9da.ccb6d", + "name": "Last motion room updated", + "wires": [ + [ + "e3ecc53a.1c89e8" + ] + ], + "server": "657c7463.48e1e4", + "version": 6, + "outputs": 1, + "exposeAsEntityConfig": "", + "entities": { + "entity": [ + "input_select.last_motion" + ], + "substring": [], + "regex": [] + }, + "outputInitially": true, + "stateType": "str", + "ifState": "", + "ifStateType": "str", + "ifStateOperator": "is", + "outputOnlyOnStateChange": true, + "for": "", + "forType": "num", + "forUnits": "minutes", + "ignorePrevStateNull": false, + "ignorePrevStateUnknown": false, + "ignorePrevStateUnavailable": false, + "ignoreCurrentStateUnknown": false, + "ignoreCurrentStateUnavailable": false, + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "", + "valueType": "entityState" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "eventData" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + } + ], + "x": 210, + "y": 1000 + }, + { + "id": "e3ecc53a.1c89e8", + "type": "template", + "z": "a9edb9da.ccb6d", + "name": "Last motion variable set to...", + "wires": [ + [ + "c59f167c.f20e" + ] + ], + "field": "payload", + "fieldType": "msg", + "format": "handlebars", + "syntax": "mustache", + "template": "Last motion variable set to: {{payload}}.", + "output": "str", + "x": 520, + "y": 1000 + }, + { + "id": "84dd47fc.401908", + "type": "api-current-state", + "z": "a9edb9da.ccb6d", + "name": "Still in Hallway?", + "wires": [ + [ + "8d847d6b.3e76c8" + ], + [ + "8a2e7e1b.11471" + ] + ], + "server": "657c7463.48e1e4", + "version": 3, + "outputs": 2, + "halt_if": "hallway", + "halt_if_type": "str", + "halt_if_compare": "is", + "entity_id": "input_select.last_motion", + "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", + "x": 660, + "y": 640 + }, + { + "id": "p2catch_mot", + "type": "catch", + "z": "a9edb9da.ccb6d", + "name": "Catch all errors", + "wires": [ + [ + "p2fmt_mot" + ] + ], + "scope": null, + "uncaught": false, + "x": 160, + "y": 1300 + }, + { + "id": "p2fmt_mot", + "type": "function", + "z": "a9edb9da.ccb6d", + "name": "Format error", + "wires": [ + [ + "p2ntfy_mot" + ] + ], + "func": "const err = (msg.error && msg.error.message) ? msg.error.message : String(msg.payload || 'Unknown error');\nconst src = (msg.error && msg.error.source) ? (msg.error.source.name || msg.error.source.id || '') : '';\nmsg.payload = JSON.stringify({\n title: 'Node-RED Error: Motion detection',\n message: err + (src ? '\\n\\nNode: ' + src : '')\n});\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "timeout": "", + "x": 400, + "y": 1300 + }, + { + "id": "p2ntfy_mot", + "type": "api-call-service", + "z": "a9edb9da.ccb6d", + "name": "Notify error", + "wires": [ + [] + ], + "server": "657c7463.48e1e4", + "version": 7, + "debugenabled": false, + "action": "notify.gotify_ha", + "floorId": [], + "areaId": [], + "deviceId": [], + "entityId": [], + "labelId": [], + "data": "{{{payload}}}", + "dataType": "json", + "mergeContext": "", + "mustacheAltTags": false, + "outputProperties": [], + "queue": "none", + "blockInputOverrides": false, + "domain": "notify", + "service": "gotify_ha", + "output_location": "", + "output_location_type": "none", + "x": 660, + "y": 1300 } ] \ No newline at end of file