If you show what you have come up with so far and where the automations fail, you’ll probably get more responses. Paste the automations (and traces) formatted correctly.
alias: TV Auto Power Off with Two Time Windows
mode: restart
trigger:
- platform: state
entity_id: remote.sony_tv
to: "off"
action:
# --- FIRST WINDOW (4h 15m) ---
- wait_for_trigger:
- platform: state
entity_id: remote.sony_tv
to: "on" # cancel if TV turns on
timeout: "04:15:00"
continue_on_timeout: true
# Cancel if TV turned on during first wait
- choose:
- conditions:
- condition: state
entity_id: remote.sony_tv
state: "on"
sequence:
- stop: "TV turned on — cancel automation."
# Check if power stays below 20W for 5 minutes at 4h15m
- wait_for_trigger:
- platform: numeric_state
entity_id: sensor.tv_power
below: 20
for: "00:05:00"
- platform: state
entity_id: remote.sony_tv
to: "on" # cancel if TV turns on
timeout: "01:00:00"
continue_on_timeout: false
# If TV turned on → cancel
- choose:
- conditions:
- condition: state
entity_id: remote.sony_tv
state: "on"
sequence:
- stop: "TV turned on during low-power check — cancel automation."
# If low power detected at first window → turn off plug
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.tv_power
below: 20
sequence:
- service: switch.turn_off
target:
entity_id: switch.tv_switch
- stop: "Turned off at 4h15m window."
# --- SECOND WINDOW (5h 5m) ---
# Wait until 5h 5m total (additional 50 minutes)
- wait_for_trigger:
- platform: state
entity_id: remote.sony_tv
to: "on"
timeout: "00:50:00"
continue_on_timeout: true
# Cancel if TV turned on during second wait
- choose:
- conditions:
- condition: state
entity_id: remote.sony_tv
state: "on"
sequence:
- stop: "TV turned on — cancel automation."
# Check low power again at 5h 5m
- wait_for_trigger:
- platform: numeric_state
entity_id: sensor.tv_power
below: 20
for: "00:05:00"
- platform: state
entity_id: remote.sony_tv
to: "on"
timeout: "01:00:00"
continue_on_timeout: false
# Cancel if TV turns on during check
- choose:
- conditions:
- condition: state
entity_id: remote.sony_tv
state: "on"
sequence:
- stop: "TV turned on during second low-power check — cancel automation."
# Turn off plug if low power detected at second window
- service: switch.turn_off
target:
entity_id: switch.tv_switch
- when sony tv (remote.sony_tv) is turned off
- tv plug power (sensor.tv_power) changes from above 40w to below 20w for 1m
- turn tv plug (switch.tv_switch) off
if it will work can someone please create it for me, thank you in advance
It’s hard for us to create automations based off a system we can’t see and don’t know the details of.
Your first two statements are effectively both triggers. Are you saying “after the remote is turned off, start watching for a power drop”?
If you are, then create an automation that triggers (“When”) from the remote event (you’re on your own here, as I don’t have a remote entity: I’d guess it’s a device trigger).
Leave the condition (“And If”) blank for now. Alternatively, if you want to enforce the “above 40W” criterion, you’d do it here.
In the action (“Then”), add a Wait For Trigger block to cover the second bullet point above. Set a reasonable timeout and turn Continue on timeout off.
Add the trigger, which is a numeric state trigger for the TV power sensor to be below 20W for one minute.
Then add the action to turn the switch off.
Should end up looking something like this in YAML:
If the TV power isn’t above 40W when the button is pressed, nothing will happen with the condition in place. If the power doesn’t drop from above to below 20W in the next minute, nothing will happen — including if the power was already below 20W.
Hi, thanks for that, when I press power button to turn off tv, the power is around 15-18w for 4 hours then tv power jumps to above 40w for 6 minutes whilst tv performs a test then settles back down to around 15-18w
Unless you have another way of working out the TV state, I think you need a toggle helper (aka Input Boolean) to track the remote state, so you’ll need three automations:
remote turn off (event trigger): turn off the toggle
remote turn on (event trigger): turn on the toggle
TV power drops below 40W (entity numeric state trigger): turn off the TV on the condition that (“When”) the toggle is off
What a weird and inefficient TV you have. Not Energy Star certified, then? Are you sure your power measurement is correct?
Hi I think I’ve sorted the night time automation but what do I need to add so the automation cancels if the tv is turned on before the automation completes
alias: Auto Turn TV Plug Off (23:00-9:00)
description: ""
triggers:
- entity_id: remote.sony_tv
to: "off"
trigger: state
conditions:
- condition: and
conditions:
- condition: time
after: "23:00:00"
before: "09:00:00"
- type: is_power
condition: device
device_id: 09e2df38d9fcff26ef0b609198967d4a
entity_id: f2fd9168cdb2955fc20a40023dbf291e
domain: sensor
below: 20
actions:
- delay:
hours: 4
minutes: 7
seconds: 0
milliseconds: 0
- target:
entity_id: switch.tv_switch
action: switch.turn_off
data: {}
mode: restart
That automation will turn the TV off four hours and seven minutes after you press the remote, provided it is after 23:00 and the power is already below 20W at the time you press the button. Conditions are evaluated once immediately — they are not a “wait until this happens” feature.
That’s what my suggestion above with the toggle helper achieves. You seem to be ignoring all advice given to you so far.
Whoa, back up a minute there. That Sony Bravia is an OLED, chances are it’s attempting to do the panel calibration routine and you’re interrupting it. It’s not just “a test” and it shouldn’t be interrupted.
I suggest you let it do its thing, otherwise you’ll end up with picture issues just to prevent it from using 40W for 6 minutes.
Sorry didn’t mean to sound like I was moaning or anything, I don’t interrupt the process I let it complete and thats when it returns back down to around 15-18w