Advertisement
dykandDK

HA - NR - Alarm Notification Example

Jan 13th, 2021
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 17.67 KB | None | 0 0
  1. [
  2.     {
  3.         "id": "fdff74d6.e6bfe8",
  4.         "type": "subflow",
  5.         "name": "Sonos TTS",
  6.         "info": "",
  7.         "category": "",
  8.         "in": [
  9.             {
  10.                 "x": 40,
  11.                 "y": 80,
  12.                 "wires": [
  13.                     {
  14.                         "id": "7df8d0c8.1ebef"
  15.                     }
  16.                 ]
  17.             }
  18.         ],
  19.         "out": [],
  20.         "env": [
  21.             {
  22.                 "name": "sonos_entity",
  23.                 "type": "str",
  24.                 "value": "",
  25.                 "ui": {
  26.                     "icon": "font-awesome/fa-bullhorn",
  27.                     "label": {
  28.                         "en-US": "Entiy ID of Sonos entity"
  29.                     },
  30.                     "type": "input",
  31.                     "opts": {
  32.                         "types": [
  33.                             "str"
  34.                         ]
  35.                     }
  36.                 }
  37.             },
  38.             {
  39.                 "name": "volume",
  40.                 "type": "num",
  41.                 "value": "0.5",
  42.                 "ui": {
  43.                     "icon": "font-awesome/fa-dashboard",
  44.                     "label": {
  45.                         "en-US": "Volume (0.0-1.0)"
  46.                     },
  47.                     "type": "input",
  48.                     "opts": {
  49.                         "types": [
  50.                             "num"
  51.                         ]
  52.                     }
  53.                 }
  54.             },
  55.             {
  56.                 "name": "TTS_message",
  57.                 "type": "str",
  58.                 "value": "",
  59.                 "ui": {
  60.                     "icon": "font-awesome/fa-commenting",
  61.                     "label": {
  62.                         "en-US": "Message to say"
  63.                     },
  64.                     "type": "input",
  65.                     "opts": {
  66.                         "types": [
  67.                             "str",
  68.                             "json"
  69.                         ]
  70.                     }
  71.                 }
  72.             },
  73.             {
  74.                 "name": "delay_before_restore",
  75.                 "type": "num",
  76.                 "value": "5",
  77.                 "ui": {
  78.                     "icon": "font-awesome/fa-clock-o",
  79.                     "label": {
  80.                         "en-US": "Seconds to delay restore"
  81.                     },
  82.                     "type": "spinner",
  83.                     "opts": {
  84.                         "min": 0,
  85.                         "max": 60
  86.                     }
  87.                 }
  88.             }
  89.         ],
  90.         "color": "#DDAA99"
  91.     },
  92.     {
  93.         "id": "d433443d.eda488",
  94.         "type": "api-call-service",
  95.         "z": "fdff74d6.e6bfe8",
  96.         "name": "Snapshot",
  97.         "server": "3bebce79.1e0962",
  98.         "version": 1,
  99.         "debugenabled": false,
  100.         "service_domain": "sonos",
  101.         "service": "snapshot",
  102.         "entityId": "{{ sonos_data.sonos_entity }}",
  103.         "data": "",
  104.         "dataType": "json",
  105.         "mergecontext": "",
  106.         "output_location": "",
  107.         "output_location_type": "none",
  108.         "mustacheAltTags": false,
  109.         "x": 320,
  110.         "y": 80,
  111.         "wires": [
  112.             [
  113.                 "5f7736ee.16ae68"
  114.             ]
  115.         ]
  116.     },
  117.     {
  118.         "id": "5f7736ee.16ae68",
  119.         "type": "api-call-service",
  120.         "z": "fdff74d6.e6bfe8",
  121.         "name": "Unjoin",
  122.         "server": "3bebce79.1e0962",
  123.         "version": 1,
  124.         "debugenabled": false,
  125.         "service_domain": "sonos",
  126.         "service": "unjoin",
  127.         "entityId": "{{ sonos_data.sonos_entity }}",
  128.         "data": "",
  129.         "dataType": "json",
  130.         "mergecontext": "",
  131.         "output_location": "",
  132.         "output_location_type": "none",
  133.         "mustacheAltTags": false,
  134.         "x": 450,
  135.         "y": 80,
  136.         "wires": [
  137.             [
  138.                 "646231de.e7ab4"
  139.             ]
  140.         ]
  141.     },
  142.     {
  143.         "id": "646231de.e7ab4",
  144.         "type": "api-call-service",
  145.         "z": "fdff74d6.e6bfe8",
  146.         "name": "Volume",
  147.         "server": "3bebce79.1e0962",
  148.         "version": 1,
  149.         "debugenabled": false,
  150.         "service_domain": "media_player",
  151.         "service": "volume_set",
  152.         "entityId": "{{ sonos_data.sonos_entity }}",
  153.         "data": "{\"volume_level\":\"{{ sonos_data.volume }}\"}",
  154.         "dataType": "json",
  155.         "mergecontext": "",
  156.         "output_location": "",
  157.         "output_location_type": "none",
  158.         "mustacheAltTags": false,
  159.         "x": 580,
  160.         "y": 80,
  161.         "wires": [
  162.             [
  163.                 "5460a0df.97145"
  164.             ]
  165.         ]
  166.     },
  167.     {
  168.         "id": "5460a0df.97145",
  169.         "type": "api-call-service",
  170.         "z": "fdff74d6.e6bfe8",
  171.         "name": "TTS",
  172.         "server": "3bebce79.1e0962",
  173.         "version": 1,
  174.         "debugenabled": false,
  175.         "service_domain": "tts",
  176.         "service": "google_translate_say",
  177.         "entityId": "{{ sonos_data.sonos_entity }}",
  178.         "data": "{\"message\":\"{{{sonos_data.message}}}\",\"language\":\"da\"}",
  179.         "dataType": "json",
  180.         "mergecontext": "",
  181.         "output_location": "",
  182.         "output_location_type": "none",
  183.         "mustacheAltTags": false,
  184.         "x": 710,
  185.         "y": 80,
  186.         "wires": [
  187.             [
  188.                 "a3e3bd28.f6c1e"
  189.             ]
  190.         ]
  191.     },
  192.     {
  193.         "id": "4a5624f5.5f059c",
  194.         "type": "api-call-service",
  195.         "z": "fdff74d6.e6bfe8",
  196.         "name": "Restore",
  197.         "server": "3bebce79.1e0962",
  198.         "version": 1,
  199.         "debugenabled": false,
  200.         "service_domain": "sonos",
  201.         "service": "restore",
  202.         "entityId": "{{ sonos_data.sonos_entity }}",
  203.         "data": "",
  204.         "dataType": "json",
  205.         "mergecontext": "",
  206.         "output_location": "",
  207.         "output_location_type": "none",
  208.         "mustacheAltTags": false,
  209.         "x": 960,
  210.         "y": 80,
  211.         "wires": [
  212.             []
  213.         ]
  214.     },
  215.     {
  216.         "id": "7df8d0c8.1ebef",
  217.         "type": "change",
  218.         "z": "fdff74d6.e6bfe8",
  219.         "name": "Sonos variables",
  220.         "rules": [
  221.             {
  222.                 "t": "set",
  223.                 "p": "sonos_data.sonos_entity",
  224.                 "pt": "msg",
  225.                 "to": "sonos_entity",
  226.                 "tot": "env"
  227.             },
  228.             {
  229.                 "t": "set",
  230.                 "p": "sonos_data.volume",
  231.                 "pt": "msg",
  232.                 "to": "volume",
  233.                 "tot": "env"
  234.             },
  235.             {
  236.                 "t": "set",
  237.                 "p": "sonos_data.message",
  238.                 "pt": "msg",
  239.                 "to": "TTS_message",
  240.                 "tot": "env"
  241.             },
  242.             {
  243.                 "t": "set",
  244.                 "p": "delay",
  245.                 "pt": "msg",
  246.                 "to": "delay_before_restore",
  247.                 "tot": "env"
  248.             },
  249.             {
  250.                 "t": "set",
  251.                 "p": "delay",
  252.                 "pt": "msg",
  253.                 "to": "msg.delay*1000",
  254.                 "tot": "jsonata"
  255.             }
  256.         ],
  257.         "action": "",
  258.         "property": "",
  259.         "from": "",
  260.         "to": "",
  261.         "reg": false,
  262.         "x": 160,
  263.         "y": 80,
  264.         "wires": [
  265.             [
  266.                 "d433443d.eda488"
  267.             ]
  268.         ]
  269.     },
  270.     {
  271.         "id": "a3e3bd28.f6c1e",
  272.         "type": "delay",
  273.         "z": "fdff74d6.e6bfe8",
  274.         "name": "Delay",
  275.         "pauseType": "delayv",
  276.         "timeout": "1",
  277.         "timeoutUnits": "seconds",
  278.         "rate": "1",
  279.         "nbRateUnits": "1",
  280.         "rateUnits": "second",
  281.         "randomFirst": "1",
  282.         "randomLast": "5",
  283.         "randomUnits": "seconds",
  284.         "drop": false,
  285.         "x": 830,
  286.         "y": 80,
  287.         "wires": [
  288.             [
  289.                 "4a5624f5.5f059c"
  290.             ]
  291.         ]
  292.     },
  293.     {
  294.         "id": "780eae3d.9eca9",
  295.         "type": "tab",
  296.         "label": "Alarm flow",
  297.         "disabled": false,
  298.         "info": ""
  299.     },
  300.     {
  301.         "id": "a75a8352.76e9",
  302.         "type": "trigger-state",
  303.         "z": "780eae3d.9eca9",
  304.         "name": "Door or window is opened when nobody is home?",
  305.         "server": "3bebce79.1e0962",
  306.         "exposeToHomeAssistant": false,
  307.         "haConfig": [
  308.             {
  309.                 "property": "name",
  310.                 "value": ""
  311.             },
  312.             {
  313.                 "property": "icon",
  314.                 "value": ""
  315.             }
  316.         ],
  317.         "entityid": "binary_sensor.openclose",
  318.         "entityidfiltertype": "substring",
  319.         "debugenabled": false,
  320.         "constraints": [
  321.             {
  322.                 "targetType": "this_entity",
  323.                 "targetValue": "",
  324.                 "propertyType": "property",
  325.                 "comparatorType": "is",
  326.                 "comparatorValueDatatype": "str",
  327.                 "comparatorValue": "opening",
  328.                 "propertyValue": "new_state.attributes.device_class"
  329.             },
  330.             {
  331.                 "targetType": "this_entity",
  332.                 "targetValue": "",
  333.                 "propertyType": "current_state",
  334.                 "comparatorType": "is",
  335.                 "comparatorValueDatatype": "str",
  336.                 "comparatorValue": "on",
  337.                 "propertyValue": "new_state.state"
  338.             },
  339.             {
  340.                 "targetType": "entity_id",
  341.                 "targetValue": "group.alle_personer",
  342.                 "propertyType": "current_state",
  343.                 "comparatorType": "is",
  344.                 "comparatorValueDatatype": "str",
  345.                 "comparatorValue": "not_home",
  346.                 "propertyValue": "new_state.state"
  347.             }
  348.         ],
  349.         "outputs": 2,
  350.         "customoutputs": [],
  351.         "outputinitially": false,
  352.         "state_type": "str",
  353.         "x": 220,
  354.         "y": 90,
  355.         "wires": [
  356.             [
  357.                 "406040af.fdf9a"
  358.             ],
  359.             []
  360.         ]
  361.     },
  362.     {
  363.         "id": "b0a5e4e0.32a678",
  364.         "type": "api-call-service",
  365.         "z": "780eae3d.9eca9",
  366.         "name": "Send critical notification",
  367.         "server": "3bebce79.1e0962",
  368.         "version": 1,
  369.         "debugenabled": true,
  370.         "service_domain": "notify",
  371.         "service": "mobile_app_anders_iphone",
  372.         "entityId": "",
  373.         "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}}}",
  374.         "dataType": "json",
  375.         "mergecontext": "",
  376.         "output_location": "",
  377.         "output_location_type": "none",
  378.         "mustacheAltTags": false,
  379.         "x": 1140,
  380.         "y": 90,
  381.         "wires": [
  382.             []
  383.         ]
  384.     },
  385.     {
  386.         "id": "406040af.fdf9a",
  387.         "type": "ha-get-entities",
  388.         "z": "780eae3d.9eca9",
  389.         "server": "3bebce79.1e0962",
  390.         "name": "Get all open doors/windows",
  391.         "rules": [
  392.             {
  393.                 "property": "state",
  394.                 "logic": "is",
  395.                 "value": "on",
  396.                 "valueType": "str"
  397.             },
  398.             {
  399.                 "property": "attributes.device_class",
  400.                 "logic": "is",
  401.                 "value": "opening",
  402.                 "valueType": "str"
  403.             },
  404.             {
  405.                 "property": "entity_id",
  406.                 "logic": "starts_with",
  407.                 "value": "binary_sensor.openclose",
  408.                 "valueType": "str"
  409.             }
  410.         ],
  411.         "output_type": "split",
  412.         "output_empty_results": false,
  413.         "output_location_type": "msg",
  414.         "output_location": "payload",
  415.         "output_results_count": 1,
  416.         "x": 550,
  417.         "y": 90,
  418.         "wires": [
  419.             [
  420.                 "df631e5f.6e219"
  421.             ]
  422.         ]
  423.     },
  424.     {
  425.         "id": "df631e5f.6e219",
  426.         "type": "template",
  427.         "z": "780eae3d.9eca9",
  428.         "name": "Entity names",
  429.         "field": "payload",
  430.         "fieldType": "msg",
  431.         "format": "handlebars",
  432.         "syntax": "mustache",
  433.         "template": "{{payload.attributes.friendly_name}}",
  434.         "output": "str",
  435.         "x": 760,
  436.         "y": 90,
  437.         "wires": [
  438.             [
  439.                 "4b8c4da9.d32d84"
  440.             ]
  441.         ]
  442.     },
  443.     {
  444.         "id": "4b8c4da9.d32d84",
  445.         "type": "join",
  446.         "z": "780eae3d.9eca9",
  447.         "name": "Combine names",
  448.         "mode": "custom",
  449.         "build": "string",
  450.         "property": "payload",
  451.         "propertyType": "msg",
  452.         "key": "topic",
  453.         "joiner": "[92,110]",
  454.         "joinerType": "bin",
  455.         "accumulate": false,
  456.         "timeout": "",
  457.         "count": "",
  458.         "reduceRight": false,
  459.         "reduceExp": "",
  460.         "reduceInit": "",
  461.         "reduceInitType": "",
  462.         "reduceFixup": "",
  463.         "x": 930,
  464.         "y": 90,
  465.         "wires": [
  466.             [
  467.                 "b0a5e4e0.32a678"
  468.             ]
  469.         ]
  470.     },
  471.     {
  472.         "id": "b951aa5b.c415e8",
  473.         "type": "comment",
  474.         "z": "780eae3d.9eca9",
  475.         "name": "Send actionable notification if doors and windows are opened when nobody is home",
  476.         "info": "",
  477.         "x": 320,
  478.         "y": 50,
  479.         "wires": []
  480.     },
  481.     {
  482.         "id": "c2b5e861.0e37b8",
  483.         "type": "server-events",
  484.         "z": "780eae3d.9eca9",
  485.         "name": "IOS Action?",
  486.         "server": "3bebce79.1e0962",
  487.         "event_type": "ios.notification_action_fired",
  488.         "exposeToHomeAssistant": false,
  489.         "haConfig": [
  490.             {
  491.                 "property": "name",
  492.                 "value": ""
  493.             },
  494.             {
  495.                 "property": "icon",
  496.                 "value": ""
  497.             }
  498.         ],
  499.         "x": 100,
  500.         "y": 210,
  501.         "wires": [
  502.             [
  503.                 "aba3b9a0.e3e8f8"
  504.             ]
  505.         ]
  506.     },
  507.     {
  508.         "id": "aba3b9a0.e3e8f8",
  509.         "type": "switch",
  510.         "z": "780eae3d.9eca9",
  511.         "name": "Resonse to alert?",
  512.         "property": "payload.event.actionName",
  513.         "propertyType": "msg",
  514.         "rules": [
  515.             {
  516.                 "t": "eq",
  517.                 "v": "START_ALARM",
  518.                 "vt": "str"
  519.             },
  520.             {
  521.                 "t": "eq",
  522.                 "v": "STOP_ALARM",
  523.                 "vt": "str"
  524.             },
  525.             {
  526.                 "t": "eq",
  527.                 "v": "NOTIFY_TTS",
  528.                 "vt": "str"
  529.             }
  530.         ],
  531.         "checkall": "false",
  532.         "repair": false,
  533.         "outputs": 3,
  534.         "x": 280,
  535.         "y": 210,
  536.         "wires": [
  537.             [
  538.                 "303b49a5.5c0496"
  539.             ],
  540.             [
  541.                 "e2399287.32471"
  542.             ],
  543.             [
  544.                 "36b7bac0.0d07f6",
  545.                 "73f5ecea.3d2b34"
  546.             ]
  547.         ],
  548.         "outputLabels": [
  549.             "Remind me later",
  550.             "Postpone cleaning",
  551.             "Clean selected rooms only"
  552.         ]
  553.     },
  554.     {
  555.         "id": "36b7bac0.0d07f6",
  556.         "type": "debug",
  557.         "z": "780eae3d.9eca9",
  558.         "name": "",
  559.         "active": true,
  560.         "tosidebar": true,
  561.         "console": false,
  562.         "tostatus": false,
  563.         "complete": "payload.event.response_info",
  564.         "targetType": "msg",
  565.         "statusVal": "",
  566.         "statusType": "auto",
  567.         "x": 580,
  568.         "y": 320,
  569.         "wires": []
  570.     },
  571.     {
  572.         "id": "73f5ecea.3d2b34",
  573.         "type": "subflow:fdff74d6.e6bfe8",
  574.         "z": "780eae3d.9eca9",
  575.         "name": "Play TTS",
  576.         "env": [
  577.             {
  578.                 "name": "sonos_entity",
  579.                 "value": "media_player.kontor",
  580.                 "type": "str"
  581.             },
  582.             {
  583.                 "name": "volume",
  584.                 "value": "0.1",
  585.                 "type": "num"
  586.             },
  587.             {
  588.                 "name": "TTS_message",
  589.                 "value": "{{payload.event.response_info}}",
  590.                 "type": "str"
  591.             }
  592.         ],
  593.         "x": 510,
  594.         "y": 260,
  595.         "wires": []
  596.     },
  597.     {
  598.         "id": "303b49a5.5c0496",
  599.         "type": "api-call-service",
  600.         "z": "780eae3d.9eca9",
  601.         "name": "Trigger alarm",
  602.         "server": "3bebce79.1e0962",
  603.         "version": 1,
  604.         "debugenabled": false,
  605.         "service_domain": "alarm_control_panel",
  606.         "service": "alarm_trigger",
  607.         "entityId": "alarm_control_panel.alarm",
  608.         "data": "",
  609.         "dataType": "json",
  610.         "mergecontext": "",
  611.         "output_location": "",
  612.         "output_location_type": "none",
  613.         "mustacheAltTags": false,
  614.         "x": 520,
  615.         "y": 160,
  616.         "wires": [
  617.             []
  618.         ]
  619.     },
  620.     {
  621.         "id": "e2399287.32471",
  622.         "type": "api-call-service",
  623.         "z": "780eae3d.9eca9",
  624.         "name": "Disable alarm",
  625.         "server": "3bebce79.1e0962",
  626.         "version": 1,
  627.         "debugenabled": false,
  628.         "service_domain": "alarm_control_panel",
  629.         "service": "alarm_disarm",
  630.         "entityId": "alarm_control_panel.alarm",
  631.         "data": "",
  632.         "dataType": "json",
  633.         "mergecontext": "",
  634.         "output_location": "",
  635.         "output_location_type": "none",
  636.         "mustacheAltTags": false,
  637.         "x": 530,
  638.         "y": 210,
  639.         "wires": [
  640.             []
  641.         ]
  642.     },
  643.     {
  644.         "id": "3bebce79.1e0962",
  645.         "type": "server",
  646.         "name": "Home Assistant",
  647.         "addon": true
  648.     }
  649. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement