EPMatt / awesome-ha-blueprints

A curated collection of automation blueprints for Home Assistant.
https://epmatt.github.io/awesome-ha-blueprints
GNU General Public License v3.0
823 stars 246 forks source link

Enhancement - on off schedule #199

Open erkr opened 2 years ago

erkr commented 2 years ago

Blueprint name

on_off_schedule_state_persistence

Description

Hi Matteo First thx for your nice blue print. I like it as it is. My feature request is to add sun set / sun rise (with some time offset) as on or off triggers. e.g lights on 15 minutes before sun-set, and lights off at 23:00h. Regards Eric

Automation YAML config

No response

Implementation

No response

Additional Details

Useful resources

No response

Additional context

No response

SHxKM commented 2 years ago

I came here to suggest this exactly! and I second the compliments on the schedule blueprint.

One enhancement I'd like to suggest for this blueprint:

e.g lights on 15 minutes before sun-set, and lights off at 23:00h.

These can be dynamic attributes. x minutes_before_sunset for light.on and y minutes_after_sunrise for light.off.

SHxKM commented 2 years ago

I've actually started working on such blueprint but there's a huge blocker here because one cannot use variables in template triggers..

erkr commented 2 years ago

I've actually started working on such blueprint but there's a huge blocker here because one cannot use variables in template triggers..

Maybe this blueprint can help: CyanAutomation/lights_on_at_sunset.yaml The combination of these two blueprints would be great 😊

SHxKM commented 2 years ago

I've actually started working on such blueprint but there's a huge blocker here because one cannot use variables in template triggers..

Maybe this blueprint can help: CyanAutomation/lights_on_at_sunset.yaml The combination of these two blueprints would be great 😊

Sunset/sunrise is simple enough, but with an offset it becomes a whole different story because of inherent limitations currently imposed by HA.

In fact, even writing an automation (not a blueprint) with state persistence similar to that in this repository requires some variable duplication.

erkr commented 2 years ago

Hi. That Blueprint supports an offset, not in time but a elevation delta. Works even better than a time offset as the sunset/rise speeds differ in summer vs winter

SHxKM commented 2 years ago

Hi. That Blueprint supports an offset, not in time but a elevation delta. Works even better than a time offset as the sunset/rise speeds differ in summer vs winter

Yeah, I don’t disagree that sun-elevation is a more consistent measure between different seasons. But I was after a more naive and “simpler” blueprint, and that is unfortunately not really possible right now..

calisro commented 2 years ago

would making the fields on/off_time template friendly, allow people to possibly do this in a template? I suppose a separate automation could be created to manipulate the time/date input instead based on the change in the elevation.

erkr commented 2 years ago

I finally made the step to write some blueprint myself for persistent sunset and sunrise events. Both an offset and an elevation based variant:

https://gist.github.com/erkr/be04a09c4b826d1ff31d29c71152c322

https://gist.github.com/erkr/c0e3a3ab4aaccfbe183ae40e0b12456f

https://gist.github.com/erkr/27bb347ab107c4a9231046e75667356b

https://gist.github.com/erkr/7abf78d6ce9a1edc904124b1e1ee512c

Have fun!