Someone shoot holes through my plan. I want HA/Node-RED to be able to know when either my wife and I, or only one of us is home and set things that have a Home/Away mode to the correct setting.
This is where I have started and I’m not sure that it is working as intended. Thoughts?
[
{
"id": "626a9eee.c0c4f",
"type": "tab",
"label": "Home/Away Controller",
"disabled": false,
"info": "Control Home/Away Devices"
},
{
"id": "3dc6a01d.1f5c8",
"type": "function",
"z": "626a9eee.c0c4f",
"name": "Is Anyone Home?",
"func": "var jonathanLocation = global.get(\"jonathanLocation\");\nvar taylorLocation = global.get(\"taylorLocation\");\n\nif (jonathanLocation != \"home\" && taylorLocation != \"home\") {\n msg.payload = \"away\";\n return msg;\n} else {\n msg.payload = \"home\";\n return msg;\n}\n",
"outputs": 1,
"noerr": 0,
"x": 530,
"y": 200,
"wires": [
[
"933f60f8.57b86"
]
]
},
{
"id": "8ef890b.0eede7",
"type": "api-call-service",
"z": "626a9eee.c0c4f",
"name": "Nest: Away",
"server": "92954ff.98a11b",
"service_domain": "climate",
"service": "set_away_mode",
"data": "{ \"away_mode\": \"on\" }",
"mergecontext": "",
"x": 1010,
"y": 220,
"wires": [
[]
]
},
{
"id": "6b3569c1.d0a388",
"type": "api-call-service",
"z": "626a9eee.c0c4f",
"name": "Nest: Home",
"server": "92954ff.98a11b",
"service_domain": "climate",
"service": "set_away_mode",
"data": "{ \"away_mode\": \"off\" }",
"mergecontext": "",
"x": 1010,
"y": 180,
"wires": [
[]
]
},
{
"id": "933f60f8.57b86",
"type": "switch",
"z": "626a9eee.c0c4f",
"name": "Outputs for Home/Away",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "home",
"vt": "str"
},
{
"t": "eq",
"v": "away",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 770,
"y": 200,
"wires": [
[
"6b3569c1.d0a388",
"c82f3996.256f88"
],
[
"8ef890b.0eede7",
"f2f77c20.5282"
]
]
},
{
"id": "f2f77c20.5282",
"type": "api-call-service",
"z": "626a9eee.c0c4f",
"name": "Arlo: Armed",
"server": "92954ff.98a11b",
"service_domain": "camera",
"service": "enable_motion_detection",
"data": "{ \"entity_id\": \"camera.front_window, camera.antuique_record_player\" }",
"mergecontext": "",
"x": 1010,
"y": 360,
"wires": [
[]
]
},
{
"id": "c82f3996.256f88",
"type": "api-call-service",
"z": "626a9eee.c0c4f",
"name": "Arlo: Disarmed",
"server": "92954ff.98a11b",
"service_domain": "camera",
"service": "disable_motion_detection",
"data": "{ \"entity_id\": \"camera.front_window, camera.antuique_record_player\" }",
"mergecontext": "",
"x": 1020,
"y": 320,
"wires": [
[]
]
},
{
"id": "3dfe2afa.47a106",
"type": "comment",
"z": "626a9eee.c0c4f",
"name": "Set Nest Home/Away",
"info": "",
"x": 1040,
"y": 140,
"wires": []
},
{
"id": "1b98b668.7390aa",
"type": "comment",
"z": "626a9eee.c0c4f",
"name": "Arm/Disarm Arlo",
"info": "",
"x": 1020,
"y": 280,
"wires": []
},
{
"id": "e9c44549.b2ce78",
"type": "server-state-changed",
"z": "626a9eee.c0c4f",
"name": "Jonathan Location",
"server": "92954ff.98a11b",
"entityidfilter": "device_tracker.google_maps_****",
"entityidfiltertype": "substring",
"haltifstate": "",
"x": 110,
"y": 180,
"wires": [
[
"6c88db56.d56e44"
]
]
},
{
"id": "5df57d77.685084",
"type": "server-state-changed",
"z": "626a9eee.c0c4f",
"name": "Taylor Location",
"server": "92954ff.98a11b",
"entityidfilter": "device_tracker.google_maps_****",
"entityidfiltertype": "substring",
"haltifstate": "",
"x": 120,
"y": 220,
"wires": [
[
"a8c9173c.21c638"
]
]
},
{
"id": "6c88db56.d56e44",
"type": "function",
"z": "626a9eee.c0c4f",
"name": "jonathanLocation",
"func": "global.set(\"jonathanLocation\", msg.data.new_state.state);\nconsole.log(\"Jonathan's location changed...\");",
"outputs": 1,
"noerr": 0,
"x": 310,
"y": 180,
"wires": [
[
"3dc6a01d.1f5c8"
]
]
},
{
"id": "a8c9173c.21c638",
"type": "function",
"z": "626a9eee.c0c4f",
"name": "taylorLocation",
"func": "global.set(\"taylorLocation\", msg.data.new_state.state);\nconsole.log(\"Taylors location changed...\")",
"outputs": 1,
"noerr": 0,
"x": 320,
"y": 220,
"wires": [
[
"3dc6a01d.1f5c8"
]
]
},
{
"id": "92954ff.98a11b",
"type": "server",
"z": "",
"name": "homeassistant",
"url": "http://192.168.0.250:8123",
"pass": "****"
}
]
Also here is a photo of the flow so you can see the “wiring”: