Skip to content

Instantly share code, notes, and snippets.

@oblogic7
Last active July 17, 2019 16:27
Show Gist options
  • Save oblogic7/7399bbe11dc1dbd9a1822d2c25b99b94 to your computer and use it in GitHub Desktop.
Save oblogic7/7399bbe11dc1dbd9a1822d2c25b99b94 to your computer and use it in GitHub Desktop.
Node Red flow for mock occupancy in Home Assistant
[
{
"id": "3c1e70cc.56031",
"type": "delay",
"z": "97047d3e.e8278",
"name": "Randomize",
"pauseType": "random",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "300",
"randomUnits": "seconds",
"drop": false,
"x": 1030,
"y": 300,
"wires": [
[
"b78e0fc9.3e897"
]
]
},
{
"id": "e4410f0c.79f2f",
"type": "delay",
"z": "97047d3e.e8278",
"name": "Startup Delay",
"pauseType": "delay",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 820,
"y": 300,
"wires": [
[
"3c1e70cc.56031"
]
]
},
{
"id": "b78e0fc9.3e897",
"type": "api-current-state",
"z": "97047d3e.e8278",
"name": "Halt If Not Extended Away",
"server": "144427d5.6c9f18",
"halt_if": "off",
"halt_if_type": "str",
"halt_if_compare": "is",
"override_topic": false,
"override_payload": false,
"override_data": false,
"entity_id": "input_boolean.extended_away_mode",
"state_type": "str",
"outputs": 2,
"x": 1280,
"y": 300,
"wires": [
[
"5623456b.fc134c",
"f6fe513a.1dd42"
],
[]
],
"icon": "node-red/alert.png"
},
{
"id": "9bb5757.d056d88",
"type": "function",
"z": "97047d3e.e8278",
"name": "Build Service Payload",
"func": "if(msg.payload == 'ON') {\n var service = 'turn_on';\n} else {\n var service = 'turn_off';\n}\n\nvar domain = msg.topic.split('.')[0];\n\nreturn { \n payload:{\n domain: domain,\n service: service,\n data: {\n entity_id: msg.topic\n }\n }\n };",
"outputs": 1,
"noerr": 0,
"x": 800,
"y": 260,
"wires": [
[
"e4410f0c.79f2f"
]
]
},
{
"id": "5623456b.fc134c",
"type": "switch",
"z": "97047d3e.e8278",
"name": "Discard Strings",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "istype",
"v": "object",
"vt": "object"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 1540,
"y": 300,
"wires": [
[
"c9f72f6.4fa52d"
]
]
},
{
"id": "f6fe513a.1dd42",
"type": "debug",
"z": "97047d3e.e8278",
"name": "Light Service Debug",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 1560,
"y": 360,
"wires": []
},
{
"id": "3d25b766.82cee8",
"type": "light-scheduler",
"z": "97047d3e.e8278",
"settings": "9dba4206.297ed",
"events": "[{\"start\":{\"dow\":1,\"mod\":1080},\"end\":{\"dow\":1,\"mod\":1095}},{\"start\":{\"dow\":1,\"mod\":1275},\"end\":{\"dow\":1,\"mod\":1290}},{\"start\":{\"dow\":2,\"mod\":1095},\"end\":{\"dow\":2,\"mod\":1110}},{\"start\":{\"dow\":4,\"mod\":1080},\"end\":{\"dow\":4,\"mod\":1095}},{\"start\":{\"dow\":3,\"mod\":1215},\"end\":{\"dow\":3,\"mod\":1230}},{\"start\":{\"dow\":4,\"mod\":1110},\"end\":{\"dow\":4,\"mod\":1125}},{\"start\":{\"dow\":3,\"mod\":1125},\"end\":{\"dow\":3,\"mod\":1155}},{\"start\":{\"dow\":1,\"mod\":1125},\"end\":{\"dow\":1,\"mod\":1170}},{\"start\":{\"dow\":1,\"mod\":1230},\"end\":{\"dow\":1,\"mod\":1245}},{\"start\":{\"dow\":1,\"mod\":1335},\"end\":{\"dow\":1,\"mod\":1365}},{\"start\":{\"dow\":2,\"mod\":1170},\"end\":{\"dow\":2,\"mod\":1200}},{\"start\":{\"dow\":4,\"mod\":1260},\"end\":{\"dow\":4,\"mod\":1275}},{\"start\":{\"dow\":4,\"mod\":1335},\"end\":{\"dow\":4,\"mod\":1350}},{\"start\":{\"dow\":5,\"mod\":1170},\"end\":{\"dow\":5,\"mod\":1200}},{\"start\":{\"dow\":5,\"mod\":1260},\"end\":{\"dow\":5,\"mod\":1275}},{\"start\":{\"dow\":5,\"mod\":1305},\"end\":{\"dow\":5,\"mod\":1320}},{\"start\":{\"dow\":6,\"mod\":1200},\"end\":{\"dow\":6,\"mod\":1215}},{\"start\":{\"dow\":2,\"mod\":1290},\"end\":{\"dow\":2,\"mod\":1305}},{\"start\":{\"dow\":0,\"mod\":1275},\"end\":{\"dow\":0,\"mod\":1290}},{\"start\":{\"dow\":0,\"mod\":1215},\"end\":{\"dow\":0,\"mod\":1230}},{\"start\":{\"dow\":0,\"mod\":1155},\"end\":{\"dow\":0,\"mod\":1185}},{\"start\":{\"dow\":6,\"mod\":1365},\"end\":{\"dow\":6,\"mod\":1380}},{\"start\":{\"dow\":0,\"mod\":1335},\"end\":{\"dow\":0,\"mod\":1350}}]",
"topic": "light.kitchen_can_lights",
"name": "Kitchen Schedule",
"onPayload": "ON",
"onPayloadType": "str",
"offPayload": "OFF",
"offPayloadType": "str",
"onlyWhenDark": true,
"sunElevationThreshold": 6,
"sunShowElevationInStatus": false,
"outputfreq": "output.statechange.startup",
"x": 470,
"y": 140,
"wires": [
[
"9bb5757.d056d88"
]
]
},
{
"id": "458a451b.4b1efc",
"type": "light-scheduler",
"z": "97047d3e.e8278",
"settings": "9dba4206.297ed",
"events": "[{\"start\":{\"dow\":2,\"mod\":1350},\"end\":{\"dow\":2,\"mod\":1365}},{\"start\":{\"dow\":2,\"mod\":1380},\"end\":{\"dow\":3,\"mod\":0}},{\"start\":{\"dow\":1,\"mod\":1335},\"end\":{\"dow\":2,\"mod\":0}},{\"start\":{\"dow\":3,\"mod\":1365},\"end\":{\"dow\":4,\"mod\":0}},{\"start\":{\"dow\":4,\"mod\":1335},\"end\":{\"dow\":5,\"mod\":0}},{\"start\":{\"dow\":6,\"mod\":1335},\"end\":{\"dow\":0,\"mod\":0}},{\"start\":{\"dow\":0,\"mod\":1320},\"end\":{\"dow\":1,\"mod\":0}},{\"start\":{\"dow\":5,\"mod\":1320},\"end\":{\"dow\":5,\"mod\":1335}},{\"start\":{\"dow\":5,\"mod\":1350},\"end\":{\"dow\":6,\"mod\":0}},{\"start\":{\"dow\":1,\"mod\":0},\"end\":{\"dow\":1,\"mod\":405}},{\"start\":{\"dow\":2,\"mod\":0},\"end\":{\"dow\":2,\"mod\":405}},{\"start\":{\"dow\":3,\"mod\":0},\"end\":{\"dow\":3,\"mod\":390}},{\"start\":{\"dow\":4,\"mod\":0},\"end\":{\"dow\":4,\"mod\":405}},{\"start\":{\"dow\":5,\"mod\":0},\"end\":{\"dow\":5,\"mod\":420}},{\"start\":{\"dow\":6,\"mod\":0},\"end\":{\"dow\":6,\"mod\":420}},{\"start\":{\"dow\":0,\"mod\":0},\"end\":{\"dow\":0,\"mod\":405}}]",
"topic": "switch.stair_light",
"name": "Stair Light Schedule",
"onPayload": "ON",
"onPayloadType": "str",
"offPayload": "OFF",
"offPayloadType": "str",
"onlyWhenDark": true,
"sunElevationThreshold": 6,
"sunShowElevationInStatus": false,
"outputfreq": "output.statechange.startup",
"x": 480,
"y": 200,
"wires": [
[
"9bb5757.d056d88"
]
]
},
{
"id": "e37dd587.8c1ba8",
"type": "light-scheduler",
"z": "97047d3e.e8278",
"settings": "9dba4206.297ed",
"events": "[{\"start\":{\"dow\":1,\"mod\":1230},\"end\":{\"dow\":1,\"mod\":1290}},{\"start\":{\"dow\":1,\"mod\":1305},\"end\":{\"dow\":1,\"mod\":1335}},{\"start\":{\"dow\":2,\"mod\":1245},\"end\":{\"dow\":2,\"mod\":1320}},{\"start\":{\"dow\":3,\"mod\":1245},\"end\":{\"dow\":3,\"mod\":1305}},{\"start\":{\"dow\":3,\"mod\":1320},\"end\":{\"dow\":3,\"mod\":1335}},{\"start\":{\"dow\":4,\"mod\":1260},\"end\":{\"dow\":4,\"mod\":1290}},{\"start\":{\"dow\":4,\"mod\":1320},\"end\":{\"dow\":4,\"mod\":1350}},{\"start\":{\"dow\":5,\"mod\":1215},\"end\":{\"dow\":5,\"mod\":1335}},{\"start\":{\"dow\":6,\"mod\":1245},\"end\":{\"dow\":6,\"mod\":1305}},{\"start\":{\"dow\":0,\"mod\":1290},\"end\":{\"dow\":0,\"mod\":1335}},{\"start\":{\"dow\":1,\"mod\":1140},\"end\":{\"dow\":1,\"mod\":1155}},{\"start\":{\"dow\":2,\"mod\":1170},\"end\":{\"dow\":2,\"mod\":1185}},{\"start\":{\"dow\":4,\"mod\":1140},\"end\":{\"dow\":4,\"mod\":1155}},{\"start\":{\"dow\":5,\"mod\":1185},\"end\":{\"dow\":5,\"mod\":1200}},{\"start\":{\"dow\":6,\"mod\":1110},\"end\":{\"dow\":6,\"mod\":1125}},{\"start\":{\"dow\":0,\"mod\":1155},\"end\":{\"dow\":0,\"mod\":1170}},{\"start\":{\"dow\":3,\"mod\":1110},\"end\":{\"dow\":3,\"mod\":1125}},{\"start\":{\"dow\":3,\"mod\":1155},\"end\":{\"dow\":3,\"mod\":1170}},{\"start\":{\"dow\":6,\"mod\":1215},\"end\":{\"dow\":6,\"mod\":1230}},{\"start\":{\"dow\":3,\"mod\":1215},\"end\":{\"dow\":3,\"mod\":1230}},{\"start\":{\"dow\":0,\"mod\":1245},\"end\":{\"dow\":0,\"mod\":1260}}]",
"topic": "switch.master_bedroom_light",
"name": "Master Bedroom Light Schedule",
"onPayload": "ON",
"onPayloadType": "str",
"offPayload": "OFF",
"offPayloadType": "str",
"onlyWhenDark": true,
"sunElevationThreshold": 6,
"sunShowElevationInStatus": false,
"outputfreq": "output.statechange.startup",
"x": 510,
"y": 260,
"wires": [
[
"9bb5757.d056d88"
]
]
},
{
"id": "dbefdafa.3f9cf8",
"type": "light-scheduler",
"z": "97047d3e.e8278",
"settings": "9dba4206.297ed",
"events": "[{\"start\":{\"dow\":1,\"mod\":1095},\"end\":{\"dow\":1,\"mod\":1215}},{\"start\":{\"dow\":2,\"mod\":1125},\"end\":{\"dow\":2,\"mod\":1230}},{\"start\":{\"dow\":3,\"mod\":1095},\"end\":{\"dow\":3,\"mod\":1215}},{\"start\":{\"dow\":4,\"mod\":1080},\"end\":{\"dow\":4,\"mod\":1230}},{\"start\":{\"dow\":6,\"mod\":1095},\"end\":{\"dow\":6,\"mod\":1260}},{\"start\":{\"dow\":0,\"mod\":1155},\"end\":{\"dow\":0,\"mod\":1230}},{\"start\":{\"dow\":5,\"mod\":1110},\"end\":{\"dow\":5,\"mod\":1245}}]",
"topic": "switch.playroom_can_lights",
"name": "Playroom Light Schedule",
"onPayload": "ON",
"onPayloadType": "str",
"offPayload": "OFF",
"offPayloadType": "str",
"onlyWhenDark": true,
"sunElevationThreshold": 6,
"sunShowElevationInStatus": false,
"outputfreq": "output.statechange.startup",
"x": 490,
"y": 320,
"wires": [
[
"9bb5757.d056d88"
]
]
},
{
"id": "38d09349.53b57c",
"type": "light-scheduler",
"z": "97047d3e.e8278",
"settings": "9dba4206.297ed",
"events": "[{\"start\":{\"dow\":1,\"mod\":1140},\"end\":{\"dow\":1,\"mod\":1155}},{\"start\":{\"dow\":3,\"mod\":1170},\"end\":{\"dow\":3,\"mod\":1200}},{\"start\":{\"dow\":4,\"mod\":1125},\"end\":{\"dow\":4,\"mod\":1140}},{\"start\":{\"dow\":6,\"mod\":1215},\"end\":{\"dow\":6,\"mod\":1245}}]",
"topic": "light.living_room_chandelier",
"name": "Living Room Can Lights",
"onPayload": "ON",
"onPayloadType": "str",
"offPayload": "OFF",
"offPayloadType": "str",
"onlyWhenDark": true,
"sunElevationThreshold": 6,
"sunShowElevationInStatus": false,
"outputfreq": "output.statechange.startup",
"x": 490,
"y": 380,
"wires": [
[
"9bb5757.d056d88"
]
]
},
{
"id": "c9f72f6.4fa52d",
"type": "api-call-service",
"z": "97047d3e.e8278",
"name": "Light Service",
"server": "144427d5.6c9f18",
"service_domain": "",
"service": "",
"data": "",
"mergecontext": "",
"x": 1730,
"y": 300,
"wires": [
[]
]
},
{
"id": "88870d79.b0355",
"type": "inject",
"z": "97047d3e.e8278",
"name": "On",
"topic": "",
"payload": "on",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 190,
"y": 200,
"wires": [
[
"3d25b766.82cee8",
"458a451b.4b1efc",
"e37dd587.8c1ba8",
"dbefdafa.3f9cf8",
"38d09349.53b57c"
]
]
},
{
"id": "ffbdb800.cbb2b8",
"type": "inject",
"z": "97047d3e.e8278",
"name": "Off",
"topic": "",
"payload": "off",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 190,
"y": 240,
"wires": [
[
"3d25b766.82cee8",
"458a451b.4b1efc",
"e37dd587.8c1ba8",
"dbefdafa.3f9cf8",
"38d09349.53b57c"
]
]
},
{
"id": "b3976b49.6c3848",
"type": "inject",
"z": "97047d3e.e8278",
"name": "Auto",
"topic": "",
"payload": "auto",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 190,
"y": 280,
"wires": [
[
"3d25b766.82cee8",
"458a451b.4b1efc",
"e37dd587.8c1ba8",
"dbefdafa.3f9cf8",
"38d09349.53b57c"
]
]
},
{
"id": "5943794e.0d5bf8",
"type": "inject",
"z": "97047d3e.e8278",
"name": "Stop",
"topic": "",
"payload": "stop",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "0.5",
"x": 190,
"y": 320,
"wires": [
[
"3d25b766.82cee8",
"458a451b.4b1efc",
"e37dd587.8c1ba8",
"dbefdafa.3f9cf8",
"38d09349.53b57c"
]
]
},
{
"id": "144427d5.6c9f18",
"type": "server",
"z": "",
"name": "Home Assistant (Primary)",
"legacy": false,
"hassio": false,
"rejectUnauthorizedCerts": true
},
{
"id": "9dba4206.297ed",
"type": "light-scheduler-settings",
"z": "",
"name": "Scheduler Settings",
"latitude": "35.6946919",
"longitude": "-88.8753785"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment