Whats wrong in this alarmclock automation

I think i tried that before and changed it to on, and still didn’t go. I then compared it to your setup, you had the empty line, changed that, et voila, automation ran fine for the first time…

Just to understand completely: initial_state: ‘off’ implies one can set it to ‘on’ somewhere . How could one do that then, other than changing in the code? Isn’t this where the slider comes in?

I must say it not very nice that on each boot it sets the alarm to the initial time in the settings, rather than the time one had it set to before booting. Would that be even possible to do, have it remember the last time set somehow?

HI @petro

Should get back on this, thanks for the nudge, and no, i hadn’t seen that before. Tbh, I didn’t create the alarm clock myself… copied the package from @mviezzer while working on the Summary card…

  • What could be the advantage of this technique, and, could you help me changing that input? how would i get that in the frontend?

I must say i find your alternative condition value template much easier to read and saved that for future implementation! thanks.

Ah ok. I like the sliders and I never used the input_datetime. Don’t even know what it looks like.

There probably isn’t an advantage if you already have something set up. My guess is that so many people have datetime requirements and this is a UI element that returns a datetime object with a nice interface. It would just make setup and automations easier to implement.

Instead of having your sliders and a sensor that gets both slider info, you would have 2 datetimes.

input_datetime:
  weekend:
    name: Weekend Alarm
    has_date: false
    has_time: true
  weekday:
    name: Weekday Alarm
    has_date: false
    has_time: true

Then you’d remove your sliders and sensor. Then use this for your time auotmation value_template:

now().hour == states.input_datetime.weekend.hour and now().minute == states.input_datetime.weekend.minute

Most of the other stuff would be the same. In the end, your interface would have a Time UI element and a On/Off instead of the Time Sensor UI element, On/Off toggle, Hour Slider, and Minute Slider.

ok thanks for helping me here.

went along and created the inputs, but something must have gone wrong:

input_datetime:
  weekend:
    name: Weekend
    has_date: false
    has_time: true

  weekday:
    name: Weekday
    has_date: false
    has_time: true

  both_date_and_time:
    name: Date and time
    has_date: true
    has_time: true

  only_date:
    name: Only date
    has_date: true
    has_time: false

47

4502

check out the component.

You may need to add a initial value:

initial: "00:00"

According to @mviezzer, this is a new component. There may be issues you need to work through.

At least set it in the future…duh
will investigate further :wink:

created a fun badge for checking the state changing of the alarmclock settings:

4527

this is promising:

input_datetime:
  alarmtime:
    name: Wake-up Time
    icon: mdi:timer
    has_date: false
    has_time: true
    initial: '07:00'
  sleeptime:
    name: Sleep Time
    icon: mdi:timer
    has_date: false
    has_time: true
    initial: '22:30'

group:
  alarmclock:
    name: Wake Me Up
    control: hidden
    icon: mdi:briefcase
    entities:
      - group.alarmclock
      - input_datetime.alarmtime
      - automation.wakeup_time
  sleepclock:
    name: Time To Sleep
#    control: hidden
    icon: mdi:sleep
    entities:
      - group.sleepclock
      - input_datetime.sleeptime
      - automation.nightbed_time

automation:
  - alias: wakeup_time
    initial_state: 'on'
    trigger:
      platform: template
      value_template: "{{ states('sensor.time') == (states.input_datetime.alarmtime.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
    action:
      service: light.turn_on
      entity_id: light.bedside_table

  - alias: nightbed_time
    initial_state: 'on'
    trigger:
      platform: template
      value_template: "{{ states('sensor.time') == (states.input_datetime.sleeptime.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
    action:
      service: light.turn_off
      entity_id: light.bedside_table

not sure if it looks better though, seems to boil down to wanting to input with a keyboard or a mouse…

also, not as easy to en/disable the alarm.