Check Battery Level using Node Red

Hello,

I am new in-home automation especially using Node-Red. I have about 5 Zigbee door sensors that I would like to set up notification using Node-Red so if the battery level drops to 10% I will get ios notification including what door and what is the current battery level. Below is my current code. it works but I can’t get to show what door the notification is coming from. If you guys have another approach I am willing to give a try.

[
    {
        "id": "6f352f41.b3a56",
        "type": "switch",
        "z": "2bcdf7f.373dc08",
        "name": "Check Battery",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lt",
                "v": "92",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 860,
        "y": 220,
        "wires": [
            [
                "d49efa1d.d6d868"
            ]
        ]
    },
    {
        "id": "b57e03e3.e9fa2",
        "type": "api-call-service",
        "z": "2bcdf7f.373dc08",
        "name": "Notify Garen",
        "server": "5264684c.884f58",
        "version": 1,
        "debugenabled": false,
        "service_domain": "notify",
        "service": "ios_garens_iphone",
        "entityId": "",
        "data": "{}",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "payload",
        "output_location_type": "msg",
        "mustacheAltTags": false,
        "x": 1250,
        "y": 220,
        "wires": [
            []
        ]
    },
    {
        "id": "d49efa1d.d6d868",
        "type": "function",
        "z": "2bcdf7f.373dc08",
        "name": "Data",
        "func": "msg.payload = \n{\n  \"data\": \n  {\n    \"message\": msg.payload\n  }\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 1070,
        "y": 220,
        "wires": [
            [
                "b57e03e3.e9fa2"
            ]
        ]
    },
    {
        "id": "60a602a5.6256cc",
        "type": "inject",
        "z": "2bcdf7f.373dc08",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 100,
        "y": 220,
        "wires": [
            [
                "5d93d9d1.b743c8"
            ]
        ]
    },
    {
        "id": "5d93d9d1.b743c8",
        "type": "api-current-state",
        "z": "2bcdf7f.373dc08",
        "name": "",
        "server": "5264684c.884f58",
        "version": 1,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "sensor.garage_back_door_sensor_battery_level",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 450,
        "y": 220,
        "wires": [
            [
                "6f352f41.b3a56"
            ]
        ]
    },
    {
        "id": "5264684c.884f58",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "legacy": false,
        "hassio": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": false,
        "cacheJson": true
    }
]

Obviously you are using this as part of Home Assistant. You will need to pass the full JSON object across from HA to Node-Red so that it can be parsed and the Entity_ID then accessed (which is what you use to identify between the different sensors)

Alternatively why wouldn;t you use the new IOS app for HA and do native alerts in there to your phone ?

Craig

I am not as good with batteries as I would like, but expecting a batter to work after 90% discharge is pushing the friendship a bit I think.

Maybe if the battery is discharged by 10%. But waiting for it to be 90% discharged is asking for trouble.

Very much depends on the device and how it reports as well. Many devices will only report maybe 3-4 battery levels rather than a detailed percentage. The speed at which a devices goes from its last reporting level to not working will also be different for each type of device.

If you are using rechargable LiON batteries, I'd say recharge once they reach 1/3-1/4 charge. Maybe even 1/2 on higher-powered sensors. That's because the difference in voltage between charged and empty is relatively small.

For something like an AA Alkaline powered, low-power intermittent device then 10-20% remaining charge might be fine if the device reports to that level.

What I'm saying is that you might want to make the replace/recharge level configurable for different devices.