dykandDK

HA - NR - Alarm example

Jan 30th, 2021 (edited)
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 31.21 KB | None | 0 0
  1. [
  2.     {
  3.         "id": "2f9ce9ec.85a026",
  4.         "type": "tab",
  5.         "label": "Alarm (TEST)",
  6.         "disabled": false,
  7.         "info": "## **Flow for alarm automations**\n**By Anders Lukic**\n\n---\n<br>\n\n---\n\n### **Purpose and functionality**\n\n---\n\n\nThis flow include automations that:\n\n - Sends an actionable notification if doors or windows are opened when nobody is home\n - Ability to trigger alarm via notification \n - Ability to play TTS message via notification\n - Plays alarm sound on SONOS speakers and blinks light red when alarm is triggered\n - Stop alarm sound and light blink when alarm is disabled\n \n---\n### **Requirements**\n---\nThis flow requires the following additional configuration to work:\n\n * Definition of IOS push categories for actionable notification\n * Definition of group with persons to track home/away status for"
  8.     },
  9.     {
  10.         "id": "77832b55.c034f4",
  11.         "type": "trigger-state",
  12.         "z": "2f9ce9ec.85a026",
  13.         "name": "Door or window is opened when nobody is home?",
  14.         "server": "3bebce79.1e0962",
  15.         "exposeToHomeAssistant": false,
  16.         "haConfig": [
  17.             {
  18.                 "property": "name",
  19.                 "value": ""
  20.             },
  21.             {
  22.                 "property": "icon",
  23.                 "value": ""
  24.             }
  25.         ],
  26.         "entityid": "binary_sensor.openclose",
  27.         "entityidfiltertype": "substring",
  28.         "debugenabled": false,
  29.         "constraints": [
  30.             {
  31.                 "targetType": "this_entity",
  32.                 "targetValue": "",
  33.                 "propertyType": "property",
  34.                 "comparatorType": "is",
  35.                 "comparatorValueDatatype": "str",
  36.                 "comparatorValue": "opening",
  37.                 "propertyValue": "new_state.attributes.device_class"
  38.             },
  39.             {
  40.                 "targetType": "this_entity",
  41.                 "targetValue": "",
  42.                 "propertyType": "current_state",
  43.                 "comparatorType": "is",
  44.                 "comparatorValueDatatype": "str",
  45.                 "comparatorValue": "on",
  46.                 "propertyValue": "new_state.state"
  47.             },
  48.             {
  49.                 "targetType": "entity_id",
  50.                 "targetValue": "group.alle_personer",
  51.                 "propertyType": "current_state",
  52.                 "comparatorType": "is",
  53.                 "comparatorValueDatatype": "str",
  54.                 "comparatorValue": "not_home",
  55.                 "propertyValue": "new_state.state"
  56.             }
  57.         ],
  58.         "outputs": 2,
  59.         "customoutputs": [],
  60.         "outputinitially": false,
  61.         "state_type": "str",
  62.         "x": 210,
  63.         "y": 80,
  64.         "wires": [
  65.             [
  66.                 "26dce690.260d3a"
  67.             ],
  68.             []
  69.         ]
  70.     },
  71.     {
  72.         "id": "16f98877.8b8418",
  73.         "type": "api-call-service",
  74.         "z": "2f9ce9ec.85a026",
  75.         "name": "Send critical notification",
  76.         "server": "3bebce79.1e0962",
  77.         "version": 1,
  78.         "debugenabled": true,
  79.         "service_domain": "notify",
  80.         "service": "mobile_app_anders_iphone",
  81.         "entityId": "",
  82.         "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},\"attachment\":{\"content-type\":\"jpeg\"},\"entity_id\":\"camera.mycamera\"}}",
  83.         "dataType": "json",
  84.         "mergecontext": "",
  85.         "output_location": "",
  86.         "output_location_type": "none",
  87.         "mustacheAltTags": false,
  88.         "x": 1130,
  89.         "y": 80,
  90.         "wires": [
  91.             []
  92.         ]
  93.     },
  94.     {
  95.         "id": "26dce690.260d3a",
  96.         "type": "ha-get-entities",
  97.         "z": "2f9ce9ec.85a026",
  98.         "server": "3bebce79.1e0962",
  99.         "name": "Get all open doors/windows",
  100.         "rules": [
  101.             {
  102.                 "property": "state",
  103.                 "logic": "is",
  104.                 "value": "on",
  105.                 "valueType": "str"
  106.             },
  107.             {
  108.                 "property": "attributes.device_class",
  109.                 "logic": "is",
  110.                 "value": "opening",
  111.                 "valueType": "str"
  112.             },
  113.             {
  114.                 "property": "entity_id",
  115.                 "logic": "starts_with",
  116.                 "value": "binary_sensor.openclose",
  117.                 "valueType": "str"
  118.             }
  119.         ],
  120.         "output_type": "split",
  121.         "output_empty_results": false,
  122.         "output_location_type": "msg",
  123.         "output_location": "payload",
  124.         "output_results_count": 1,
  125.         "x": 540,
  126.         "y": 80,
  127.         "wires": [
  128.             [
  129.                 "9447d949.311778"
  130.             ]
  131.         ]
  132.     },
  133.     {
  134.         "id": "9447d949.311778",
  135.         "type": "template",
  136.         "z": "2f9ce9ec.85a026",
  137.         "name": "Entity names",
  138.         "field": "payload",
  139.         "fieldType": "msg",
  140.         "format": "handlebars",
  141.         "syntax": "mustache",
  142.         "template": "{{payload.attributes.friendly_name}}",
  143.         "output": "str",
  144.         "x": 750,
  145.         "y": 80,
  146.         "wires": [
  147.             [
  148.                 "cbe4acf3.33b"
  149.             ]
  150.         ]
  151.     },
  152.     {
  153.         "id": "cbe4acf3.33b",
  154.         "type": "join",
  155.         "z": "2f9ce9ec.85a026",
  156.         "name": "Combine names",
  157.         "mode": "custom",
  158.         "build": "string",
  159.         "property": "payload",
  160.         "propertyType": "msg",
  161.         "key": "topic",
  162.         "joiner": "[92,110]",
  163.         "joinerType": "bin",
  164.         "accumulate": false,
  165.         "timeout": "",
  166.         "count": "",
  167.         "reduceRight": false,
  168.         "reduceExp": "",
  169.         "reduceInit": "",
  170.         "reduceInitType": "",
  171.         "reduceFixup": "",
  172.         "x": 920,
  173.         "y": 80,
  174.         "wires": [
  175.             [
  176.                 "16f98877.8b8418"
  177.             ]
  178.         ]
  179.     },
  180.     {
  181.         "id": "6a1bfc6c.073064",
  182.         "type": "comment",
  183.         "z": "2f9ce9ec.85a026",
  184.         "name": "Send actionable notification if doors and windows are opened when nobody is home",
  185.         "info": "",
  186.         "x": 310,
  187.         "y": 40,
  188.         "wires": []
  189.     },
  190.     {
  191.         "id": "ffea8cbc.2b2ef",
  192.         "type": "server-events",
  193.         "z": "2f9ce9ec.85a026",
  194.         "name": "IOS Action?",
  195.         "server": "3bebce79.1e0962",
  196.         "event_type": "ios.notification_action_fired",
  197.         "exposeToHomeAssistant": false,
  198.         "haConfig": [
  199.             {
  200.                 "property": "name",
  201.                 "value": ""
  202.             },
  203.             {
  204.                 "property": "icon",
  205.                 "value": ""
  206.             }
  207.         ],
  208.         "x": 90,
  209.         "y": 190,
  210.         "wires": [
  211.             [
  212.                 "28ccc57b.53320a"
  213.             ]
  214.         ]
  215.     },
  216.     {
  217.         "id": "28ccc57b.53320a",
  218.         "type": "switch",
  219.         "z": "2f9ce9ec.85a026",
  220.         "name": "Resonse to alert?",
  221.         "property": "payload.event.actionName",
  222.         "propertyType": "msg",
  223.         "rules": [
  224.             {
  225.                 "t": "eq",
  226.                 "v": "START_ALARM",
  227.                 "vt": "str"
  228.             },
  229.             {
  230.                 "t": "eq",
  231.                 "v": "STOP_ALARM",
  232.                 "vt": "str"
  233.             },
  234.             {
  235.                 "t": "eq",
  236.                 "v": "NOTIFY_TTS",
  237.                 "vt": "str"
  238.             }
  239.         ],
  240.         "checkall": "false",
  241.         "repair": false,
  242.         "outputs": 3,
  243.         "x": 270,
  244.         "y": 190,
  245.         "wires": [
  246.             [
  247.                 "490a46f8.838258"
  248.             ],
  249.             [
  250.                 "97b6a00a.3cb57"
  251.             ],
  252.             [
  253.                 "94155e86.d2e45",
  254.                 "c9a6a399.68411",
  255.                 "490a46f8.838258"
  256.             ]
  257.         ],
  258.         "outputLabels": [
  259.             "Remind me later",
  260.             "Postpone cleaning",
  261.             "Clean selected rooms only"
  262.         ]
  263.     },
  264.     {
  265.         "id": "94155e86.d2e45",
  266.         "type": "debug",
  267.         "z": "2f9ce9ec.85a026",
  268.         "name": "",
  269.         "active": true,
  270.         "tosidebar": true,
  271.         "console": false,
  272.         "tostatus": false,
  273.         "complete": "payload.event.response_info",
  274.         "targetType": "msg",
  275.         "statusVal": "",
  276.         "statusType": "auto",
  277.         "x": 580,
  278.         "y": 290,
  279.         "wires": []
  280.     },
  281.     {
  282.         "id": "e8ba80a8.ddcfb",
  283.         "type": "inject",
  284.         "z": "2f9ce9ec.85a026",
  285.         "name": "Test notification",
  286.         "props": [
  287.             {
  288.                 "p": "payload"
  289.             }
  290.         ],
  291.         "repeat": "",
  292.         "crontab": "",
  293.         "once": false,
  294.         "onceDelay": 0.1,
  295.         "topic": "",
  296.         "payload": "test vindue",
  297.         "payloadType": "str",
  298.         "x": 920,
  299.         "y": 130,
  300.         "wires": [
  301.             [
  302.                 "16f98877.8b8418"
  303.             ]
  304.         ]
  305.     },
  306.     {
  307.         "id": "da56994e.189b78",
  308.         "type": "inject",
  309.         "z": "2f9ce9ec.85a026",
  310.         "name": "Test TTS",
  311.         "props": [
  312.             {
  313.                 "p": "payload.event.response_info",
  314.                 "v": "Test af alarm",
  315.                 "vt": "str"
  316.             }
  317.         ],
  318.         "repeat": "",
  319.         "crontab": "",
  320.         "once": false,
  321.         "onceDelay": 0.1,
  322.         "topic": "",
  323.         "payloadType": "str",
  324.         "x": 300,
  325.         "y": 240,
  326.         "wires": [
  327.             [
  328.                 "c9a6a399.68411"
  329.             ]
  330.         ]
  331.     },
  332.     {
  333.         "id": "490a46f8.838258",
  334.         "type": "api-call-service",
  335.         "z": "2f9ce9ec.85a026",
  336.         "name": "Trigger alarm",
  337.         "server": "3bebce79.1e0962",
  338.         "version": 1,
  339.         "debugenabled": false,
  340.         "service_domain": "alarm_control_panel",
  341.         "service": "alarm_trigger",
  342.         "entityId": "alarm_control_panel.alarm",
  343.         "data": "",
  344.         "dataType": "json",
  345.         "mergecontext": "",
  346.         "output_location": "",
  347.         "output_location_type": "none",
  348.         "mustacheAltTags": false,
  349.         "x": 510,
  350.         "y": 140,
  351.         "wires": [
  352.             []
  353.         ]
  354.     },
  355.     {
  356.         "id": "97b6a00a.3cb57",
  357.         "type": "api-call-service",
  358.         "z": "2f9ce9ec.85a026",
  359.         "name": "Disable alarm",
  360.         "server": "3bebce79.1e0962",
  361.         "version": 1,
  362.         "debugenabled": false,
  363.         "service_domain": "alarm_control_panel",
  364.         "service": "alarm_disarm",
  365.         "entityId": "alarm_control_panel.alarm",
  366.         "data": "",
  367.         "dataType": "json",
  368.         "mergecontext": "",
  369.         "output_location": "",
  370.         "output_location_type": "none",
  371.         "mustacheAltTags": false,
  372.         "x": 520,
  373.         "y": 190,
  374.         "wires": [
  375.             []
  376.         ]
  377.     },
  378.     {
  379.         "id": "840f0cb5.e2fb5",
  380.         "type": "trigger-state",
  381.         "z": "2f9ce9ec.85a026",
  382.         "name": "Alarm triggered",
  383.         "server": "3bebce79.1e0962",
  384.         "exposeToHomeAssistant": false,
  385.         "haConfig": [
  386.             {
  387.                 "property": "name",
  388.                 "value": ""
  389.             },
  390.             {
  391.                 "property": "icon",
  392.                 "value": ""
  393.             }
  394.         ],
  395.         "entityid": "alarm_control_panel.alarm",
  396.         "entityidfiltertype": "exact",
  397.         "debugenabled": false,
  398.         "constraints": [
  399.             {
  400.                 "targetType": "this_entity",
  401.                 "targetValue": "",
  402.                 "propertyType": "current_state",
  403.                 "comparatorType": "is",
  404.                 "comparatorValueDatatype": "str",
  405.                 "comparatorValue": "triggered",
  406.                 "propertyValue": "new_state.state"
  407.             }
  408.         ],
  409.         "outputs": 2,
  410.         "customoutputs": [],
  411.         "outputinitially": false,
  412.         "state_type": "str",
  413.         "x": 100,
  414.         "y": 370,
  415.         "wires": [
  416.             [
  417.                 "a0335306.d4f64",
  418.                 "a210e8b1.4e5f08"
  419.             ],
  420.             [
  421.                 "a210e8b1.4e5f08"
  422.             ]
  423.         ]
  424.     },
  425.     {
  426.         "id": "cb84e7b0.af00f8",
  427.         "type": "api-call-service",
  428.         "z": "2f9ce9ec.85a026",
  429.         "name": "Snapshot",
  430.         "server": "3bebce79.1e0962",
  431.         "version": 1,
  432.         "debugenabled": false,
  433.         "service_domain": "sonos",
  434.         "service": "snapshot",
  435.         "entityId": "{{ sonos_data.sonos_entity }}",
  436.         "data": "",
  437.         "dataType": "json",
  438.         "mergecontext": "",
  439.         "output_location": "",
  440.         "output_location_type": "none",
  441.         "mustacheAltTags": false,
  442.         "x": 680,
  443.         "y": 240,
  444.         "wires": [
  445.             [
  446.                 "ee3feb43.7a0f78"
  447.             ]
  448.         ]
  449.     },
  450.     {
  451.         "id": "ee3feb43.7a0f78",
  452.         "type": "api-call-service",
  453.         "z": "2f9ce9ec.85a026",
  454.         "name": "Unjoin",
  455.         "server": "3bebce79.1e0962",
  456.         "version": 1,
  457.         "debugenabled": false,
  458.         "service_domain": "sonos",
  459.         "service": "unjoin",
  460.         "entityId": "{{ sonos_data.sonos_entity }}",
  461.         "data": "",
  462.         "dataType": "json",
  463.         "mergecontext": "",
  464.         "output_location": "",
  465.         "output_location_type": "none",
  466.         "mustacheAltTags": false,
  467.         "x": 810,
  468.         "y": 240,
  469.         "wires": [
  470.             [
  471.                 "9976c37a.02441"
  472.             ]
  473.         ]
  474.     },
  475.     {
  476.         "id": "9976c37a.02441",
  477.         "type": "api-call-service",
  478.         "z": "2f9ce9ec.85a026",
  479.         "name": "Volume",
  480.         "server": "3bebce79.1e0962",
  481.         "version": 1,
  482.         "debugenabled": false,
  483.         "service_domain": "media_player",
  484.         "service": "volume_set",
  485.         "entityId": "{{ sonos_data.sonos_entity }}",
  486.         "data": "{\"volume_level\":\"{{ sonos_data.volume }}\"}",
  487.         "dataType": "json",
  488.         "mergecontext": "",
  489.         "output_location": "",
  490.         "output_location_type": "none",
  491.         "mustacheAltTags": false,
  492.         "x": 940,
  493.         "y": 240,
  494.         "wires": [
  495.             [
  496.                 "f6cddf03.12cb9"
  497.             ]
  498.         ]
  499.     },
  500.     {
  501.         "id": "f6cddf03.12cb9",
  502.         "type": "api-call-service",
  503.         "z": "2f9ce9ec.85a026",
  504.         "name": "TTS",
  505.         "server": "3bebce79.1e0962",
  506.         "version": 1,
  507.         "debugenabled": false,
  508.         "service_domain": "tts",
  509.         "service": "google_translate_say",
  510.         "entityId": "{{ sonos_data.sonos_entity }}",
  511.         "data": "{\"message\":\"{{{sonos_data.message}}}\",\"language\":\"da\"}",
  512.         "dataType": "json",
  513.         "mergecontext": "",
  514.         "output_location": "",
  515.         "output_location_type": "none",
  516.         "mustacheAltTags": false,
  517.         "x": 1070,
  518.         "y": 240,
  519.         "wires": [
  520.             [
  521.                 "eaaf75e7.fc5368"
  522.             ]
  523.         ]
  524.     },
  525.     {
  526.         "id": "ef912700.648808",
  527.         "type": "api-call-service",
  528.         "z": "2f9ce9ec.85a026",
  529.         "name": "Restore",
  530.         "server": "3bebce79.1e0962",
  531.         "version": 1,
  532.         "debugenabled": false,
  533.         "service_domain": "sonos",
  534.         "service": "restore",
  535.         "entityId": "{{ sonos_data.sonos_entity }}",
  536.         "data": "",
  537.         "dataType": "json",
  538.         "mergecontext": "",
  539.         "output_location": "",
  540.         "output_location_type": "none",
  541.         "mustacheAltTags": false,
  542.         "x": 1320,
  543.         "y": 240,
  544.         "wires": [
  545.             []
  546.         ]
  547.     },
  548.     {
  549.         "id": "eaaf75e7.fc5368",
  550.         "type": "delay",
  551.         "z": "2f9ce9ec.85a026",
  552.         "name": "Delay",
  553.         "pauseType": "delayv",
  554.         "timeout": "10",
  555.         "timeoutUnits": "seconds",
  556.         "rate": "1",
  557.         "nbRateUnits": "1",
  558.         "rateUnits": "second",
  559.         "randomFirst": "1",
  560.         "randomLast": "5",
  561.         "randomUnits": "seconds",
  562.         "drop": false,
  563.         "x": 1190,
  564.         "y": 240,
  565.         "wires": [
  566.             [
  567.                 "ef912700.648808"
  568.             ]
  569.         ]
  570.     },
  571.     {
  572.         "id": "c9a6a399.68411",
  573.         "type": "template",
  574.         "z": "2f9ce9ec.85a026",
  575.         "name": "TTS variables",
  576.         "field": "sonos_data",
  577.         "fieldType": "msg",
  578.         "format": "json",
  579.         "syntax": "mustache",
  580.         "template": "{\n    \"sonos_entity\": \"media_player.kontor\",\n    \"volume\": \"0.5\",\n    \"message\": \"{{payload.event.response_info}}\"\n}",
  581.         "output": "json",
  582.         "x": 520,
  583.         "y": 240,
  584.         "wires": [
  585.             [
  586.                 "cb84e7b0.af00f8"
  587.             ]
  588.         ]
  589.     },
  590.     {
  591.         "id": "a0335306.d4f64",
  592.         "type": "template",
  593.         "z": "2f9ce9ec.85a026",
  594.         "name": "Alarm variables",
  595.         "field": "sonos_data",
  596.         "fieldType": "msg",
  597.         "format": "json",
  598.         "syntax": "mustache",
  599.         "template": "{\n    \"sonos_entity\": \"media_player.kontor\",\n    \"volume\": \"0.5\",\n    \"filename\": \"https://[myHAURL]/local/assets/sound/alarm.mp3\"\n}",
  600.         "output": "json",
  601.         "x": 300,
  602.         "y": 370,
  603.         "wires": [
  604.             [
  605.                 "6839d122.93169"
  606.             ]
  607.         ]
  608.     },
  609.     {
  610.         "id": "58f75663.6c2cd8",
  611.         "type": "api-call-service",
  612.         "z": "2f9ce9ec.85a026",
  613.         "name": "Alarm",
  614.         "server": "3bebce79.1e0962",
  615.         "version": 1,
  616.         "debugenabled": false,
  617.         "service_domain": "media_player",
  618.         "service": "play_media",
  619.         "entityId": "{{ sonos_data.sonos_entity }}",
  620.         "data": "{\"media_content_id\":\"{{{sonos_data.filename}}}\",\"media_content_type\":\"music\"}",
  621.         "dataType": "json",
  622.         "mergecontext": "",
  623.         "output_location": "",
  624.         "output_location_type": "none",
  625.         "mustacheAltTags": false,
  626.         "x": 770,
  627.         "y": 370,
  628.         "wires": [
  629.             []
  630.         ]
  631.     },
  632.     {
  633.         "id": "6839d122.93169",
  634.         "type": "api-call-service",
  635.         "z": "2f9ce9ec.85a026",
  636.         "name": "Volume",
  637.         "server": "3bebce79.1e0962",
  638.         "version": 1,
  639.         "debugenabled": false,
  640.         "service_domain": "media_player",
  641.         "service": "volume_set",
  642.         "entityId": "{{ sonos_data.sonos_entity }}",
  643.         "data": "{\"volume_level\":\"{{ sonos_data.volume }}\"}",
  644.         "dataType": "json",
  645.         "mergecontext": "",
  646.         "output_location": "",
  647.         "output_location_type": "none",
  648.         "mustacheAltTags": false,
  649.         "x": 470,
  650.         "y": 370,
  651.         "wires": [
  652.             [
  653.                 "650f90ac.1d0f9",
  654.                 "c54cffa8.0c726"
  655.             ]
  656.         ]
  657.     },
  658.     {
  659.         "id": "650f90ac.1d0f9",
  660.         "type": "api-call-service",
  661.         "z": "2f9ce9ec.85a026",
  662.         "name": "Repeat",
  663.         "server": "3bebce79.1e0962",
  664.         "version": 1,
  665.         "debugenabled": false,
  666.         "service_domain": "media_player",
  667.         "service": "repeat_set",
  668.         "entityId": "{{ sonos_data.sonos_entity }}",
  669.         "data": "{\"repeat\":\"one\"}",
  670.         "dataType": "json",
  671.         "mergecontext": "",
  672.         "output_location": "",
  673.         "output_location_type": "none",
  674.         "mustacheAltTags": false,
  675.         "x": 630,
  676.         "y": 370,
  677.         "wires": [
  678.             [
  679.                 "58f75663.6c2cd8"
  680.             ]
  681.         ]
  682.     },
  683.     {
  684.         "id": "52fcd0c0.42329",
  685.         "type": "api-call-service",
  686.         "z": "2f9ce9ec.85a026",
  687.         "name": "Trigger alarm",
  688.         "server": "3bebce79.1e0962",
  689.         "version": 1,
  690.         "debugenabled": false,
  691.         "service_domain": "alarm_control_panel",
  692.         "service": "alarm_trigger",
  693.         "entityId": "alarm_control_panel.alarm",
  694.         "data": "",
  695.         "dataType": "json",
  696.         "mergecontext": "",
  697.         "output_location": "",
  698.         "output_location_type": "none",
  699.         "mustacheAltTags": false,
  700.         "x": 310,
  701.         "y": 730,
  702.         "wires": [
  703.             []
  704.         ]
  705.     },
  706.     {
  707.         "id": "f10f278e.07e9b8",
  708.         "type": "inject",
  709.         "z": "2f9ce9ec.85a026",
  710.         "name": "Trigger alarm",
  711.         "props": [
  712.             {
  713.                 "p": "payload.event.response_info",
  714.                 "v": "Test af alarm",
  715.                 "vt": "str"
  716.             }
  717.         ],
  718.         "repeat": "",
  719.         "crontab": "",
  720.         "once": false,
  721.         "onceDelay": 0.1,
  722.         "topic": "",
  723.         "x": 120,
  724.         "y": 730,
  725.         "wires": [
  726.             [
  727.                 "52fcd0c0.42329"
  728.             ]
  729.         ]
  730.     },
  731.     {
  732.         "id": "bec6943a.ab9ef8",
  733.         "type": "api-call-service",
  734.         "z": "2f9ce9ec.85a026",
  735.         "name": "Disable alarm",
  736.         "server": "3bebce79.1e0962",
  737.         "version": 1,
  738.         "debugenabled": false,
  739.         "service_domain": "alarm_control_panel",
  740.         "service": "alarm_disarm",
  741.         "entityId": "alarm_control_panel.alarm",
  742.         "data": "",
  743.         "dataType": "json",
  744.         "mergecontext": "",
  745.         "output_location": "",
  746.         "output_location_type": "none",
  747.         "mustacheAltTags": false,
  748.         "x": 320,
  749.         "y": 780,
  750.         "wires": [
  751.             []
  752.         ]
  753.     },
  754.     {
  755.         "id": "f38e5778.9bf7a8",
  756.         "type": "inject",
  757.         "z": "2f9ce9ec.85a026",
  758.         "name": "Disable alarm",
  759.         "props": [
  760.             {
  761.                 "p": "payload.event.response_info",
  762.                 "v": "Test af alarm",
  763.                 "vt": "str"
  764.             }
  765.         ],
  766.         "repeat": "",
  767.         "crontab": "",
  768.         "once": false,
  769.         "onceDelay": 0.1,
  770.         "topic": "",
  771.         "payloadType": "str",
  772.         "x": 120,
  773.         "y": 780,
  774.         "wires": [
  775.             [
  776.                 "bec6943a.ab9ef8"
  777.             ]
  778.         ]
  779.     },
  780.     {
  781.         "id": "7d91e862.348988",
  782.         "type": "comment",
  783.         "z": "2f9ce9ec.85a026",
  784.         "name": "Alarm triggered",
  785.         "info": "",
  786.         "x": 100,
  787.         "y": 330,
  788.         "wires": []
  789.     },
  790.     {
  791.         "id": "67ba49d3.e3a968",
  792.         "type": "template",
  793.         "z": "2f9ce9ec.85a026",
  794.         "name": "Disable variables",
  795.         "field": "sonos_data",
  796.         "fieldType": "msg",
  797.         "format": "json",
  798.         "syntax": "mustache",
  799.         "template": "{\n    \"sonos_entity\": \"media_player.kontor\",\n    \"volume\": \"0.4\"\n}",
  800.         "output": "json",
  801.         "x": 330,
  802.         "y": 610,
  803.         "wires": [
  804.             [
  805.                 "d7e346ff.942a58",
  806.                 "21dc9f2d.ddd4"
  807.             ]
  808.         ]
  809.     },
  810.     {
  811.         "id": "30dd7656.bcd85a",
  812.         "type": "trigger-state",
  813.         "z": "2f9ce9ec.85a026",
  814.         "name": "Alarm disabled",
  815.         "server": "3bebce79.1e0962",
  816.         "exposeToHomeAssistant": false,
  817.         "haConfig": [
  818.             {
  819.                 "property": "name",
  820.                 "value": ""
  821.             },
  822.             {
  823.                 "property": "icon",
  824.                 "value": ""
  825.             }
  826.         ],
  827.         "entityid": "alarm_control_panel.alarm",
  828.         "entityidfiltertype": "exact",
  829.         "debugenabled": false,
  830.         "constraints": [
  831.             {
  832.                 "targetType": "this_entity",
  833.                 "targetValue": "",
  834.                 "propertyType": "previous_state",
  835.                 "comparatorType": "is",
  836.                 "comparatorValueDatatype": "str",
  837.                 "comparatorValue": "triggered",
  838.                 "propertyValue": "old_state.state"
  839.             }
  840.         ],
  841.         "outputs": 2,
  842.         "customoutputs": [],
  843.         "outputinitially": false,
  844.         "state_type": "str",
  845.         "x": 100,
  846.         "y": 610,
  847.         "wires": [
  848.             [
  849.                 "67ba49d3.e3a968"
  850.             ],
  851.             []
  852.         ]
  853.     },
  854.     {
  855.         "id": "597e8bab.8ff4d4",
  856.         "type": "api-call-service",
  857.         "z": "2f9ce9ec.85a026",
  858.         "name": "Volume",
  859.         "server": "3bebce79.1e0962",
  860.         "version": 1,
  861.         "debugenabled": false,
  862.         "service_domain": "media_player",
  863.         "service": "volume_set",
  864.         "entityId": "{{ sonos_data.sonos_entity }}",
  865.         "data": "{\"volume_level\":\"{{ sonos_data.volume }}\"}",
  866.         "dataType": "json",
  867.         "mergecontext": "",
  868.         "output_location": "",
  869.         "output_location_type": "none",
  870.         "mustacheAltTags": false,
  871.         "x": 710,
  872.         "y": 610,
  873.         "wires": [
  874.             []
  875.         ]
  876.     },
  877.     {
  878.         "id": "d7e346ff.942a58",
  879.         "type": "api-call-service",
  880.         "z": "2f9ce9ec.85a026",
  881.         "name": "Stop Alarm",
  882.         "server": "3bebce79.1e0962",
  883.         "version": 1,
  884.         "debugenabled": false,
  885.         "service_domain": "media_player",
  886.         "service": "media_stop",
  887.         "entityId": "{{ sonos_data.sonos_entity }}",
  888.         "data": "",
  889.         "dataType": "json",
  890.         "mergecontext": "",
  891.         "output_location": "",
  892.         "output_location_type": "none",
  893.         "mustacheAltTags": false,
  894.         "x": 560,
  895.         "y": 610,
  896.         "wires": [
  897.             [
  898.                 "597e8bab.8ff4d4"
  899.             ]
  900.         ]
  901.     },
  902.     {
  903.         "id": "9195563e.8022c8",
  904.         "type": "comment",
  905.         "z": "2f9ce9ec.85a026",
  906.         "name": "Alarm disabled after being triggered",
  907.         "info": "",
  908.         "x": 160,
  909.         "y": 570,
  910.         "wires": []
  911.     },
  912.     {
  913.         "id": "6bfdf45b.ab910c",
  914.         "type": "comment",
  915.         "z": "2f9ce9ec.85a026",
  916.         "name": "TEST: Trigger and disable alarm",
  917.         "info": "",
  918.         "x": 150,
  919.         "y": 690,
  920.         "wires": []
  921.     },
  922.     {
  923.         "id": "a210e8b1.4e5f08",
  924.         "type": "debug",
  925.         "z": "2f9ce9ec.85a026",
  926.         "name": "",
  927.         "active": true,
  928.         "tosidebar": true,
  929.         "console": false,
  930.         "tostatus": false,
  931.         "complete": "false",
  932.         "statusVal": "",
  933.         "statusType": "auto",
  934.         "x": 290,
  935.         "y": 420,
  936.         "wires": []
  937.     },
  938.     {
  939.         "id": "dccd982a.64f298",
  940.         "type": "api-call-service",
  941.         "z": "2f9ce9ec.85a026",
  942.         "name": "Light blink",
  943.         "server": "3bebce79.1e0962",
  944.         "version": 1,
  945.         "debugenabled": false,
  946.         "service_domain": "light",
  947.         "service": "turn_on",
  948.         "entityId": "light.kokken",
  949.         "data": "{\"flash\":\"short\",\"transition\":0,\"rgb_color\":[252,3,3]}",
  950.         "dataType": "json",
  951.         "mergecontext": "",
  952.         "output_location": "",
  953.         "output_location_type": "none",
  954.         "mustacheAltTags": false,
  955.         "x": 1070,
  956.         "y": 470,
  957.         "wires": [
  958.             []
  959.         ]
  960.     },
  961.     {
  962.         "id": "8b329bec.5475b8",
  963.         "type": "inject",
  964.         "z": "2f9ce9ec.85a026",
  965.         "name": "Test blink",
  966.         "props": [],
  967.         "repeat": "",
  968.         "crontab": "",
  969.         "once": false,
  970.         "onceDelay": 0.1,
  971.         "topic": "",
  972.         "payloadType": "str",
  973.         "x": 470,
  974.         "y": 470,
  975.         "wires": [
  976.             [
  977.                 "c54cffa8.0c726"
  978.             ]
  979.         ]
  980.     },
  981.     {
  982.         "id": "644bc868.057528",
  983.         "type": "function",
  984.         "z": "2f9ce9ec.85a026",
  985.         "name": "loop",
  986.         "func": "// Loop function\n// Top output provides triger for next actions\n// Botton output should be connected to the input through a dealy\n// The msg.payload can consis one of actions: start, stop, toggle\n// Other content is ignored\n// On the outoput the msg.payload contains current loop state\n\ncontext.loop = context.loop || \"stop\";\ncontext.loops = context.loops || 0;\n\n//console.log(\"topic :\" + msg.topic);\n//console.log(\"loop  :\" + context.loop);\n//console.log(\"loops :\" + context.loops);\n//console.log(\"action:\" + msg.payload);\n\nswitch (msg.payload) {\n\tcase \"stop\":\n\t\tcontext.loops = context.loops + 1;\n\t\tmsg.payload = \"stopped\";\n\t\tcontext.loop = \"stop\";\n\t\treturn [msg,null];\n\tcase \"toggle\":\n\t\tif (context.loop == \"start\") {\n\t\t\tmsg.payload = \"stopped\";\n\t\t\tcontext.loop = \"stop\";\n\t\t\treturn [msg,null];\n\t\t} else {\n\t\t\tmsg.payload = \"started\";\n\t\t\tcontext.loop = \"loop\";\n\t\t\tcontext.loops = 1;\n\t\t\treturn [msg,msg];\n\t\t}\n\tcase \"start\":\n\t\tmsg.payload = \"started\";\n\t\tcontext.loop = \"loop\";\n\t\tcontext.loops = 1;\n\t\treturn [msg,msg];\n\tdefault:\n\t\tif (context.loop == \"loop\") {\n\t\t\tcontext.loops = context.loops + 1;\n\t\t\tmsg.payload = \"loop:\" + context.loops;\n\t\t\treturn [msg,msg];\n\t\t} else {\n\t\t\treturn [null,null]; \n\t\t}\n}",
  987.         "outputs": "2",
  988.         "noerr": 0,
  989.         "initialize": "",
  990.         "finalize": "",
  991.         "x": 900,
  992.         "y": 470,
  993.         "wires": [
  994.             [
  995.                 "dccd982a.64f298"
  996.             ],
  997.             [
  998.                 "72efe33b.ba9e3c"
  999.             ]
  1000.         ]
  1001.     },
  1002.     {
  1003.         "id": "72efe33b.ba9e3c",
  1004.         "type": "delay",
  1005.         "z": "2f9ce9ec.85a026",
  1006.         "name": "",
  1007.         "pauseType": "delay",
  1008.         "timeout": "2",
  1009.         "timeoutUnits": "seconds",
  1010.         "rate": "1",
  1011.         "nbRateUnits": "",
  1012.         "rateUnits": "second",
  1013.         "randomFirst": "1",
  1014.         "randomLast": "5",
  1015.         "randomUnits": "seconds",
  1016.         "drop": false,
  1017.         "x": 900,
  1018.         "y": 530,
  1019.         "wires": [
  1020.             [
  1021.                 "644bc868.057528"
  1022.             ]
  1023.         ]
  1024.     },
  1025.     {
  1026.         "id": "c54cffa8.0c726",
  1027.         "type": "change",
  1028.         "z": "2f9ce9ec.85a026",
  1029.         "name": "Start loop",
  1030.         "rules": [
  1031.             {
  1032.                 "t": "set",
  1033.                 "p": "payload",
  1034.                 "pt": "msg",
  1035.                 "to": "start",
  1036.                 "tot": "str"
  1037.             }
  1038.         ],
  1039.         "action": "",
  1040.         "property": "",
  1041.         "from": "",
  1042.         "to": "",
  1043.         "reg": false,
  1044.         "x": 660,
  1045.         "y": 470,
  1046.         "wires": [
  1047.             [
  1048.                 "644bc868.057528"
  1049.             ]
  1050.         ]
  1051.     },
  1052.     {
  1053.         "id": "21dc9f2d.ddd4",
  1054.         "type": "change",
  1055.         "z": "2f9ce9ec.85a026",
  1056.         "name": "Stop loop",
  1057.         "rules": [
  1058.             {
  1059.                 "t": "set",
  1060.                 "p": "payload",
  1061.                 "pt": "msg",
  1062.                 "to": "stop",
  1063.                 "tot": "str"
  1064.             }
  1065.         ],
  1066.         "action": "",
  1067.         "property": "",
  1068.         "from": "",
  1069.         "to": "",
  1070.         "reg": false,
  1071.         "x": 660,
  1072.         "y": 530,
  1073.         "wires": [
  1074.             [
  1075.                 "644bc868.057528"
  1076.             ]
  1077.         ]
  1078.     },
  1079.     {
  1080.         "id": "eb18f41f.26b4a8",
  1081.         "type": "inject",
  1082.         "z": "2f9ce9ec.85a026",
  1083.         "name": "Stop blink",
  1084.         "props": [],
  1085.         "repeat": "",
  1086.         "crontab": "",
  1087.         "once": false,
  1088.         "onceDelay": 0.1,
  1089.         "topic": "",
  1090.         "x": 470,
  1091.         "y": 530,
  1092.         "wires": [
  1093.             [
  1094.                 "21dc9f2d.ddd4"
  1095.             ]
  1096.         ]
  1097.     },
  1098.     {
  1099.         "id": "3bebce79.1e0962",
  1100.         "type": "server",
  1101.         "name": "Home Assistant",
  1102.         "addon": true
  1103.     }
  1104. ]
Add Comment
Please, Sign In to add comment