Created
January 7, 2019 19:11
-
-
Save oblogic7/d153ac9d1a44a996edc45094fd8ea29b to your computer and use it in GitHub Desktop.
Camera/TV Automation via Node Red and Home Assistant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "8fb080c0.696a2", | |
"type": "inject", | |
"z": "3e9522c6.d11e1e", | |
"name": "Test Notification", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 140, | |
"y": 220, | |
"wires": [ | |
[ | |
"1f9e987c.47f058" | |
] | |
] | |
}, | |
{ | |
"id": "1f9e987c.47f058", | |
"type": "function", | |
"z": "3e9522c6.d11e1e", | |
"name": "Test Doorbell", | |
"func": "msg.event_type = 'doorbird_front_door_button'\n// msg.event_type = 'doorbird_side_entry_button'\n// msg.event_type = 'doorbird_back_door_button'\n\n\nreturn msg;\n\n", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 390, | |
"y": 220, | |
"wires": [ | |
[ | |
"9bf1aa85.7499c8" | |
] | |
] | |
}, | |
{ | |
"id": "9bf1aa85.7499c8", | |
"type": "function", | |
"z": "3e9522c6.d11e1e", | |
"name": "Doorbell to Camera Mapper", | |
"func": "var map = {\n doorbird_back_door_button: \"camera.back_door_live\",\n doorbird_front_door_button: \"camera.front_door_live\",\n doorbird_side_entry_button: \"camera.side_entry_live\",\n}\n\nmsg.payload = {\n entity_id: map[msg.event_type],\n}\n\nmsg.display = 'all';\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 680, | |
"y": 220, | |
"wires": [ | |
[ | |
"78310c2b.3a5c44" | |
] | |
] | |
}, | |
{ | |
"id": "ded49243.9bbe1", | |
"type": "switch", | |
"z": "3e9522c6.d11e1e", | |
"name": "Doorbird Doorbell Events", | |
"property": "event_type", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "regex", | |
"v": "doorbird_.*_button", | |
"vt": "str", | |
"case": false | |
} | |
], | |
"checkall": "true", | |
"repair": false, | |
"outputs": 1, | |
"x": 350, | |
"y": 260, | |
"wires": [ | |
[ | |
"9bf1aa85.7499c8" | |
] | |
] | |
}, | |
{ | |
"id": "78310c2b.3a5c44", | |
"type": "api-current-state", | |
"z": "3e9522c6.d11e1e", | |
"name": "Get Camera URL", | |
"server": "144427d5.6c9f18", | |
"halt_if": "", | |
"halt_if_type": "str", | |
"halt_if_compare": "is", | |
"override_topic": false, | |
"override_payload": false, | |
"override_data": true, | |
"entity_id": "", | |
"state_type": "str", | |
"outputs": 1, | |
"x": 1010, | |
"y": 380, | |
"wires": [ | |
[ | |
"cb9584e6.66a8b8" | |
] | |
] | |
}, | |
{ | |
"id": "e0f73ce1.d1e12", | |
"type": "server-events", | |
"z": "3e9522c6.d11e1e", | |
"name": "All Events", | |
"server": "144427d5.6c9f18", | |
"x": 120, | |
"y": 260, | |
"wires": [ | |
[ | |
"ded49243.9bbe1" | |
] | |
] | |
}, | |
{ | |
"id": "cb9584e6.66a8b8", | |
"type": "credentials", | |
"z": "3e9522c6.d11e1e", | |
"name": "Get Base URL", | |
"props": [ | |
{ | |
"value": "base_url", | |
"type": "msg" | |
} | |
], | |
"x": 1020, | |
"y": 320, | |
"wires": [ | |
[ | |
"a67f2028.5f2d7" | |
] | |
] | |
}, | |
{ | |
"id": "76b58aa2.4c5024", | |
"type": "function", | |
"z": "3e9522c6.d11e1e", | |
"name": "Alexa Action to Camera/Display Mapper", | |
"func": "var map = {\n \"input_boolean.alexa_show_back_door_office_tv\": {camera: \"camera.back_door_live\", display: \"media_player.office_chromecast\"},\n \"input_boolean.alexa_show_front_door_office_tv\": {camera: \"camera.front_door_live\", display: \"media_player.office_chromecast\"},\n \"input_boolean.alexa_show_side_entry_office_tv\": {camera: \"camera.side_entry_live\", display: \"media_player.office_chromecast\"},\n \"input_boolean.alexa_show_girls_room_office_tv\": {camera: \"camera.girls_room\", display: \"media_player.office_tv_chromecast\"},\n \n \"input_boolean.alexa_show_back_door_playroom_tv\": {camera: \"camera.back_door_live\", display: \"media_player.playroom_tv_chromecast\"},\n \"input_boolean.alexa_show_front_door_playroom_tv\": {camera: \"camera.front_door_live\", display: \"media_player.playroom_tv_chromecast\"},\n \"input_boolean.alexa_show_side_entry_playroom_tv\": {camera: \"camera.side_entry_live\", display: \"media_player.playroom_tv_chromecast\"},\n \"input_boolean.alexa_show_girls_room_play_room_tv\": {camera: \"camera.girls_room\", display: \"media_player.playroom_tv_chromecast\"},\n \n \"input_boolean.alexa_show_back_door_living_room_tv\": {camera: \"camera.back_door_live\", display: \"media_player.living_room_chromecast\"},\n \"input_boolean.alexa_show_front_door_living_room_tv\": {camera: \"camera.front_door_live\", display: \"media_player.living_room_chromecast\"},\n \"input_boolean.alexa_show_side_entry_living_room_tv\": {camera: \"camera.side_entry_live\", display: \"media_player.living_room_chromecast\"},\n \"input_boolean.alexa_show_girls_room_living_room_tv\": {camera: \"camera.girls_room\", display: \"media_player.living_room_chromecast\"},\n \n \n}\n\nmsg.payload = {\n entity_id: map[msg.topic].camera,\n}\n\nmsg.display = map[msg.topic].display;\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 660, | |
"y": 380, | |
"wires": [ | |
[ | |
"78310c2b.3a5c44" | |
] | |
] | |
}, | |
{ | |
"id": "a67f2028.5f2d7", | |
"type": "switch", | |
"z": "3e9522c6.d11e1e", | |
"name": "Display Selector", | |
"property": "display", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "neq", | |
"v": "all", | |
"vt": "str" | |
}, | |
{ | |
"t": "else" | |
} | |
], | |
"checkall": "false", | |
"repair": false, | |
"outputs": 2, | |
"x": 1040, | |
"y": 260, | |
"wires": [ | |
[ | |
"c7579c9b.d4f56" | |
], | |
[ | |
"e1d3a8a0.2ce0f8" | |
] | |
] | |
}, | |
{ | |
"id": "fc268fde.02b75", | |
"type": "server-state-changed", | |
"z": "3e9522c6.d11e1e", | |
"name": "Alexa Handler - Show Cameras on TVs", | |
"server": "144427d5.6c9f18", | |
"entityidfilter": "input_boolean.alexa_show_.*_tv", | |
"entityidfiltertype": "regex", | |
"outputinitially": false, | |
"state_type": "str", | |
"haltifstate": "off", | |
"halt_if_type": "str", | |
"halt_if_compare": "is", | |
"outputs": 2, | |
"x": 190, | |
"y": 380, | |
"wires": [ | |
[ | |
"76b58aa2.4c5024" | |
], | |
[] | |
] | |
}, | |
{ | |
"id": "c7579c9b.d4f56", | |
"type": "change", | |
"z": "3e9522c6.d11e1e", | |
"name": "Set Display Payload", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload.data.entity_id", | |
"pt": "msg", | |
"to": "display", | |
"tot": "msg" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 1360, | |
"y": 260, | |
"wires": [ | |
[ | |
"8d11fcf7.518b1", | |
"188c665e.0b683a" | |
] | |
] | |
}, | |
{ | |
"id": "e1d3a8a0.2ce0f8", | |
"type": "api-call-service", | |
"z": "3e9522c6.d11e1e", | |
"name": "Show Camera on All Displays", | |
"server": "144427d5.6c9f18", | |
"service_domain": "media_player", | |
"service": "play_media", | |
"data": "{\"entity_id\":\"media_player.living_room_chromecast, media_player.office_chromecast, media_player.playroom_tv_chromecast, media_player.master_bedroom_tv\",\"media_content_id\":\"https://{{base_url}}/api/camera_proxy_stream/{{data.entity_id}}?token={{data.attributes.access_token}}\",\"media_content_type\":\"image/jpg\"}", | |
"render_data": true, | |
"mergecontext": "", | |
"output_location": "payload", | |
"output_location_type": "msg", | |
"x": 1390, | |
"y": 380, | |
"wires": [ | |
[ | |
"98f435bd.39b668" | |
] | |
] | |
}, | |
{ | |
"id": "8d11fcf7.518b1", | |
"type": "api-call-service", | |
"z": "3e9522c6.d11e1e", | |
"name": "Show Camera on Requested Display", | |
"server": "144427d5.6c9f18", | |
"service_domain": "media_player", | |
"service": "play_media", | |
"data": "{\"media_content_id\":\"https://{{base_url}}/api/camera_proxy_stream/{{data.entity_id}}?token={{data.attributes.access_token}}\",\"media_content_type\":\"image/jpg\"}", | |
"render_data": true, | |
"mergecontext": "", | |
"output_location": "payload", | |
"output_location_type": "msg", | |
"x": 1410, | |
"y": 300, | |
"wires": [ | |
[ | |
"aa990c2c.22912" | |
] | |
] | |
}, | |
{ | |
"id": "188c665e.0b683a", | |
"type": "debug", | |
"z": "3e9522c6.d11e1e", | |
"name": "", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "false", | |
"x": 1560, | |
"y": 180, | |
"wires": [] | |
}, | |
{ | |
"id": "98f435bd.39b668", | |
"type": "delay", | |
"z": "3e9522c6.d11e1e", | |
"name": "Delay", | |
"pauseType": "delay", | |
"timeout": "15", | |
"timeoutUnits": "seconds", | |
"rate": "1", | |
"nbRateUnits": "1", | |
"rateUnits": "second", | |
"randomFirst": "1", | |
"randomLast": "5", | |
"randomUnits": "seconds", | |
"drop": false, | |
"x": 1650, | |
"y": 380, | |
"wires": [ | |
[ | |
"80d538c4.f9f818" | |
] | |
] | |
}, | |
{ | |
"id": "aa990c2c.22912", | |
"type": "delay", | |
"z": "3e9522c6.d11e1e", | |
"name": "Delay", | |
"pauseType": "delay", | |
"timeout": "300", | |
"timeoutUnits": "seconds", | |
"rate": "1", | |
"nbRateUnits": "1", | |
"rateUnits": "second", | |
"randomFirst": "1", | |
"randomLast": "5", | |
"randomUnits": "seconds", | |
"drop": false, | |
"x": 1650, | |
"y": 300, | |
"wires": [ | |
[ | |
"80d538c4.f9f818" | |
] | |
] | |
}, | |
{ | |
"id": "80d538c4.f9f818", | |
"type": "change", | |
"z": "3e9522c6.d11e1e", | |
"name": "Clean Payload", | |
"rules": [ | |
{ | |
"t": "delete", | |
"p": "payload.service", | |
"pt": "msg" | |
}, | |
{ | |
"t": "delete", | |
"p": "payload.data.media_content_id", | |
"pt": "msg" | |
}, | |
{ | |
"t": "delete", | |
"p": "payload.data.media_content_type", | |
"pt": "msg" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 1880, | |
"y": 300, | |
"wires": [ | |
[ | |
"48d2989b.427f78" | |
] | |
] | |
}, | |
{ | |
"id": "48d2989b.427f78", | |
"type": "api-call-service", | |
"z": "3e9522c6.d11e1e", | |
"name": "Stop Camera Stream on Display", | |
"server": "144427d5.6c9f18", | |
"service_domain": "media_player", | |
"service": "turn_off", | |
"data": "", | |
"render_data": false, | |
"mergecontext": "", | |
"output_location": "payload", | |
"output_location_type": "msg", | |
"x": 1930, | |
"y": 340, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "144427d5.6c9f18", | |
"type": "server", | |
"z": "", | |
"name": "Home Assistant (Primary)", | |
"legacy": false, | |
"hassio": false, | |
"rejectUnauthorizedCerts": true | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment