Advertisement
dykandDK

HA - NR - Low Battery Level Alert

Aug 3rd, 2020 (edited)
954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 5.51 KB | None | 0 0
  1. [
  2.     {
  3.         "id": "8ffd3e02.3f032",
  4.         "type": "tab",
  5.         "label": "Low battery notification",
  6.         "disabled": false,
  7.         "info": "## Flow for sending low battery notification\n**By Anders Lukic**\n\n---\n\nThis flow sends a notification once every day at 20.00 if one or more devices has a low battery (less than 30%)\n\nThe message will include names of the devices as well as the current battery level."
  8.     },
  9.     {
  10.         "id": "c13c10f4.16466",
  11.         "type": "template",
  12.         "z": "8ffd3e02.3f032",
  13.         "name": "Battery msg",
  14.         "field": "payload",
  15.         "fieldType": "msg",
  16.         "format": "handlebars",
  17.         "syntax": "mustache",
  18.         "template": "{{payload.attributes.friendly_name}} - {{payload.state}}%",
  19.         "output": "str",
  20.         "x": 490,
  21.         "y": 120,
  22.         "wires": [
  23.             [
  24.                 "924ec17d.6fdbb"
  25.             ]
  26.         ]
  27.     },
  28.     {
  29.         "id": "c0d7dbc7.645068",
  30.         "type": "join",
  31.         "z": "8ffd3e02.3f032",
  32.         "name": "Combine msgs",
  33.         "mode": "custom",
  34.         "build": "string",
  35.         "property": "payload",
  36.         "propertyType": "msg",
  37.         "key": "topic",
  38.         "joiner": "[92,110]",
  39.         "joinerType": "bin",
  40.         "accumulate": false,
  41.         "timeout": "",
  42.         "count": "",
  43.         "reduceRight": false,
  44.         "reduceExp": "",
  45.         "reduceInit": "",
  46.         "reduceInitType": "",
  47.         "reduceFixup": "",
  48.         "x": 900,
  49.         "y": 120,
  50.         "wires": [
  51.             [
  52.                 "7a7629fd.6ffa78"
  53.             ]
  54.         ]
  55.     },
  56.     {
  57.         "id": "ec1819db.fb8c38",
  58.         "type": "ha-get-entities",
  59.         "z": "8ffd3e02.3f032",
  60.         "server": "3bebce79.1e0962",
  61.         "name": "Get battery levels",
  62.         "rules": [
  63.             {
  64.                 "property": "attributes.device_class",
  65.                 "logic": "is",
  66.                 "value": "battery",
  67.                 "valueType": "str"
  68.             },
  69.             {
  70.                 "property": "attributes.unit_of_measurement",
  71.                 "logic": "is",
  72.                 "value": "%",
  73.                 "valueType": "str"
  74.             },
  75.             {
  76.                 "property": "state",
  77.                 "logic": "lte",
  78.                 "value": "30",
  79.                 "valueType": "num"
  80.             }
  81.         ],
  82.         "output_type": "split",
  83.         "output_empty_results": false,
  84.         "output_location_type": "msg",
  85.         "output_location": "payload",
  86.         "output_results_count": 1,
  87.         "x": 310,
  88.         "y": 120,
  89.         "wires": [
  90.             [
  91.                 "c13c10f4.16466"
  92.             ]
  93.         ]
  94.     },
  95.     {
  96.         "id": "924ec17d.6fdbb",
  97.         "type": "string",
  98.         "z": "8ffd3e02.3f032",
  99.         "name": "Remove battery level text",
  100.         "methods": [
  101.             {
  102.                 "name": "replaceAll",
  103.                 "params": [
  104.                     {
  105.                         "type": "str",
  106.                         "value": " Battery Level"
  107.                     },
  108.                     {
  109.                         "type": "str",
  110.                         "value": ""
  111.                     }
  112.                 ]
  113.             },
  114.             {
  115.                 "name": "replaceAll",
  116.                 "params": [
  117.                     {
  118.                         "type": "str",
  119.                         "value": " battery state"
  120.                     },
  121.                     {
  122.                         "type": "str",
  123.                         "value": ""
  124.                     }
  125.                 ]
  126.             }
  127.         ],
  128.         "prop": "payload",
  129.         "propout": "payload",
  130.         "object": "msg",
  131.         "objectout": "msg",
  132.         "x": 690,
  133.         "y": 120,
  134.         "wires": [
  135.             [
  136.                 "c0d7dbc7.645068"
  137.             ]
  138.         ]
  139.     },
  140.     {
  141.         "id": "164d92d1.209d5d",
  142.         "type": "inject",
  143.         "z": "8ffd3e02.3f032",
  144.         "name": "Run at 20.00",
  145.         "props": [
  146.             {
  147.                 "p": "payload"
  148.             }
  149.         ],
  150.         "repeat": "",
  151.         "crontab": "00 20 * * *",
  152.         "once": false,
  153.         "onceDelay": 0.1,
  154.         "topic": "",
  155.         "payload": "true",
  156.         "payloadType": "bool",
  157.         "x": 120,
  158.         "y": 120,
  159.         "wires": [
  160.             [
  161.                 "ec1819db.fb8c38"
  162.             ]
  163.         ]
  164.     },
  165.     {
  166.         "id": "7a7629fd.6ffa78",
  167.         "type": "api-call-service",
  168.         "z": "8ffd3e02.3f032",
  169.         "name": "Send notification",
  170.         "server": "3bebce79.1e0962",
  171.         "version": 1,
  172.         "debugenabled": false,
  173.         "service_domain": "notify",
  174.         "service": "mobile_app_myphone",
  175.         "entityId": "",
  176.         "data": "{\"message\":\"En eller flere enheder har lavt batteri: \\n\\n {{payload}} \\n\\nDu bør oplade eller skifte batteriet.\"}",
  177.         "dataType": "json",
  178.         "mergecontext": "",
  179.         "output_location": "",
  180.         "output_location_type": "none",
  181.         "mustacheAltTags": false,
  182.         "x": 1090,
  183.         "y": 120,
  184.         "wires": [
  185.             []
  186.         ]
  187.     },
  188.     {
  189.         "id": "6bf2cee8.2c147",
  190.         "type": "comment",
  191.         "z": "8ffd3e02.3f032",
  192.         "name": "Send notification at 20.00 if any device has low battey",
  193.         "info": "",
  194.         "x": 220,
  195.         "y": 60,
  196.         "wires": []
  197.     },
  198.     {
  199.         "id": "3bebce79.1e0962",
  200.         "type": "server",
  201.         "name": "Home Assistant",
  202.         "addon": true
  203.     }
  204. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement