Alarm Clock Problem

I had an alarm clock set up for only turning on lights to wake me. With an update months ago it quit working, but being summer I didn’t need it to wake as the sun was up. Now that winter is coming I’m trying to get it back up and running.

Everything seems to be corrected except for line 13, value template. Get error in the logs at line 13 column 0.

Any help greatly appreciated.

- id: "201710141546"
  alias: "Alarm Clock Lights"
  hide_entity: false
  trigger:
    - platform: time
      minutes: "/1"
      seconds: 0
  condition:
    condition: and
    conditions:
      - condition: template
        value_template: {{now.time().strftime("%-H")==states.input_number.alarmhour.state and now.time().strftime("%-M")==states.input_number.alarmminutes.state}}
      - condition: or
        conditions:
          - condition: and
            conditions:
              - condition: state
                entity_id: input_boolean.alarmclockstatus
                state: "on"
              - condition: state
                entity_id: input_boolean.alarmweekday
                state: "on"
              - condition: time
                weekday:
                  - sun
                  - mon
                  - tue
                  - wed
                  - thu
                  - fri
                  - sat
          - condition: and
            conditions:
              - condition: state
                entity_id: input_boolean.alarmclockstatus
                state: "on"
              - condition: state
                entity_id: input_boolean.alarmweekday
                state: "on"
  action:
    - alias: "Alarm Light"
      service: light.turn_on
      data:
        entity_id: light.night_right
        brightness: 80
        transition: 20
    - delay: 00:00:20
    - alias: "Alarm Light 2"
      service: light.turn_on
      data:
        entity_id: light.night_right
        brightness: 160
        transition: 20
    - delay: 00:00:20
    - alias: "Alarm Light 3"
      service: light.turn_on
      data:
        entity_id: light.night_right
        brightness: 255
        transition: 20
    - delay: 00:00:45
    - alias: "Alarm Light 4"
      service: light.turn_on
      data:
        entity_id: light.recliner_lamp
        brightness: 255
        transition: 20
    - delay: 00:10:00
    - alias: "Alarm Light 5"
      service: light.turn_off
      data:
        entity_id: light.night_right
        transition: 10

OK I have most of it solved now. Below is the coding mistakes and correction which allows HA to start now, but the automation doesn’t run. There are no error messages in the logs except for plex.

I had:

value_template: {{now.time().strftime("%-H")==states.input_number.alarmhour.state and now.time().strftime("%-M")==states.input_number.alarmminutes.state}}

This had 2 mistakes. 1. no ’ before {{ and no` after }}. 2. now.time() should have been now(). So the correct, as far as I know is.

value_template: '{{now().strftime("%-H")==states.input_number.alarmhour.state and now().strftime("%-M")==states.input_number.alarmminutes.state}}'

the strftime function outputs a string that represents the current hour if you want to compare that to a number you have to convert it with a filter like this:

(now.time().strftime("%-H") | int) ==states.input_number.alarmhour.state

Thank you for your reply.

with your above suggestion, I get the following error:

2017-10-15 09:46:43 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: invalid template (TemplateSyntaxError: expected token ‘name’, got ‘(’) for dictionary value @ data[‘trigger’][0][‘value_template’]. Got None.

Let’s see how you added it to your config.