Any way to create a template sensor which will show the last of a group of sensors which goes to 'on'?

This is for PIR use with PIRs. I have a sensor at the moment but it’s next to useless because all it shows is the PIR with the most recently updated status. So for Xiaomi sensors, which timeout after a two minute break, it’s not actually telling you anything useful because it could be overriding motion from a minute ago.

There might not be a way of doing this.

Thanks!

You can see the sensor’s last_changed or last_updated attributes. That tells you is how long ago it triggered. If you want more than “movement occurred sometime in the last two minutes” you will need better sensors.

Hi Tom - do you understand the problem?

My existing template sensor shows the LAST PIR sensor to report an update.

If someone is moving up and then down again through a building, the Xiaomi sensors work like this:

Activitiy Floor 1 - > Activity Floor 2 - Activity Floor 3
down again
Activity Floor 2 - > Activity Floor 1

So you’d HOPE the “last movement” template sensor would show Floor 1. However, due to the fact two minutes after it was turned on, the Floor 3 sensor will report ‘off’, it breaks the logic of the template sensor

Which is why I said:

i.e. ones that are only active while movement is occurring. Unfortunately this kills battery life so wired sensors are the go. Or there are some pretty epic threads about reducing the Xiaomi movement sensor active time if you can live with replacing batteries more often. e.g.

Thanks, Tom, yes I know about the hacks but not sure I want to hammer my SD card or MQTT broker like that! Thanks though. Food for thought.

Looks like this is now solved!! :slight_smile: