aneeshd / schedule_state

Home Assistant (HA) sensor that returns a string based on a defined schedule, enabling further automations
Apache License 2.0
41 stars 6 forks source link

Examples, please #357

Open Strux-DK opened 3 weeks ago

Strux-DK commented 3 weeks ago

I'm new to Home Assistant and especially coding and coding in raw YAML. I'm trying to make a schedule for my bathroom lights, for example: 5:00-7:00 = 30% 7:00-10:00 = 40% 10:00-19:00 = 70% 19:00-21:00 = 40% 21:00-23:00 = 30% 23:00-5:00 = 20% But i'm having difficulties figuring out what to write where and what to include. `- platform: schedule_state name: Some descriptive name

refresh: "6:00:00" # this is the default

# default_state: default            # this is the default
# icon: mdi:calendar-check          # this is the default
# error_icon: mdi:calendar-alert    # this is the default
# minutes_to_refresh_on_error: 5    # this is the default
# allow_wrap: False                 # this is the default`

Should this just be at the top?

` events:

It would be lovely to reference some examples, where you shortly explain "in this example, the state will be on at time X and Y, but not at bla bla bla" and then some code.

That would be very helpful, thank you in advance!

hilburn commented 3 weeks ago

For something like that you could do:

- platform: schedule_state
  name: lighting_percentage_schedule
  default_state: 20  # this means it will return 20 when nothing else is happening - i.e. your 23:00-5:00 time
  events:
    - start: 05:00
      end: 23:00
      state: 30  # this overrides your default state between 0500 and 2300
    - start: 07:00
      end: 21:00
      state: 40  # this overrides everything "above" it (the 0500-2300 30% one and the default one) between 0700 and 2100
    - start: 10:00
      end: 19:00
      state: 70  # this overrides everything above it between 1000 and 1900