PIR - Motion Last Seen Sensor

This template is not working anymore for me in 0.81.0… I have hue motion sensors. Seems to update only on HA restart… Am I the only one ?

EDIT: Solved ! Indeed, if you do not supply an entity_id in the configuration you will need to run the service homeassistant.update_entity to update the sensor.

1 Like

see the note:

1 Like

Any idea what I am doing wrong here? Im trying to use Philips hue motion sensors in this template? Thanks in advance :slight_smile:

- entity_id: motion_location_001
  platform: template
  sensors:
    template_pir_motion:
      friendly_name: 'Motion Location'
      value_template: >
                  {%- set pirs = [sensor.bedroom_motion, sensor.living_room_motion, sensor.landing_motion] %}
                  {% for pir in pirs %}
                    {% if as_timestamp(pir.last_changed) == as_timestamp(pirs | map(attribute='last_changed') | max) %}
                      {{ pir.name }}
                    {% endif %}
                  {% endfor %}

Yes, you need to add the entity_id of all your sensors:

- platform: template
  sensors:
    template_last_motion:
      friendly_name: 'Last Motion'
      icon_template: 'mdi:walk'
      entity_id:
        - sensor.bedroom_motion
        - sensor.living_room_motion
        - sensor.landing_motion
      value_template: >
        {%- set sensors = [sensor.bedroom_motion, sensor.living_room_motion, sensor.landing_motion] %}
        {% for sensor in sensors %}
          {% if as_timestamp(sensor.last_changed) == as_timestamp(sensors | map(attribute='last_changed') | max) %}
            {{ sensor.name }}
          {% endif %}
        {% endfor %}
1 Like

Which PIR are you using? i am tired of using hue motion sensors, they work fine for walking into a room, but if i’m reading something for more then 30 minutes theres no motion…, well because there isn’t none, id much rather use PIR

I’m using Hue Motion sensors with hue-mqtt-bridge without any problem :slightly_smiling_face:

Many thanks for this!
May I ask you further help? I was trying to add all the “pir_” named sensors, but I can’t get to have a working code…

hue doesn’t do PIR…

i have two of them, so how do i turn on PIR?

PIR stands for Passive Infra Red… its how the device detects motion. There is no ‘turning it on’ as such

yes, by heat… show me where the hue does this

all PIR devices use that same basic technology / method. I don’t understand what you are asking.

as far as i know the hue doesn’t have PIR for motion sense

so what tech does it use then? it certainly looks like a PIR…

if it used heat waves then it would detect that im sitting in my room and not turn off my lights automatically, i assumed heat waves used by PIR would detect someone and not turn off my lights

PIR needs motion of the heat producing item/body. They do use the tracking of heat but they require the heat to move across the IR beams. Thats why if you move slow enough (especially walking directly towards a PIR sensor) it wont detect you

hm ok, is there a motion sensor that works better to detect someone if im sitting in my chair for a longer period of time without moving?

you can get ‘presence detectors’ which are basically just high sensitivity motion sensors so that they can detect small movements such as someone working at a desk, or you can get heat detectors.
Perhaps your best option (rather than spending a lot of money) would simply to have a manual mode for your light so that it isn’t purely dependent on motion. I have my lights set up for 3 modes: ON, OFF and AUTO. AUTO is motion detection based. If I want the light to stay on without motion I simply put it in ON mode, likewise if I don’t want it to come on with motion I set it to OFF.

Great idea, do you have a sample automation how this works we can pirate :wink: