[ { "id": "8ffd3e02.3f032", "type": "tab", "label": "Low battery notification", "disabled": false, "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." }, { "id": "c13c10f4.16466", "type": "template", "z": "8ffd3e02.3f032", "name": "Battery msg", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{{payload.attributes.friendly_name}} - {{payload.state}}%", "output": "str", "x": 490, "y": 120, "wires": [ [ "924ec17d.6fdbb" ] ] }, { "id": "c0d7dbc7.645068", "type": "join", "z": "8ffd3e02.3f032", "name": "Combine msgs", "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": 900, "y": 120, "wires": [ [ "7a7629fd.6ffa78" ] ] }, { "id": "ec1819db.fb8c38", "type": "ha-get-entities", "z": "8ffd3e02.3f032", "server": "3bebce79.1e0962", "name": "Get battery levels", "rules": [ { "property": "attributes.device_class", "logic": "is", "value": "battery", "valueType": "str" }, { "property": "attributes.unit_of_measurement", "logic": "is", "value": "%", "valueType": "str" }, { "property": "state", "logic": "lte", "value": "30", "valueType": "num" } ], "output_type": "split", "output_empty_results": false, "output_location_type": "msg", "output_location": "payload", "output_results_count": 1, "x": 310, "y": 120, "wires": [ [ "c13c10f4.16466" ] ] }, { "id": "924ec17d.6fdbb", "type": "string", "z": "8ffd3e02.3f032", "name": "Remove battery level text", "methods": [ { "name": "replaceAll", "params": [ { "type": "str", "value": " Battery Level" }, { "type": "str", "value": "" } ] }, { "name": "replaceAll", "params": [ { "type": "str", "value": " battery state" }, { "type": "str", "value": "" } ] } ], "prop": "payload", "propout": "payload", "object": "msg", "objectout": "msg", "x": 690, "y": 120, "wires": [ [ "c0d7dbc7.645068" ] ] }, { "id": "164d92d1.209d5d", "type": "inject", "z": "8ffd3e02.3f032", "name": "Run at 20.00", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "00 20 * * *", "once": false, "onceDelay": 0.1, "topic": "", "payload": "true", "payloadType": "bool", "x": 120, "y": 120, "wires": [ [ "ec1819db.fb8c38" ] ] }, { "id": "7a7629fd.6ffa78", "type": "api-call-service", "z": "8ffd3e02.3f032", "name": "Send notification", "server": "3bebce79.1e0962", "version": 1, "debugenabled": false, "service_domain": "notify", "service": "mobile_app_myphone", "entityId": "", "data": "{\"message\":\"En eller flere enheder har lavt batteri: \\n\\n {{payload}} \\n\\nDu bør oplade eller skifte batteriet.\"}", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 1090, "y": 120, "wires": [ [] ] }, { "id": "6bf2cee8.2c147", "type": "comment", "z": "8ffd3e02.3f032", "name": "Send notification at 20.00 if any device has low battey", "info": "", "x": 220, "y": 60, "wires": [] }, { "id": "3bebce79.1e0962", "type": "server", "name": "Home Assistant", "addon": true } ]