[Feature Request] Service to set schedule from template
See original GitHub issueThanks so much for this integration, it works great.
I have a use case where my sleep schedule can be quite unpredictable, but Home Assistant knows when I set an alarm to wake up, and what time the alarm is set for. As such, I would like to write an automation to automatically set a schedule whenever my wake up alarm changes, with the idea that both the heating and hot water would turn on 30 minutes before.
Unfortunately, because the set schedule services require a file, I would have to write every possible schedule into separate files, and then pick one depending on the alarm time. It would be easier if I could just use the HA templating capabilities to essentially build a schedule inside the automation, and then set it.
Ideally, we would also have some extra keywords, like “All” (for all days, Monday through Sunday), or “Today” (for the weekday that is today, e.g. if today is monday, this would be equivalent to using “Monday”), or “Tomorrow” (for the next day, e.g. if today is monday, this would be equivalent to using “Tuesday”).
Something like this:
service: wiser.assign_schedule
data:
to_entity_id: climate.wiser_heating
schedule:
Weekdays:
- Time: {{ (as_timestamp(wake_up_time) - 15*60) | timestamp_custom("%H:%M") }}
Temp: 20
- Time: 22:30
Temp: 15
Weekends:
- Time: {{ (as_timestamp(wake_up_time) - 15*60) | timestamp_custom("%H:%M") }}
Temp: 20
- Time: 22:30
Temp: 15
Or
service: wiser.assign_schedule
data:
to_entity_id: climate.wiser_heating
schedule:
All:
- Time: {{ (as_timestamp(wake_up_time) - 15*60) | timestamp_custom("%H:%M") }}
Temp: 20
- Time: 22:30
Temp: 15
The same could be done when HA detects I am going to sleep, the schedule could be dynamically modified accordingly.
Right now, I need to manually automate the schedule myself, controlling the thermostat directly, as an override. I would prefer to just set the Wiser schedules dynamically, and leave everything else to the hub.
Thank you!
Issue Analytics
- State:
- Created a year ago
- Comments:6
@ruipin I have now released our new v3.2 version that includes this. I did not see your update to the issue regarding having a today or tomorrow option, but I would need to look into this more before we do that. Not sure if that could cause issues. However, if you want to be able to just amend a specific day on a schedule, you could do something like this:
and this will just amend the current day of week (or use some other templating logic to get to a weekday).
Anyway, please try it out and see how you get on. Will leave this issue open to track any problems you find.
This is a nice idea and was nowhere near as hard as I thought. As such, it will be in next release. I’ll let you know when done if you can please test it for me. You will have to add a Type: Heating etc line also but see docs here, shows how it will work. Also included the All option.
https://github.com/asantaga/wiserHomeAssistantPlatform/blob/Async-API/docs/services.md#set-schedule-from-string