Zigbee Motion Sensing – Tuya Z20ZL and Aqara P1 Sensors

Luminance Motion Sensor ZG-204ZL

Last update 12/12/2022 at the end. A couple of weeks ago I ordered a Zigbee TUYA Mini-PIR Sensor ZG-204ZL from (in my case) AliExpress – taking a leap of faith – as I wanted initially to see if it was worth turning Alexa Show off overnight. Today the sensor appeared in the mail (standby current 12uA)..

Until this point I had no idea if it would have to be used with a TUYA gateway (hardware device) or if I could use my usual Zigbee solution – Zigbee2MQTT which is running on my Raspberry Pi 4 home controller via the Sonoff Zigbee 3.0 Dongle Plus. Also on the same RPi I have Node-Red, MQTT and Grafana to name just a few of the software tools I have on there.

Anyway I took the plastic tab out of the sensor to allow the CR2450 battery (included) to run the IR sensor. Next, I inserted the supplied pin into the little hole for 3 seconds as per the instructions – while allowing my Node-Red Zigbee arrangement to look for new devices. Sure enough the IR sensor appeared, along with the usual default very long code – thankfully Zigbee lets you select a friendly name for devices so I’ve called it “minipir1”. I can do all of this via my Node-Red console or the Zigbee2MQTT web interface (which magically appears at port 9099 on my RPi).

Zigbee PIR
Zigbee2mqtt dashboard

Next, I added the node-red-contrib-zigbee2MQTT node set to that friendly name – and fed the output initially into a Node Red debug node – the result – I moved my hand – and msg.payload.occupancy returned TRUE. The device also reports its battery state and light levels (handy – up to 1000 lux) but I don’t need any of that right now.

AGES ago I wrote a node for Node-Red, called it node-red-control-timeout and it is freely available. I put that node on the output of the function (which simply returns an object with several items in it) and fed the result (if msg.payload.occupancy is TRUE) to a smart socket also accessible over MQTT (no phoning home here, this is all local).

Motion sensor and control nodes

The result, with my timeout node set to 900 seconds – i.e. 15 minutes – is working a treat, Alexa hasn’t turned off all afternoon. I eventually settled on Alexa going off after an hour of no movement at all and it will – and once it’s had a long test I’ll actually have the power controller turn off the entire TV cabinet which includes Android box, router, Alexa and TV.

Right now – I have Alexa turning off at night using the rather odd-shaped Tuya device above.

But today I received samples of the Aqara Motion Sensor P1 directly from Aqara, a lovely looking device which I quickly discovered ALSO works with Zigbee2MQTT. I opened the base of the device so I could pull out the plastic tab protecting the CR2450 battery. I put it back together, went into the Zigbee2MQTT web page on my PC as before and added the unit to my selection of Zigbee devices. All of that took seconds and it was not long before I could check that it was working.

The device measures both LUX (light) levels and movement and reports them back – with a satisfying blue light flashing once on movement. The results look remarkably similar to the Tuya unit but I like the form factor and operation width of this new Aqara device a LOT.

By now I’m getting more ambitious in my thoughts for movement sensing at night (I don’t want the cats waking me up so I can have Node-Red ignore changes between certain hours). I’m also particularly interested in the Aqara claim of 5 years battery life. I obviously can’t test that now but I will come back to this and see how the two different devices compare. I’ll also report back on how well they integrate with OTHER Zigbee hubs – I have just received an Athom Zigbee 3.0 Zigbee hub to test and as soon sa they give me a clue as to how to use it WITHOUT HOME ASSISTANT I’ll put something in here.

But for now, above, a short video of the opening of the movement sensing Aqara unit and below, some Zigbee2MQTT web interface output… the sensor works marvellously. Meanwhile the sensor is on my wall, up and running.

If you’re interested in Zigbee2MQTT or Zigbee 3.00 in general, there are several posts in this blog.

I used to hate Zigbee but it just keeps getting easier.

Aqara P1 Motion Sensor
Aqara P1 Motion Sensor
Aqara P1 Motion Sensor

Update Dec 12, 2022

Well, the first of the Aqara sensors has been 2m up on the wall behind the TV for the past week, reporting movement back to my Node-Red RPi4 setup which turns on the Echo Show for an hour after a movement report i.e. OCCUPIED report. Flawless – Echo Show turns on just as I’m coming into the room, by the time I sit down it’s running. I may just hook that into the entire power block for Alexa the TV Android box and the local router (used for TV (wired) next. Because we’re getting our broadband from 4G with a (high but not infinite) limit, I turn off the Android box off overnight (The TV turns itself off). On the odd occasion I forget to turn it off, the box seems to do some kind of data collection or ad processing when sitting doing nothing and 2 or 3 days in the last few months it has taken me over my self-imposed 10GB a day limit (300GB/month). In fact on two days we used up 22GB a day. Since I started turning the Android box to standby overnight that has only re-occurred once when I forgot. May as well automate the lot.


3 thoughts on “Zigbee Motion Sensing – Tuya Z20ZL and Aqara P1 Sensors

  1. Hi Pete,
    about the “ZG-204ZL” did you check the logs of your Zigbee gateway and can you, please, tell me if you have infos on the battery ? mine is reporting 0% since I installed it and it’s just brand new..
    that’s I can found on a ZbBridge with Tasmota, the other devices are reporting their battery as normal.

    1. I’m using Zigbee2MQT on that one – on the Raspberry Pi – and here’s what I get… You can see my battery is showing 100% and the sensor has been sitting on the wall since December.

      I just popped into the living room to make sure it’s looking at me (occupied). Yes, all’s well at this end.

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!

The maximum upload file size: 512 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here