My last_motion sensor stopped working (from 86.4 to 89.1)

I always used below to check when the last motion in the house was. Always worked fine until I upgraded from 86.4 to 89.1. I searched for breaking changes regarding this but could not find anything. Any suggestions?

  - platform: time_date
    display_options:
      - 'date_time'

  - platform: template
    sensors:
      last_motionv2:
        friendly_name: Last motionv2
        value_template: '{% if states.group.motion_check.last_updated is undefined %}{{"00:00:00"}}{% else %}{{ ((as_timestamp(states.sensor.date_time.last_updated)-as_timestamp(states.group.motion_indoors.last_updated))|int) }}{% endif %}'
        entity_id:
          - sensor.date_time
        unit_of_measurement: 's'

And in the groups.yaml:

    Motion check:
      - binary_sensor.motion_eetkamer_326
      - binary_sensor.motion_gang_beneden_317
      - binary_sensor.motion_gang_boven_393
      - binary_sensor.fibaro_system_fgms001_motion_sensor_sensor_10_0
      - binary_sensor.motion_zitkamer_313
      - binary_sensor.motion_kelder_213
      - binary_sensor.frontdoor_sensor_25_0

    Motion indoors:
      - binary_sensor.motion_eetkamer_326
      - binary_sensor.motion_gang_beneden_317
      - binary_sensor.motion_gang_boven_393
      - binary_sensor.fibaro_system_fgms001_motion_sensor_sensor_10_0
      - binary_sensor.motion_zitkamer_313
      - binary_sensor.motion_kelder_213

Are there any errors?

No, nothing in logs related (even remotely) to this. It’s just not updating the sensor anymore ( (sensor.date_time is updating correctly). Maybe there always has been a mistake in this sensor but was <86.4 more forgiving?

Could be…
Does the template work in the template editor in the dev tools?

No capitals, no spaces for yaml. I’m surprised this worked at all, ever.

And the syntax doesn’t even look correct. I’d expect something more like this. (group: would be missing if you are using group.yaml)

group:
  motion_check:
    icon: mdi:home
    entities:
      - binary_sensor.motion_eetkamer_326
      - binary_sensor.motion_gang_beneden_317
      - binary_sensor.motion_gang_boven_393
      - binary_sensor.fibaro_system_fgms001_motion_sensor_sensor_10_0
      - binary_sensor.motion_zitkamer_313
      - binary_sensor.motion_kelder_213
      - binary_sensor.frontdoor_sensor_25_0

One of the recent releases changed the way template_sensors are updating (can’t find which version though)

The template engine will attempt to work out what entities should trigger an update of the sensor. This can fail, for example, if your template loops over the contents of a group. In this case, you can use entity_id to provide a list of entity IDs that will cause the sensor to update or you can run the service homeassistant.update_entity to update the sensor at will.

Source : Template - Home Assistant

I had to adapt my template sensors, i.e. provide a list of entities that could trigger an update.

Maybe it’s the same in your setup, it’s worth a check.

He already has that.

Are the entity_ids the same - a recent breaking change added _2 at the end of some of mine. This will break the template sensor?

Update: Stupid me; there was a motion sensor stuck on triggered so no state change was happening… After resetting the sensor all back to normal @petro; No idea why this is still working. Think this one from +3 years back.

That’s good news! If it ain’t broke don’t fix it.