I want to turn on a switch based on a schedule and then off.
I was told the best way to do is via schedule helper. So I created the helper and set a schedule. And then created an automation when the helper’s state is active, then that calls service to turn on the switch.
And when the helper goes to idle, the switch is turned off.
This automation seemes not to work… maybe I’m missing something. And if it did work then there is a slight flaw to it.
(For example: I want to turn on the switch on Monday at 7am till 9am. So when the status changes of the helper from idle to active. I turn on the switch. But if for some reason the the helper does not change the state then the switch won’t turn on at 7am. But I want to turn on the switch anyway between 7 till 9. But this automation only works at the specific time of 7am)
schedule.dehumidifier
from: “off”
to: “on”
condition:
condition: state
entity_id: input_boolean.room_dehumidifier_button
state: “on”
action:
service: switch.turn_on
data: {}
target:
entity_id: switch.room_dehumidifier
mode: single
I have helper button as a condition to control whether I want the schedule to run or not on a particular day. And it’d always on. So I dont know what else could be causing the automation to not run.
(And please ignore any errors in the structure as when i pasted the yaml from the automation, the structure seems to have messed up)
So this is the case.
You want to turn on dehumidifier and than turn it off. When you want to do it? At specific time or when humidity level reach some point?
I’m not sure that using this helper is the best way to do this automation.
Maybe the easiest way to do it is to create two triggers ids based on humidity level and select choose action to turn humidifier on off when humidity level is above or below threshold.
I think what you have should work - provided the indentation is correct:
alias: Test
description: ""
trigger:
- platform: state
entity_id:
- schedule.test
from: "off"
to: "on"
condition:
- condition: state
entity_id: input_boolean.test
state: "on"
action:
- service: switch.turn_on
data: {}
target:
entity_id: switch.test
mode: single
You would need another automation to turn the switch off again.
You might try leaving out the “off” in the trigger. As it stands the automation will not run if schedule.dehumidifier starts out in some other state than “off” - unavailable, for example.
Also, it will only run when the state of the trigger actually changes - at 7am. If you want to have manual control of the dehumidifier as well as a schedule, you could include an input_boolean as a second trigger.
I dont see scheduler as key component to most automation. Only device that I have and use scheduler is buderus furnace. It is using its build in scheduler. But even it is using conditions to run.
Will the automation still work if I delete the “off” from the trigger. (I assume the automation wants to know the change in state from off to on?) If not, then its a great idea to remove the “off” in the trigger.
Finally, I don’t understand what you mean by change input boolean to control the switch.
I want the switch to turn on between 7am till 9am. But as you said, this automation only runs at 7am. If for any case, the automation fails to run at 7am then it will stay off untill 9am.
But I want to modify this automation in a such a way that even if its past 7am but before 9am, that this automation still runs and turns on the switch.
I don’t know how to do that🙃
Well I use just timer helper for lights. I don’t know will this help but here it is. The problem I want to solve is that I want to turn off lights only when motion is not detected for a minute. Helper is here to start countdown when pir sensor stop detecting motion. But if pir sensor detect motion cancel helper and start counting down again when motion is cleared.
Well I can’t take a picture of it. Its simple. It uses 3 state triggers. All of them have a trigger id.
For action its using choose. It has 3 options as its has 3 triggers and every choose option is started with trigger id. It might look complicated on the first glance but its basically very simple.
Maybe I didn’t read this correctly, but when using the schedule helper, you have to make sure that you setup the schedule helper correctly. When I first used it for some lights, I had random results.
But I wasn’t doing the schedule correctly! I had simply clicked at a time i wanted it to turn on or off, and where I clicked, it put a line there. Later when I was looking at it to figure out why it wasn’t working, I noticed that if you put your cursor at the bottom of the line, but only if you get your cursor in the right place, it changes to an up & down arrow. (This was tricky, since it was only a line, not a block!)
Then you can drag the “ON” time to go all the way to the time you want it to turn off.
The result is shaded blocks of time for the “ON” time.
(It seems so obvious now, lol. But starting out, I just had a line to turn on, and another to turn off–that’s why it wasn’t working correctly!)
Hope that helps someone!
An example of a simple way to use Schedule to turn something on and off within one automation would be…
alias: Pool Pump via Schedule
description: “”
triggers:
trigger: state
entity_id:
schedule.pool_pump
conditions:
actions:
choose:
conditions:
condition: state
entity_id: schedule.pool_pump
state: “on”
sequence: