Hey everyone!
I am trying to create a sensor that shows if my desktop is actively being used.
I integrated it into HA through IOT Link which gives me a sensor that shows the Idle time of the PC.
So far so good. I am trying to get a sensor that is on when the idle time (in seconds) is under 900. The sensor should be off when it is over.
This is what I have:
- platform: template
sensors:
desktop_pc_active:
friendly_name: 'Desktop PC active'
value_template: >-
{% set desktop = states('sensor.desktop_oaf62lp_system_idle_time') | float %}
{% if desktop < 900 %} On
{% else %} Off
{% endif %}
It works as intended however the state of the sensor is saved as a string I suppose. So it just has “on” or “off” in it. I would like the sensor to be on or off, so it reflex the status also in lovelace. Does that make sense?
Anyone that can help me?
Cheers!