[ { "id": "fdff74d6.e6bfe8", "type": "subflow", "name": "Sonos TTS", "info": "", "category": "", "in": [ { "x": 40, "y": 80, "wires": [ { "id": "7df8d0c8.1ebef" } ] } ], "out": [], "env": [ { "name": "sonos_entity", "type": "str", "value": "", "ui": { "icon": "font-awesome/fa-bullhorn", "label": { "en-US": "Entiy ID of Sonos entity" }, "type": "input", "opts": { "types": [ "str" ] } } }, { "name": "volume", "type": "num", "value": "0.5", "ui": { "icon": "font-awesome/fa-dashboard", "label": { "en-US": "Volume (0.0-1.0)" }, "type": "input", "opts": { "types": [ "num" ] } } }, { "name": "TTS_message", "type": "str", "value": "", "ui": { "icon": "font-awesome/fa-commenting", "label": { "en-US": "Message to say" }, "type": "input", "opts": { "types": [ "str", "json" ] } } }, { "name": "delay_before_restore", "type": "num", "value": "5", "ui": { "icon": "font-awesome/fa-clock-o", "label": { "en-US": "Seconds to delay restore" }, "type": "spinner", "opts": { "min": 0, "max": 60 } } } ], "color": "#DDAA99" }, { "id": "d433443d.eda488", "type": "api-call-service", "z": "fdff74d6.e6bfe8", "name": "Snapshot", "server": "3bebce79.1e0962", "version": 1, "debugenabled": false, "service_domain": "sonos", "service": "snapshot", "entityId": "{{ sonos_data.sonos_entity }}", "data": "", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 320, "y": 80, "wires": [ [ "5f7736ee.16ae68" ] ] }, { "id": "5f7736ee.16ae68", "type": "api-call-service", "z": "fdff74d6.e6bfe8", "name": "Unjoin", "server": "3bebce79.1e0962", "version": 1, "debugenabled": false, "service_domain": "sonos", "service": "unjoin", "entityId": "{{ sonos_data.sonos_entity }}", "data": "", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 450, "y": 80, "wires": [ [ "646231de.e7ab4" ] ] }, { "id": "646231de.e7ab4", "type": "api-call-service", "z": "fdff74d6.e6bfe8", "name": "Volume", "server": "3bebce79.1e0962", "version": 1, "debugenabled": false, "service_domain": "media_player", "service": "volume_set", "entityId": "{{ sonos_data.sonos_entity }}", "data": "{\"volume_level\":\"{{ sonos_data.volume }}\"}", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 580, "y": 80, "wires": [ [ "5460a0df.97145" ] ] }, { "id": "5460a0df.97145", "type": "api-call-service", "z": "fdff74d6.e6bfe8", "name": "TTS", "server": "3bebce79.1e0962", "version": 1, "debugenabled": false, "service_domain": "tts", "service": "google_translate_say", "entityId": "{{ sonos_data.sonos_entity }}", "data": "{\"message\":\"{{{sonos_data.message}}}\",\"language\":\"da\"}", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 710, "y": 80, "wires": [ [ "a3e3bd28.f6c1e" ] ] }, { "id": "4a5624f5.5f059c", "type": "api-call-service", "z": "fdff74d6.e6bfe8", "name": "Restore", "server": "3bebce79.1e0962", "version": 1, "debugenabled": false, "service_domain": "sonos", "service": "restore", "entityId": "{{ sonos_data.sonos_entity }}", "data": "", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 960, "y": 80, "wires": [ [] ] }, { "id": "7df8d0c8.1ebef", "type": "change", "z": "fdff74d6.e6bfe8", "name": "Sonos variables", "rules": [ { "t": "set", "p": "sonos_data.sonos_entity", "pt": "msg", "to": "sonos_entity", "tot": "env" }, { "t": "set", "p": "sonos_data.volume", "pt": "msg", "to": "volume", "tot": "env" }, { "t": "set", "p": "sonos_data.message", "pt": "msg", "to": "TTS_message", "tot": "env" }, { "t": "set", "p": "delay", "pt": "msg", "to": "delay_before_restore", "tot": "env" }, { "t": "set", "p": "delay", "pt": "msg", "to": "msg.delay*1000", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 160, "y": 80, "wires": [ [ "d433443d.eda488" ] ] }, { "id": "a3e3bd28.f6c1e", "type": "delay", "z": "fdff74d6.e6bfe8", "name": "Delay", "pauseType": "delayv", "timeout": "1", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "x": 830, "y": 80, "wires": [ [ "4a5624f5.5f059c" ] ] }, { "id": "780eae3d.9eca9", "type": "tab", "label": "Alarm flow", "disabled": false, "info": "" }, { "id": "a75a8352.76e9", "type": "trigger-state", "z": "780eae3d.9eca9", "name": "Door or window is opened when nobody is home?", "server": "3bebce79.1e0962", "exposeToHomeAssistant": false, "haConfig": [ { "property": "name", "value": "" }, { "property": "icon", "value": "" } ], "entityid": "binary_sensor.openclose", "entityidfiltertype": "substring", "debugenabled": false, "constraints": [ { "targetType": "this_entity", "targetValue": "", "propertyType": "property", "comparatorType": "is", "comparatorValueDatatype": "str", "comparatorValue": "opening", "propertyValue": "new_state.attributes.device_class" }, { "targetType": "this_entity", "targetValue": "", "propertyType": "current_state", "comparatorType": "is", "comparatorValueDatatype": "str", "comparatorValue": "on", "propertyValue": "new_state.state" }, { "targetType": "entity_id", "targetValue": "group.alle_personer", "propertyType": "current_state", "comparatorType": "is", "comparatorValueDatatype": "str", "comparatorValue": "not_home", "propertyValue": "new_state.state" } ], "outputs": 2, "customoutputs": [], "outputinitially": false, "state_type": "str", "x": 220, "y": 90, "wires": [ [ "406040af.fdf9a" ], [] ] }, { "id": "b0a5e4e0.32a678", "type": "api-call-service", "z": "780eae3d.9eca9", "name": "Send critical notification", "server": "3bebce79.1e0962", "version": 1, "debugenabled": true, "service_domain": "notify", "service": "mobile_app_anders_iphone", "entityId": "", "data": "{\"title\":\"Dør/vindue åbnet\",\"message\":\"Følgende døre eller vinduer åbnet, mens I ikke er hjemme: \\n\\n {{payload}} \\n\\n\",\"data\":{\"push\":{\"category\":\"camera1\"},\"sound\":{\"name\":\"default\",\"critical\":1,\"volume\":0}}}", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 1140, "y": 90, "wires": [ [] ] }, { "id": "406040af.fdf9a", "type": "ha-get-entities", "z": "780eae3d.9eca9", "server": "3bebce79.1e0962", "name": "Get all open doors/windows", "rules": [ { "property": "state", "logic": "is", "value": "on", "valueType": "str" }, { "property": "attributes.device_class", "logic": "is", "value": "opening", "valueType": "str" }, { "property": "entity_id", "logic": "starts_with", "value": "binary_sensor.openclose", "valueType": "str" } ], "output_type": "split", "output_empty_results": false, "output_location_type": "msg", "output_location": "payload", "output_results_count": 1, "x": 550, "y": 90, "wires": [ [ "df631e5f.6e219" ] ] }, { "id": "df631e5f.6e219", "type": "template", "z": "780eae3d.9eca9", "name": "Entity names", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{{payload.attributes.friendly_name}}", "output": "str", "x": 760, "y": 90, "wires": [ [ "4b8c4da9.d32d84" ] ] }, { "id": "4b8c4da9.d32d84", "type": "join", "z": "780eae3d.9eca9", "name": "Combine names", "mode": "custom", "build": "string", "property": "payload", "propertyType": "msg", "key": "topic", "joiner": "[92,110]", "joinerType": "bin", "accumulate": false, "timeout": "", "count": "", "reduceRight": false, "reduceExp": "", "reduceInit": "", "reduceInitType": "", "reduceFixup": "", "x": 930, "y": 90, "wires": [ [ "b0a5e4e0.32a678" ] ] }, { "id": "b951aa5b.c415e8", "type": "comment", "z": "780eae3d.9eca9", "name": "Send actionable notification if doors and windows are opened when nobody is home", "info": "", "x": 320, "y": 50, "wires": [] }, { "id": "c2b5e861.0e37b8", "type": "server-events", "z": "780eae3d.9eca9", "name": "IOS Action?", "server": "3bebce79.1e0962", "event_type": "ios.notification_action_fired", "exposeToHomeAssistant": false, "haConfig": [ { "property": "name", "value": "" }, { "property": "icon", "value": "" } ], "x": 100, "y": 210, "wires": [ [ "aba3b9a0.e3e8f8" ] ] }, { "id": "aba3b9a0.e3e8f8", "type": "switch", "z": "780eae3d.9eca9", "name": "Resonse to alert?", "property": "payload.event.actionName", "propertyType": "msg", "rules": [ { "t": "eq", "v": "START_ALARM", "vt": "str" }, { "t": "eq", "v": "STOP_ALARM", "vt": "str" }, { "t": "eq", "v": "NOTIFY_TTS", "vt": "str" } ], "checkall": "false", "repair": false, "outputs": 3, "x": 280, "y": 210, "wires": [ [ "303b49a5.5c0496" ], [ "e2399287.32471" ], [ "36b7bac0.0d07f6", "73f5ecea.3d2b34" ] ], "outputLabels": [ "Remind me later", "Postpone cleaning", "Clean selected rooms only" ] }, { "id": "36b7bac0.0d07f6", "type": "debug", "z": "780eae3d.9eca9", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload.event.response_info", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 580, "y": 320, "wires": [] }, { "id": "73f5ecea.3d2b34", "type": "subflow:fdff74d6.e6bfe8", "z": "780eae3d.9eca9", "name": "Play TTS", "env": [ { "name": "sonos_entity", "value": "media_player.kontor", "type": "str" }, { "name": "volume", "value": "0.1", "type": "num" }, { "name": "TTS_message", "value": "{{payload.event.response_info}}", "type": "str" } ], "x": 510, "y": 260, "wires": [] }, { "id": "303b49a5.5c0496", "type": "api-call-service", "z": "780eae3d.9eca9", "name": "Trigger alarm", "server": "3bebce79.1e0962", "version": 1, "debugenabled": false, "service_domain": "alarm_control_panel", "service": "alarm_trigger", "entityId": "alarm_control_panel.alarm", "data": "", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 520, "y": 160, "wires": [ [] ] }, { "id": "e2399287.32471", "type": "api-call-service", "z": "780eae3d.9eca9", "name": "Disable alarm", "server": "3bebce79.1e0962", "version": 1, "debugenabled": false, "service_domain": "alarm_control_panel", "service": "alarm_disarm", "entityId": "alarm_control_panel.alarm", "data": "", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 530, "y": 210, "wires": [ [] ] }, { "id": "3bebce79.1e0962", "type": "server", "name": "Home Assistant", "addon": true } ]