LAB02-Research / HASS.Agent

Windows-based client for Home Assistant. Provides notifications, quick actions, commands, sensors and more.
https://hassagent.lab02-research.org
MIT License
1.47k stars 65 forks source link

Misc: Can't Trigger an Automation once a User Is Active on their PC with the Template Provided in the HASS.Agent Docs #414

Open ars4l4n opened 2 weeks ago

ars4l4n commented 2 weeks ago

One of the examples from the Hass.Agent Docs didn't work.

An automation with this as a trigger never triggers for me:

alias: example
trigger:
- platform: template
  value_template: "{{ (now() - states('sensor.testvm_lastactive')|as_datetime).total_seconds() < 60 }}"
action:
   ... etc ...

Using the "User Active" sensor below as a trigger does however work.

template:
  - binary_sensor:
      - name: "User Active"
        state: "{{ as_timestamp(now(),0) - as_timestamp(states('sensor.staging_lastactive'),0) < 60 }}"

Core2024.6.1 Supervisor2024.06.0 Operating System12.3