Can someone smarter than me help me with an automation that does not seem to trigger. It is supposed to look for a sensor status and if it is true perform an action. it checks good in the config checker and the automation template returns true in the template editor. I have included the sensor code and the template code below. If manually activated this automation turns the light off/on it just does not seem to trigger on the sensor state change.
Sensor:
- platform: template
sensors:
glances:
friendly_name: “HTPC”
value_template: >-
{% if is_state(‘media_player.living_room_tv’, ‘off’) %}
Off
{% elif is_state(‘sensor.htpc_idle’, ‘Idle’) and is_state(‘media_player.living_room_tv’, ‘idle’) %}
Idle
{% else %}
In Use
{% endif %}
Automation
-
alias: Turn Off TV Lights when TV is off
trigger:- platform: template
value_template: “{% if is_state(‘media_player.living_room_tv’, ‘off’) %}true{% else %}false{% endif %}”
action: - service: homeassistant.turn_off
entity_id: switch.tv_lights_power
- platform: template
-
alias: Turn On TV Lights when TV is Idle/In Use
trigger:- platform: template
value_template: >-
{% if is_state(‘sensor.glances’, ‘Idle’) %}
true
{% elif is_state(‘sensor.glances’, ‘In Use’) %}
true
{% else %}
false
{% endif %}
action: - service: homeassistant.turn_on
entity_id: switch.tv_lights_power
- platform: template
I’m sorry if this is the wrong area to ask for help.