Monitor Devices battery with Node Red?

I would like to monitor the battery status of my z wave devices and also all my Iphones.

In Hass I have working sensors for these devices. How would I do a flow to send a notification if the batteries are getting low? Say at 20% battery left it would send me a message.

1 Like

This is my flow: every week I check sensors status, I check with switch node if “data.attributes.battery_level” is below 10% and if true I send a notify with telegram.

I do this with the cell phones in my household. When someone’s cell phone goes from 26 to 25%, they get an alert on Telegram.

Just use the Event State node, and right after that, a function that compares current battery state to previous battery state, and when it hits your threshold, send a message.

Would you share you function code with me. I’m new to Node Red and still learning.

Super simple code:

if (msg.data.old_state.state == "26" && msg.data.new_state.state == "25"){
    return msg;
} else { return null;}
1 Like

Hello,

I tried to make the same like you, but i failing getting there :frowning:

Your ‘Ogni’, i have no idea what to fill in/ what node to select.

I can’t seem to find the same icons like you have for the current state?
image

For the switch, i just guessed:
image

I’m sure my notify will work (already using that node in other flows).

Any help would be nice.

Hey guys, created this flow for my battery check.
The messages will be send to my Pushover app on my phone if the battery is less then 30%.

Can you share this flow? Curious to play around with this.

Hello everyone.
I too would like to see the flow.
Thank you very much for sharing.
Best regards.
Bruno from France

Here is a simple one I created that sends an alert to telegram when the battery is at 20% or less each day.

[
    {
        "id": "82ab2d4f.93de8",
        "type": "ha-get-entities",
        "z": "d8d79347.2a13c",
        "server": "f0aa0465.fa7ce8",
        "name": "",
        "rules": [
            {
                "property": "attributes.battery_level",
                "logic": "lte",
                "value": "20",
                "valueType": "num"
            }
        ],
        "output_type": "split",
        "output_empty_results": false,
        "output_location_type": "msg",
        "output_location": "payload",
        "output_results_count": 1,
        "x": 290,
        "y": 100,
        "wires": [
            [
                "9ca8013e.c0992"
            ]
        ]
    },
    {
        "id": "d8102913.36b2d8",
        "type": "inject",
        "z": "d8d79347.2a13c",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "86400",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "x": 130,
        "y": 100,
        "wires": [
            [
                "82ab2d4f.93de8"
            ]
        ]
    },
    {
        "id": "9ca8013e.c0992",
        "type": "template",
        "z": "d8d79347.2a13c",
        "name": "Battery msg",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "The battery level for the {{payload.attributes.node_name}} is at {{payload.attributes.battery_level}}%",
        "output": "str",
        "x": 450,
        "y": 100,
        "wires": [
            [
                "1292e29b.6fe1ad"
            ]
        ]
    },
    {
        "id": "1292e29b.6fe1ad",
        "type": "join",
        "z": "d8d79347.2a13c",
        "name": "combine msgs",
        "mode": "custom",
        "build": "string",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": ",",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "",
        "count": "",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 620,
        "y": 100,
        "wires": [
            [
                "e1b49fe5.d8661"
            ]
        ]
    },
    {
        "id": "8065fd29.b0133",
        "type": "comment",
        "z": "d8d79347.2a13c",
        "name": "Alert when z-wave battery level are at or below 20%",
        "info": "",
        "x": 230,
        "y": 60,
        "wires": []
    },
    {
        "id": "e1b49fe5.d8661",
        "type": "telegrambot-notify",
        "z": "d8d79347.2a13c",
        "name": "low battery",
        "bot": "6cf9d125.c9a1f",
        "chatId": "111111111",
        "message": "",
        "parseMode": "",
        "x": 790,
        "y": 100,
        "wires": []
    },
    {
        "id": "f0aa0465.fa7ce8",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "legacy": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true
    },
    {
        "id": "6cf9d125.c9a1f",
        "type": "telegrambot-config",
        "z": "",
        "botname": "BatteryBot",
        "usernames": "xxxxxxx",
        "chatIds": "11111111111",
        "pollInterval": "300"
    }
]
1 Like

It’s awesome.
It works really well even for modules that are not from Fibaro.
Now I can monitor all batteries of my devices, including those of smartphones.
Thank you very much for sharing.
Bruno

This is a great flow! It shouldn’t be plug and play right? Cause I can’t seem to get it to report any of my entities’ battery levels?

Hi, as long as you have the same attributes and change the server path, it should work without any additional changes.

1 Like

Nice job.
I like to have a list of my all the battery devices in lovelace, but than would require that I set a condition list that I would have to update manually when ever I got new devices. Do you guys know if there is a way to do expose a list like this made e.g. in NR to lovelace?