Alarm Clock Automation Help

I have a alarm clock automation that I love and works great except for
I can’t figure out how to pick the wake up time from my input_select:

The input_boolean: works great for picking the days.
Just need to be able to pick the time.

I currently have to manually enter the time in the automation file.

Any help would be greatly appericated.

This is my input_boolean

input_boolean:
  monday:
    name: 1_Monday
    initial: off
  tuesday:
    name: 2_Tuesday
    initial: off
  wednesday:
    name: 3_Wednesday
    initial: off
  thursday:
    name: 4_Thursday
    initial: off
  friday:
    name: 5_Friday
    initial: off
  saturday:
    name: 6_Saturday
    initial: off
  sunday:
    name: 7_Sunday
    initial: off

This is the input_select

input_select:
  alarmtime:
    name: "Alarm Time"
    icon: mdi:alarm
    initial: "08:00:00"
    options:
      - "07:00:00"
      - "07:30:00"
      - "08:00:00"
      - "08:30:00"
      - "09:00:00"
      - "09:30:00"
      - "10:00:00"

This is the Auomation

#-----------------------------------
#----Wake Up Alarm for Work Days

- id: three
  alias: "Alarm Clock Work Days"
#  hide_entity: true
  condition:
    condition: or
    conditions:
      - condition: template
        value_template: '{{ (now().strftime("%a") == "Mon") and (states.input_boolea$
      - condition: template
        value_template: '{{ (now().strftime("%a") == "Tue") and (states.input_boolea$
      - condition: template
        value_template: '{{ (now().strftime("%a") == "Wed") and (states.input_boolea$
      - condition: template
        value_template: '{{ (now().strftime("%a") == "Thu") and (states.input_boolea$
      - condition: template
        value_template: '{{ (now().strftime("%a") == "Fri") and (states.input_boolea$
      - condition: template
        value_template: '{{ (now().strftime("%a") == "Sat") and (states.input_boolea$
      - condition: template
        value_template: '{{ (now().strftime("%a") == "Sun") and (states.input_boolea$
  trigger:
    platform: time
    at: '08:00:00' #Changed from after to at per log
      action:
        - service: light.turn_on
          entity_id:
            - light.cree_connected_a19_60w_equivalent_fe06c273_10
            - light.sengled_e11g13_0306678e_1
            - light.sengled_e11g13_03092691_1
            - light.sengled_e11g13_03092ed4_1
        - service: tts.google_say
          entity_id: media_player.ccaudio_media
          data_template:
            message: >
              Time to get your out of bed!
              Todays temperature will be a high of {{states.sensor.yweather_temperature_$
              and a low of {{states.sensor.yweather_temperature_min.state}}
              Weather conditions will be {{states.sensor.yweather_condition.state}}.
        - delay: '00:00:15'
        - service: media_player.media_play
          data:
            entity_id: media_player.runeaudio_mpd
1 Like

This is quite a pain in the ass. Triggers do not allow for value_templates to be added into the ‘at:’ category. So you have to work around that. The way to do that is creating a automation that fires at a time increment, but only fires based on a specific condition. This is a work around by the way. Appdaemon can do this without this funky BS:

- alias: something
  trigger:
    platform: time
    minute: "/1"
  condition:
    condition: and
    conditions:
      - condition: template
        value_template: >
          {% set hour, minute, second = alarmtime.split(':') %}
          {{ now().hour == hour | int and now().minute == minute | int }}
      - condition: or
           # add your input boolean conditions here

This is off the top of my head so the syntax might be wrong. Check it against the documentation when you attempt to implement it.

Hi,

Maybe you like this:

imagen

https://community.home-assistant.io/t/creating-a-alarm-clock/410/25

That would work as well. Still a work around. The general idea of that is to trigger off a template using sensor.time. Which means you need to track time in your HA instance.

I am shocked that with all of the stuff HA is capable of I can’t just pick
the time I need from my input_slider instead of have it hard coded.

trigger:
    platform: time
    at: '08:00:00'

Someone has to know how to do this.

Thanks again for any help

I think you are just missing some logic here that ties what you see on the screen (and interact with) and what goes on in the background to make the result what you want it to be.

So, in this case, you want a dropdown box (an input select) with some pre-defined times. When you select the time, you want that time to trigger the alarm.

An input select contains ‘strings’ not ‘times’, so you must convert the contents of the input_select before anything else. You can use an input datetime to hold the time. (I’m not quite sure why you’re not using this as the frontend, but that’s not important to actually answering your question).

Then you need a template trigger, because you want it to change (not be hard coded).

So, first things first:

Automation to convert input select in to a time

trigger:
  platform: state 
  entity_id: input_select.alarm_time
action:
  service: input_datetime.set_datetime
  data_template:
    entity_id: input_datetime.alarm_placeholder
    time: "{{states.input_select.alarm_time.state}}"

(you might need to remove the quotes from the entries in your input_select)

Then your automaton trigger is as per the example on the docs for input_datetime.

Then you need your condition to establish whether today’s input boolean is on. This should just be one condition, something like

value_template: "{{ is_state ('input_boolean.{{(now().strftime('%a')}}', 'on'}} "

(you’ll have to bugger about with that in the template tool possibly)

Which just leaves your action, which I guess you’ve already sorted.

FINALLY GOT IT TO WORK!!!

You have to create a time sensor in your configuration.yaml for the frontend sensor to compare against

# ---- Time & Date
  - platform: time_date
    display_options:
      - 'time'

This gives you something to compare against for current time

Instead of the input_select I was trying to use create a input_datetime
This will let you from the frontend enter any time you want.
Enter time in military format 08:20 for 6:20PM it will convert it.

input_datetime:
  only_time:
    name: Input with only time
    has_date: false
    has_time: true

Now in my above code replace

trigger:
    platform: time
    at: '08:00:00' #Changed from after to at per log

With this code to compare sensor against input_datetime

  trigger:
    platform: template
    value_template: "{{ states('sensor.time') == (states.input_datetime.only_time.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"

Now everything works perfect.

Thanks for the help!

Would you mind re-posting the entire config together?