Hi, I’m trying to turn off a light if the time is between 23:00:00 and 05:00:00, and the power consumption of the TV is less than 2. But I can’t get my automation to work.
What am I doing wrong here?
- alias: 'Light livingroom off night'
trigger:
platform: time
minutes: '/5'
seconds: 00
condition:
condition: and
conditions:
- condition: template
value_template: '{{ states.sensor.fibaro_plug_tv_power < 2 }}'
- condition: and
conditions:
- condition: time
before: '05:00:00'
after: '23:00:00'
- condition: state
entity_id: light.oslo_wood
state: 'on'
action:
service: light.light_off
entity_id: light.oslo_wood
data:
transition: 30
EDIT: Added final automation with changes form @anon43302295 and @VDRainer for anyone else interested.
Automation: Light livingroom off night
- alias: ‘Light livingroom off night’
trigger:
platform: time
minutes: ‘/5’
seconds: 00
condition:
condition: and
conditions:
- condition: template
value_template: ‘{{ (states.sensor.fibaro_plug_tv_power | int) < 2 }}’
- condition: and
conditions:
- condition: time
before: ‘05:00:00’
after: ‘23:00:00’
- condition: state
entity_id: light.oslo_wood
state: ‘on’
action:- service: light.turn_off
entity_id: light.oslo_wood
data:
transition: 30 - service: notify.telegram
data:
message: “Nighttime, and the TV is off. Turning off light…”
- service: light.turn_off