I’m losing my mind over this, my automation just stopped working for no reason at all. I made one change, reverted it, and ever since it just will not work. I followed this guide. My set up is EXACTLY the same. I don’t understand what the problem is, it worked earlier.
input_number:
bedroomac_timer_minutes:
name: "Bedroom AC Timer"
min: 10
max: 360
step: 10
input_boolean:
bedroomac_timer_on:
name: "Bedroom AC Timer Switch"
initial: off
icon: mdi:timelapse
Edited automation in visual editor:
TRIGGERS
platform: state
entity_id: switch.bedroom_ac
to: 'on'
CONDITIONS
condition: state
entity_id: input_boolean.bedroomac_timer_on
state: 'on'
Before you read the rest of my post, first confirm the automation is enabled. It’s possible to manually execute a disabled automation but it definitely won’t trigger.
Where is the configuration for switch.bedroom_ac? Is it automatically created by some integration you are using?
Go to Developer Tools > States, find switch.bedroom_ac see what it reports as its current state (should be on or off).
Once you find it, click the entity and its information will populate the form at the top of the page. In the State field, change off to on then click the Set State button. That will change the switch’s state to on and trigger your automation (because it is using a State Trigger to listen to the switch for a change to on.
Let us know if that worked or failed.
BTW, don’t post a summary of an automation. Post its YAML code. In the Automation Editor, click the overflow menu (three vertical dots) and select ‘Edit in YAML’. Copy the displayed YAML and paste it here.
switch.bedroom_ac is a tasmota switch, added by MQTT. It works fine with other automations.
I’m not trying to trigger it from switch.bedroom_ac being on I’m trying to trigger it from input_boolean.bedroomac_timer_on being on. As I say this worked fine before but now it doesn’t. I’m assuming the changes I made and reverted have caused a bug.
I can’t comment on what happened in the past but I can assure you that what you posted above is not designed to trigger on the input_boolean’s state-changes.
The linked post uses a State Trigger to listen to light.treelamp and not the input_boolean.
I assume the switch must have been in an on state then but not reflected as such on the UI which lead me down this rabbit hole of expecting something to happen that was the result of something that couldn’t / shouldn’t happen.
Turning on the switch.bedroom_ac then toggling the timer switch gives me the expected result I was looking for.
Next time I do this I’ll do it on more than a few hours sleep. Thanks for the assist.
If the goal is to automatically turn off the switch after a certain amount of time (but only if the input_boolean is on) then it can be done like this:
alias: Bedroom AC Timer
description: ' '
trigger:
- platform: state
entity_id: switch.bedroom_ac
to: 'on'
for:
minutes: '{{ states(''input_number.bedroomac_timer_minutes'') | int }}'
condition:
- condition: state
entity_id: input_boolean.bedroomac_timer_on
state: 'on'
action:
- service: switch.turn_off
target:
entity_id: switch.bedroom_ac
mode: single
Be advised that any automation that employs delay, wait_template, the for option, timers, etc doesn’t survive a restart. That means if you restart Home Assistant while a delay is underway, its countdown is lost on startup. In other words, your original automation, and the one I posted, will fail to turn off the switch.
There are ways to make robust automations whose countdowns survive a restart but they are more complex.