Automation when state hasn't changed for some time

I am automating my Microsoft Teams status. I have sensors showing my status. When I close the Teams application, the status shows as ‘Offline’. So far so good.

When I shutdown my computer without first closing the application, the status is not updated. If it was showing ‘Available’ it will continue to do so until I launch the Teams application the next day.

What I was thinking was, to create an automation that forces the status to ‘Offline’ when the status has not changed for 2 hours after 19:00. Any help or hints are appreciated.

I have searched the forums but couldn’t find anything useful or similar from the automation gurus like @pnbruckner. :upside_down_face:

  platform: template
  value_template: "{{ as_timestamp( now() ) - as_timestamp( states.your_teams_senso.last_changed )  > 7200 }}"

Or you could just monitor the state of your PC and trigger off that.

1 Like

That simple. :man_facepalming: