Sensor.time not triggering

I’m trying to create a sensor that indicates when the last time a sensor value was updated:

	  - platform: template
		sensors:
		  living_no_activity:
			entity_id: sensor.time
			value_template: >
			  {{ (now().timestamp() - as_timestamp(states.sensor.living_temperature.last_changed)) | int //60 > 30 }}

This works because the automation tester shows 1 or True after 30 minutes.

But when I look at the States page, the state is always 0 or False, it never updates to 1.

Why is this?

See this doc page.

Sorry, but what am I looking for exactly? I see:

Please note that the resulting template will be evaluated by Home Assistant state engine on every state change of these sensors, which in case of sensor.time happens every minute and might have a negative impact on performance.

I have it set to entity_id: sensor.time, but it doesn’t update every minute.

D’oh! I looked right past the entity_id option and just saw the value_template. Ok, then have you configured sensor.time in your system?

sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
      - 'date_time'
      - 'date_time_iso'
      - 'time_date'
      - 'time_utc'
      - 'beat'

This either goes in your configuration.yaml or any package file

You will probably only ever use 2 or 3 of these but it costs virtually nothing (resources) to add them all

Edit; unless you run packages - there can only be one sensor header in your config (be careful)

This makes sense, I didn’t configure those no! I didn’t realized those have to be configured separately and thought they were out of the box enabled.

Thanks @Mutt!

Is your automation working okay now ?

@pnbruckner is there a reason why sensor time is excluded from default config.?
I’m not suggesting this is anyone’s ‘fault’ but you may have an insight as to why a sensor that virtually every user will need within 3 months is not preconfigured ?
I install it by hand but I presume there should even be a GUI install ?
Just speculating. :smiley:

Don’t know anyone who use sensor.beat though :man_shrugging:

No clue. I had nothing to do with that, nor was I involved in any discussions about it.

I guessed as much, it’s not exactly ‘considered’ and I’ve yet to see you make an ‘ill-considered’ one.

Mistakes however (unfortunately), follow all of us.
:rofl: