HomeHome AutomationThis hunts unresponsive ZigBee sensors

This hunts unresponsive ZigBee sensors

Time for a hunt

A long long time ago, I did a small project called “ZigBee low battery warning“. It would actively scan your ZigBee network and notify your phone when your battery-powered device drops below a personalised threshold. It would also let you buy the batteries directly from Android notifications! The project had one shortcoming. It didn’t care about sensor responsiveness.

Monitoring ZigBee sensors in NodeRED

My work on DIY Smart Heating v4 takes more time than I would like, but I made one more module that will be integrated into my ZigBee network. This time around, I used NodeRED and Join to scan connected sensors and notify my phone if one of them hasn’t called home for a while. There are multiple reasons why this could happen, but it’s infuriating given how crucial sensors are to our automation – when the sensor is not performing as expected.

What I haven’t mentioned in the video, is the fact that this project works for any device that reports back to NodeRED. As long as the payload is posted to your NodeRED server, you can make it work no matter the protocol it uses.

How often do sensors call home?

A couple of articles ago, I tested 11 ZigBee temperature and humidity sensors for home automation. Apart from the usual metrics, I also took a look at how often sensors would call home and update your server with the latest readings. This would vary wildly between sensor type and brand but it would boil down essentially to a couple of triggers:

  • environmental change – a change in temperature, humidity, lux etc would trigger an update almost instantly. Once the threshold for change is crossed, the sensor sends the update
  • interval – without significant changes to your environment, the sensor would still report back. On average, you should expect one or more updates every 5-30 min
Lots of ZigBee updates paint a picture

Your battery-powered (and not only) devices can skip a beat. A faulty sensor may not work as expected, a crappy battery may drop current when an update is called or a troublesome router in the mesh network can hinder ZigBee communication. All these can affect the frequency of your reports.

The fix isn’t always as easy as swapping a battery, but knowing when the device failed and how long it had been since then helps to troubleshoot the issue.

NodeRED to the rescue

The project uses NodeRED with Join node (install via palette manager: node-red-contrib-join-joaoapps). Join links up with your Android phone and allows NodeRED to issue notifications. I have a complete write-up on the advantages of using Join in NodeRED here.

You can use this project in NodeRED and make it compatible with whatever automation at home. There are some requirements that your automation must meet, otherwise, you’ll have to modify the core code yourself.

To hunt for unresponsive ZigBee devices, sensors must be stored in an array

#get the list of existing sensors (make sure initially sensors = [])
var sensors = flow.get("sensors");
var sensor = msg.payload;
#add timestamp off the sensor update
sensor.timestamp = Date.now();
sensors.push(sensor);
flow.set("sensors", sensors);

and each sensor is an object which must contain these two key-value pairs:

{
"room":"name_your_sensor",
"last_report": 1675014128151
};

Each sensor object can contain other information too, but these 2 must be included in each object. You can assign the timestamp for each update by using this simple function:

sensor.last_report = Date.now();

Once you set the stage, import the project and take a look at the Settings node. In the “OnStart” tab you will find the settings which can be set for the flow and your Android notifications. If the sensors array has info on your battery status, it will include that in the notification too. It should help decide if the battery was at fault when the sensor went dark.

I suggest setting the timeout to more than an hour unless you have a good reason to keep more frequent notifications. The project is set to notify your phone within 1h from the time your sensor reports as unresponsive. It will issue a single notification for each sensor that became unresponsive. To prevent it from spamming, you can disable repeats, otherwise, NodeRED will reset notifications at 8 am the next morning.

Make sure to add names or IDs for your Join devices. You can specify one or the other and list more than one device to be notified.

Better control over notifications

If you are interested in having better control over the look and styling of Android notifications including HTML tags, links and whatnot – the AutoNotification plug-in is the answer. Take a look at my Perfect Notification article to take your notifications to the next level and style it the way you want.

Final thoughts

It’s a very simple add-on, but can be extremely useful. Similar data I available via the ZigBee2MQTT dashboard, but checking it daily is a chore – and no one likes hard work. Over the next few weeks, I’ll put some time aside to merge this project with my ZigBee low battery warning. It will give me the motivation to streamline that old project as NodeRED has gotten new tools since then. Let me know what you think in this Reddit thread.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

Smart Ideas with

Automate your space in with these ecosystems and integrate it with other automation services

client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image

Learn NodeRED

NodeRED for beginners: 1. Why do you need a NodeRED server?

0
To server or not to server? That's a very silly question!

Best Automation Projects

Tuya SDK for beginners: Intro to Tuya Cloud API

0
Working with Tuya Cloud API. A guide to Cloud automation for beginners, get started with REST!

NEST your old thermostat under $5

0
Nest-ing up your older thermostat under $5

Sonoff Zigbee Bridge – review

0
Sonoff line up will soon include Sonoff Zigbee Bridge and more Zigbee sensors - here is the first look

Nora – Google Assistant in NodeRED

0
Integrate Google Assistant with NodeRED thanks to Nora - NodeRED home automation

DIY Smart Washing Machine – for about 15 bucks!

0
Learn how to add washing machine notifications to your Google Home on the cheap

Smart Home

I damaged the cheapest Smart Socket with power metering for you

0
Sonoff S60 has an exeptional price for a smart socket with a power meter - I decided to check it out and see how flashable it is

The end of Tasmota? Sonoff SwitchMan M5 Matter

0
These are one of the least expensive Matter devices to automate your lights. Will Sonoff SwitchMan M5 Matter put an end to Tasmota?

Meros TRV to the rescue?

0
I got my hands on another TRV - this time from Meross. I heard good things about the brand so I wanted to see if Meross TRV would be good to manage smart heating.

Aqara brings Thread sensors but…

0
Aqara brings new Thread sensors to their ecosystem. First sensors to support Matter this way are Aqara Motion and Light Sensor P2 and Aqara Contact Sensor P2

Multi-lights for your ceiling from Aqara

0
This is the biggest light I held in my hands so far. It's ZigBee and it comes from Aqara - meet Aqara Ceiling Light T1M