I pretty heavily re-worked the flow to be more robust in responding to different events (esp. turning lights on/off during motion active), set the timer to start after the sensor goes to inactive, and be slightly more readable.
Summary
[
{
"id": "32054f7b.6f13c",
"type": "tab",
"label": "Flow 11",
"disabled": false,
"info": ""
},
{
"id": "cd2e24c3.24164",
"type": "state-machine",
"z": "32054f7b.6f13c",
"name": "",
"triggerProperty": "payload",
"triggerPropertyType": "msg",
"stateProperty": "payload",
"statePropertyType": "msg",
"outputStateChangeOnly": true,
"throwException": false,
"states": [
"st_switch",
"st_motion-on",
"st_motion-timer",
"st_motion-off",
"st_off",
"st_on",
"st_switch_off",
"st_switch_on"
],
"transitions": [
{
"name": "tr_off",
"from": "*",
"to": "st_off"
},
{
"name": "tr_on",
"from": "*",
"to": "st_on"
},
{
"name": "tr_motion-active",
"from": "st_off",
"to": "st_motion-on"
},
{
"name": "tr_motion-active",
"from": "st_motion-timer",
"to": "st_motion-on"
},
{
"name": "tr_motion-on",
"from": "st_motion-on",
"to": "st_motion-timer"
},
{
"name": "tr_motion-inactive",
"from": "st_motion-on",
"to": "st_motion-timer"
},
{
"name": "tr_motion-off",
"from": "st_motion-timer",
"to": "st_motion-off"
},
{
"name": "tr_switch-off",
"from": "*",
"to": "st_switch_off"
},
{
"name": "tr_switch-on",
"from": "st_motion-timer",
"to": "st_switch_on"
},
{
"name": "tr_switch-on",
"from": "st_motion-off",
"to": "st_switch_on"
},
{
"name": "tr_switch-on",
"from": "st_switch_off",
"to": "st_switch_on"
},
{
"name": "tr_switch-on",
"from": "st_off",
"to": "st_switch_on"
}
],
"x": 500,
"y": 540,
"wires": [
[
"e4bc4a4c.a41c88",
"360cbf98.e378a8",
"56259156.cacac",
"3abe544f.9780ec",
"628ae107.126778",
"159bf659.920b8a"
]
]
},
{
"id": "2e7249fe.b79626",
"type": "change",
"z": "32054f7b.6f13c",
"name": "tr_switch-on",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "tr_switch-on",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 230,
"y": 780,
"wires": [
[
"cd2e24c3.24164",
"8ad74838.a063f"
]
]
},
{
"id": "81b55db6.ac465",
"type": "change",
"z": "32054f7b.6f13c",
"name": "tr_motion-active",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "tr_motion-active",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 360,
"y": 440,
"wires": [
[
"cd2e24c3.24164",
"8ad74838.a063f"
]
]
},
{
"id": "18468b2f.edbca5",
"type": "change",
"z": "32054f7b.6f13c",
"name": "stop timer",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "stop",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 910,
"y": 480,
"wires": [
[
"c65ec7b5.1a812"
]
]
},
{
"id": "9fdf23ab.1043a8",
"type": "change",
"z": "32054f7b.6f13c",
"name": "tr_motion-off",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "tr_motion-off",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1130,
"y": 420,
"wires": [
[
"81434535.f6326"
]
]
},
{
"id": "1f3745d7.2e5fa2",
"type": "inject",
"z": "32054f7b.6f13c",
"name": "Current State",
"topic": "",
"payload": "stop",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"x": 1300,
"y": 860,
"wires": [
[
"9d1eb16.c4c095",
"a2131a41.ef7608"
]
]
},
{
"id": "e7869b10.0f8bf",
"type": "inject",
"z": "32054f7b.6f13c",
"name": "",
"topic": "",
"payload": "simulate",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 1240,
"y": 160,
"wires": [
[
"81b55db6.ac465",
"4ed301e3.bd1a78"
]
]
},
{
"id": "e4bc4a4c.a41c88",
"type": "switch",
"z": "32054f7b.6f13c",
"name": "st_motion-on",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "st_motion-on",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 720,
"y": 360,
"wires": [
[
"18468b2f.edbca5",
"1066966d.019372"
]
]
},
{
"id": "360cbf98.e378a8",
"type": "switch",
"z": "32054f7b.6f13c",
"name": "st_motion-timer",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "st_motion-timer",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 720,
"y": 420,
"wires": [
[
"c65ec7b5.1a812"
]
]
},
{
"id": "b1cbc49a.9cd008",
"type": "link in",
"z": "32054f7b.6f13c",
"name": "kitchen state machine",
"links": [
"81434535.f6326"
],
"x": 335,
"y": 500,
"wires": [
[
"cd2e24c3.24164",
"8ad74838.a063f"
]
]
},
{
"id": "81434535.f6326",
"type": "link out",
"z": "32054f7b.6f13c",
"name": "kitchen state machine",
"links": [
"b1cbc49a.9cd008"
],
"x": 1555,
"y": 420,
"wires": []
},
{
"id": "56259156.cacac",
"type": "switch",
"z": "32054f7b.6f13c",
"name": "st_switch_on",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "st_switch_on",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 710,
"y": 660,
"wires": [
[
"18468b2f.edbca5",
"9d1eb16.c4c095",
"a2131a41.ef7608"
]
]
},
{
"id": "3abe544f.9780ec",
"type": "switch",
"z": "32054f7b.6f13c",
"name": "st_motion-off",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "st_motion-off",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 720,
"y": 540,
"wires": [
[
"be1931cb.958768"
]
]
},
{
"id": "b7009f7c.1475a8",
"type": "hubitat device",
"z": "32054f7b.6f13c",
"name": "Motion Sensor",
"server": "d0c8b8e.6894848",
"deviceId": "2695",
"attribute": "motion",
"sendEvent": true,
"x": 100,
"y": 300,
"wires": [
[
"d768f4ca.32357",
"d4a8da8b.9feeb8"
]
]
},
{
"id": "8b7bf52b.866948",
"type": "hubitat device",
"z": "32054f7b.6f13c",
"name": "DR Lights",
"server": "d0c8b8e.6894848",
"deviceId": "7",
"attribute": "switch",
"sendEvent": true,
"x": 80,
"y": 660,
"wires": [
[
"7b856664.62a66"
]
]
},
{
"id": "76ef38e1.e0c138",
"type": "hubitat command",
"z": "32054f7b.6f13c",
"name": "DR Lights On",
"server": "d0c8b8e.6894848",
"deviceId": "7",
"command": "on",
"commandArgs": "",
"x": 1120,
"y": 360,
"wires": [
[
"7676191b.c2c53"
]
]
},
{
"id": "e4033469.c56598",
"type": "hubitat command",
"z": "32054f7b.6f13c",
"name": "DR Lights Off",
"server": "d0c8b8e.6894848",
"deviceId": "7",
"command": "off",
"commandArgs": "",
"x": 1120,
"y": 540,
"wires": [
[
"a27508c.116b578"
]
]
},
{
"id": "9d1eb16.c4c095",
"type": "hubitat device",
"z": "32054f7b.6f13c",
"name": "DR Lights",
"server": "d0c8b8e.6894848",
"deviceId": "7",
"attribute": "switch",
"sendEvent": false,
"x": 1480,
"y": 660,
"wires": [
[
"17dcd9bd.e783d6"
]
]
},
{
"id": "82d17be7.3b429",
"type": "hubitat command",
"z": "32054f7b.6f13c",
"name": "DR Lights Off",
"server": "d0c8b8e.6894848",
"deviceId": "7",
"command": "off",
"commandArgs": "",
"x": 1420,
"y": 40,
"wires": [
[]
]
},
{
"id": "90b4d9cc.00d748",
"type": "hubitat command",
"z": "32054f7b.6f13c",
"name": "DR Lights On",
"server": "d0c8b8e.6894848",
"deviceId": "7",
"command": "setLevel",
"commandArgs": "55",
"x": 1420,
"y": 100,
"wires": [
[]
]
},
{
"id": "82637f9c.d91bf8",
"type": "inject",
"z": "32054f7b.6f13c",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 1240,
"y": 40,
"wires": [
[
"82d17be7.3b429"
]
]
},
{
"id": "78757e7a.f06d4",
"type": "inject",
"z": "32054f7b.6f13c",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 1240,
"y": 100,
"wires": [
[
"90b4d9cc.00d748"
]
]
},
{
"id": "e64c4e31.36aaf8",
"type": "time-range-switch",
"z": "32054f7b.6f13c",
"name": "",
"lat": "",
"lon": "",
"startTime": "06:00",
"endTime": "22:00",
"startOffset": 0,
"endOffset": 0,
"x": 340,
"y": 100,
"wires": [
[
"aec70c57.f1e2d8"
],
[]
]
},
{
"id": "afbbd0dd.bb8b38",
"type": "hubitat device",
"z": "32054f7b.6f13c",
"name": "Lux - Back Entrance",
"server": "d0c8b8e.6894848",
"deviceId": "1579",
"attribute": "illuminance",
"sendEvent": true,
"x": 340,
"y": 160,
"wires": [
[
"ec312867.891898"
]
]
},
{
"id": "3b7e53e0.d21554",
"type": "change",
"z": "32054f7b.6f13c",
"name": "Lux Blocked?",
"rules": [
{
"t": "set",
"p": "lux_block",
"pt": "flow",
"to": "0",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 680,
"y": 160,
"wires": [
[
"decd31d2.ac43e"
]
]
},
{
"id": "aec70c57.f1e2d8",
"type": "switch",
"z": "32054f7b.6f13c",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "nnull"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 510,
"y": 100,
"wires": [
[
"aa9f4f85.57da7"
]
]
},
{
"id": "aa9f4f85.57da7",
"type": "change",
"z": "32054f7b.6f13c",
"name": "Time Blocked?",
"rules": [
{
"t": "set",
"p": "time_block",
"pt": "flow",
"to": "0",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 680,
"y": 100,
"wires": [
[
"a0ee8250.47b91"
]
]
},
{
"id": "ec312867.891898",
"type": "switch",
"z": "32054f7b.6f13c",
"name": "",
"property": "payload.value",
"propertyType": "msg",
"rules": [
{
"t": "lt",
"v": "100",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 510,
"y": 160,
"wires": [
[
"3b7e53e0.d21554"
]
]
},
{
"id": "d768f4ca.32357",
"type": "function",
"z": "32054f7b.6f13c",
"name": "Blocked?",
"func": "var a= flow.get('time_block')\nvar b= flow.get('lux_block')\nmsg.payload.blockValue = a+b\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 280,
"y": 300,
"wires": [
[
"1c635c36.ad33ec"
]
]
},
{
"id": "1c635c36.ad33ec",
"type": "switch",
"z": "32054f7b.6f13c",
"name": "Blocked =0",
"property": "payload.blockValue",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 450,
"y": 300,
"wires": [
[
"70024162.dae038"
]
]
},
{
"id": "4ccc06b2.f00188",
"type": "comment",
"z": "32054f7b.6f13c",
"name": "Filters",
"info": "",
"x": 70,
"y": 40,
"wires": []
},
{
"id": "1578ab31.0d2b6d",
"type": "comment",
"z": "32054f7b.6f13c",
"name": "Control the lights",
"info": "",
"x": 100,
"y": 240,
"wires": []
},
{
"id": "17dcd9bd.e783d6",
"type": "change",
"z": "32054f7b.6f13c",
"name": "Transition Name",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "\"tr_\"&payload.value",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1480,
"y": 560,
"wires": [
[
"81434535.f6326"
]
]
},
{
"id": "decd31d2.ac43e",
"type": "debug",
"z": "32054f7b.6f13c",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "( { \"Lux Block\": $flowContext('lux_block') } )",
"targetType": "jsonata",
"x": 880,
"y": 160,
"wires": []
},
{
"id": "628ae107.126778",
"type": "debug",
"z": "32054f7b.6f13c",
"name": "To State",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 700,
"y": 600,
"wires": []
},
{
"id": "70024162.dae038",
"type": "switch",
"z": "32054f7b.6f13c",
"name": "Active?",
"property": "payload.value",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "active",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 340,
"y": 380,
"wires": [
[
"81b55db6.ac465"
]
]
},
{
"id": "8ad74838.a063f",
"type": "debug",
"z": "32054f7b.6f13c",
"name": "Transition",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 520,
"y": 780,
"wires": []
},
{
"id": "c65ec7b5.1a812",
"type": "stoptimer2",
"z": "32054f7b.6f13c",
"duration": "10",
"durationType": "num",
"units": "Second",
"payloadtype": "num",
"payloadval": "0",
"name": "",
"x": 930,
"y": 420,
"wires": [
[
"9fdf23ab.1043a8"
],
[]
]
},
{
"id": "e2b82781.7af5e",
"type": "stoptimer2",
"z": "32054f7b.6f13c",
"duration": "1",
"durationType": "num",
"units": "Minute",
"payloadtype": "num",
"payloadval": "0",
"name": "pause motion detection for 1 min",
"x": 1200,
"y": 720,
"wires": [
[
"9d1eb16.c4c095"
],
[]
]
},
{
"id": "c97a4d6d.1f772",
"type": "switch",
"z": "32054f7b.6f13c",
"name": "On or Off",
"property": "payload.value",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "on",
"vt": "str"
},
{
"t": "eq",
"v": "off",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 220,
"y": 720,
"wires": [
[
"2e7249fe.b79626"
],
[
"547fa841.80388"
]
]
},
{
"id": "547fa841.80388",
"type": "change",
"z": "32054f7b.6f13c",
"name": "tr_switch-off",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "tr_switch-off",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 230,
"y": 840,
"wires": [
[
"cd2e24c3.24164",
"8ad74838.a063f"
]
]
},
{
"id": "159bf659.920b8a",
"type": "switch",
"z": "32054f7b.6f13c",
"name": "st_switch_off",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "st_switch_off",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 710,
"y": 720,
"wires": [
[
"e2b82781.7af5e",
"18468b2f.edbca5"
]
]
},
{
"id": "95b3ed1f.620b18",
"type": "inject",
"z": "32054f7b.6f13c",
"name": "Update every 1 min",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "60",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"x": 140,
"y": 100,
"wires": [
[
"e64c4e31.36aaf8",
"afbbd0dd.bb8b38"
]
]
},
{
"id": "a0ee8250.47b91",
"type": "debug",
"z": "32054f7b.6f13c",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "( { \"Time Block\": $flowContext('time_block') } )",
"targetType": "jsonata",
"x": 880,
"y": 100,
"wires": []
},
{
"id": "a2131a41.ef7608",
"type": "change",
"z": "32054f7b.6f13c",
"name": "stop timer",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "stop",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 930,
"y": 780,
"wires": [
[
"e2b82781.7af5e"
]
]
},
{
"id": "d4a8da8b.9feeb8",
"type": "switch",
"z": "32054f7b.6f13c",
"name": "Inactive?",
"property": "payload.value",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "inactive",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 140,
"y": 500,
"wires": [
[
"38012087.2eab18"
]
]
},
{
"id": "38012087.2eab18",
"type": "change",
"z": "32054f7b.6f13c",
"name": "tr_motion-inactive",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "tr_motion-inactive",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 170,
"y": 560,
"wires": [
[
"cd2e24c3.24164",
"8ad74838.a063f"
]
]
},
{
"id": "1066966d.019372",
"type": "change",
"z": "32054f7b.6f13c",
"name": "Manual Block =1",
"rules": [
{
"t": "set",
"p": "manual_block",
"pt": "flow",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 930,
"y": 360,
"wires": [
[
"76ef38e1.e0c138"
]
]
},
{
"id": "9cb826db.929388",
"type": "change",
"z": "32054f7b.6f13c",
"name": "Manual Block =0",
"rules": [
{
"t": "set",
"p": "manual_block",
"pt": "flow",
"to": "0",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1450,
"y": 360,
"wires": [
[]
]
},
{
"id": "7676191b.c2c53",
"type": "delay",
"z": "32054f7b.6f13c",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 1280,
"y": 360,
"wires": [
[
"9cb826db.929388"
]
]
},
{
"id": "be1931cb.958768",
"type": "change",
"z": "32054f7b.6f13c",
"name": "Manual Block =1",
"rules": [
{
"t": "set",
"p": "manual_block",
"pt": "flow",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 930,
"y": 540,
"wires": [
[
"e4033469.c56598"
]
]
},
{
"id": "a557edf7.e7b4",
"type": "change",
"z": "32054f7b.6f13c",
"name": "Manual Block =0",
"rules": [
{
"t": "set",
"p": "manual_block",
"pt": "flow",
"to": "0",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1270,
"y": 600,
"wires": [
[
"9d1eb16.c4c095"
]
]
},
{
"id": "7b856664.62a66",
"type": "switch",
"z": "32054f7b.6f13c",
"name": "Manual Block=1",
"property": "manual_block",
"propertyType": "flow",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 240,
"y": 660,
"wires": [
[
"c97a4d6d.1f772"
]
]
},
{
"id": "a27508c.116b578",
"type": "delay",
"z": "32054f7b.6f13c",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 1280,
"y": 540,
"wires": [
[
"a557edf7.e7b4"
]
]
},
{
"id": "4ed301e3.bd1a78",
"type": "delay",
"z": "32054f7b.6f13c",
"name": "",
"pauseType": "delay",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 1400,
"y": 160,
"wires": [
[
"38012087.2eab18"
]
]
},
{
"id": "d0c8b8e.6894848",
"type": "hubitat config",
"z": "",
"name": "Hubitat",
"usetls": false,
"host": "192.168.1.17",
"port": "80",
"token": "e5653e7e-56a0-43fc-8e19-96a6d9f22711",
"appId": "2834",
"nodeRedServer": "http://192.168.1.10:1882",
"webhookPath": "/hubitat/webhook"
}]