Hey there,
I know that I will kick myself but here goes… Once I have created a schedule using the new Helpers function in the 2022.9 release, how do I link it to an entity or to an automation?
Thank you.
Hey there,
I know that I will kick myself but here goes… Once I have created a schedule using the new Helpers function in the 2022.9 release, how do I link it to an entity or to an automation?
Thank you.
Use a State Trigger to detect when the schedule
entity changes state from off
to on
(a scheduled time period has started) and from on
to off
(a scheduled time period has finished).
Simple automation that turns a light on/off according to a schedule
entity.
alias: example
trigger:
- platform: state
entity_id: schedule.your_schedule
condition: "{{ trigger.to_state.state in ['on', 'off'] }}"
action:
- service: 'light.turn_{{ trigger.to_state.state }}'
target:
entity_id: light.your_light
That is awesome! Thank you so much.
To clarify. Are two Automation routines required? One from On-to-Off and the other from Off-to-On?
The example I posted handles both.
Thank you! I have much to learn.
You’re welcome!
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.
For more information, refer to guideline 21 in the FAQ.
@Kaizen28, did you test the solution and did it work for you? I added the following to my automations.yaml and the event did not trigger, and I don’t show any errors in the logfile.
- id: control-hot-water-heater-with-schedule
trigger:
- platform: state
entity_id: schedule.hot_water_schedule
condition: "{{ trigger.to_state.state in ['on', 'off'] }}"
action:
- service: 'switch.turn_{{ trigger.to_state.state }}'
target:
entity_id: switch.hot_water_heater_switch
Has the schedule option not been implemented in the UI yet?
My variation seems to be working
alias: Driveway Monitor Schedule
description: ""
trigger:
- platform: state
entity_id:
- schedule.driveway_monitor
condition:
- condition: template
value_template: "{{ trigger.to_state.state in ['on', 'off'] }}"
action:
- service: switch.turn_{{ trigger.to_state.state }}
target:
entity_id: switch.driveway_monitor_socket_1
mode: single
any idea how I could switch the helper apart from the schedule?
TIA
To make a minor improvement to use it with everything that can be turned on or off:
alias: Sync schedule koelingen
description: ""
trigger:
- platform: state
entity_id:
- schedule.koelingschedule
condition: []
action:
- service: homeassistant.turn_{{ trigger.to_state.state }}
target:
entity_id:
- switch.spp_grotekoeling
- switch.spp_3frigoshal
mode: single
@huuub I think you need to change homeassistant.{{ trigger.to_state.state }}
to homeassistant.turn_{{ trigger.to_state.state }}
Again I don’t understand why it is so difficult to find a blueprint for this basic task. So I have created what is necessary:
1.) Create a helper with the required schedule
2.) Add this blueprint
blueprint:
name: Schedule-activated Switch
description: Turn on and off a switch by schedule.
domain: automation
input:
schedule_entity:
name: Schedule
selector:
entity:
domain: schedule
switch_target:
name: Switch
selector:
target:
entity:
domain: switch
trigger:
platform: state
entity_id: !input schedule_entity
action:
- service: homeassistant.turn_{{ trigger.to_state.state }}
target: !input switch_target
mode: single
3.) Reload the blueprints
4.) Create an automation by selecting for the blueprint Schedule-activated Switch the schedule and the traget switch to opperate