Input time

I want an automation that will do events based on a certain time. No problem. But I want to be able to adjust the time. Lets call it an alarm clock. I have 4 bedrooms, each bedroom has a different time they need to wakeup and it may change from day to day. So I don’t want to have to change the automation.yaml file and bounce HA every day to activate the new times. I would like a text box, drop down, slider, something that could be accessed from the main screen or a group screen that would allow those times to be maintained easily without restarting HA.

It may be a long read but people have created alarm clocks in HA… Creating a alarm clock

1 Like

HI,

You can do that

in automation.yaml:

  - alias: "reveil matin Aurore Semaine"
    trigger:
      - platform: time
        minutes: '/1'
        seconds: 0
    condition:
      - condition: state
        entity_id: input_boolean.alarmweekon
        state: 'on'
      - condition: state
        entity_id: input_boolean.alarmweekday
        state: 'on'
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
      - condition: template
        value_template: '{{ now().strftime("%H:%M") == states.sensor.alarm_time.state }}'
    action:
      - service: light.turn_on
        entity_id: light.chambre
        data:
          transition: 600
          brightness: 255
      - service: light.turn_on
        entity_id: light.escalier
  - alias: "reveil matin Aurore les weekend"
    trigger:
      - platform: time
        minutes: '/1'
        seconds: 0
    condition:
      - condition: state
        entity_id: input_boolean.alarmweekon
        state: 'on'
      - condition: state
        entity_id: input_boolean.alarmweekday
        state: 'off'
      - condition: time
        weekday:
          - sat
          - sun
      - condition: template
        value_template: '{{ now().strftime("%H:%M") == states.sensor.alarm_time.state }}'
    action:
      service: light.turn_on
      entity_id: light.chambre
      data:
        transition: 600
        brightness: 255

So you need

 input_slider:
  alarmhour:
    name: Heure
    icon: mdi:timer
    initial: 6
    min: 0
    max: 23
    step: 1
  alarmminutes:
    name: Minutes
    icon: mdi:timer
    initial: 30
    min: 0
    max: 59
    step: 5

Here a snapshot to see the result

6 Likes

Awesome,
Thanks

I’m not understanding the relationship between the input_slider and the trigger above? Where do you get states.sensor.alarm_time.state?

Sorry for that :blush:

in sensors.yaml (or in configuration.yaml) you have to declare a sensor template

- platform: template
  sensors:
    alarm_time:
      friendly_name: 'Time'
      value_template: '{{ "%0.02d:%0.02d" | format(states("input_slider.alarmhour") | int, states("input_slider.alarmminutes") | int) }}'
1 Like

how you make this (the time?)

How to make 2 times (one for weekdays and one for weekend?

If you disable the input boolean jours de la semaine (icon calendar) the alarm will work the week-end
With the code in my previous post you could adapt like you want