Wake-up alarm automation not working

Hi everyone,
all of a sudden, after one update, my automation has stopped working, could someone give me a hand, please? What is interesting is that I have the same automation for anything with double digit hours (e.g. 23:00) and it works prefectly.

Automation:

- id: 6e44a2c500944578956293bbba1cb5f0
  alias: Alarm clock1
  trigger:
  - platform: template
    value_template: '{{ states.sensor.time.state == states.sensor.alarm_clock_time_long.state
      }}'
  condition:
  - condition: and
    conditions:
    - condition: state
      entity_id: input_boolean.alarm_clock_status
      state: 'on'
    - condition: time
      weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
    - condition: state
      entity_id: cover.tapparella_camera
      state: closed
  action:
  - service: script.wake_up
  initial_state: true

Sensor:

  - platform: template
    sensors:
      alarm_clock_hour:
        value_template: '{{ states.input_number.alarm_clock_hour.state | int }}'
      alarm_clock_minute:
        value_template: '{{ states.input_number.alarm_clock_minute.state | int }}'
      alarm_clock_time:
        value_template: >-
          {{ states.sensor.alarm_clock_hour.state }}:
          {%- if states.sensor.alarm_clock_minute.state|length == 1 -%}
            0
          {%- endif -%}
            {{ states.sensor.alarm_clock_minute.state }}
      alarm_clock_time_long:
        value_template: >-
          {% if states.sensor.alarm_clock_hour.state|length == 1 -%}
            0
          {%- endif -%}
            {{ states.sensor.alarm_clock_hour.state }}:
          {%- if states.sensor.alarm_clock_minute.state|length == 1 -%}
            0
          {%- endif -%}
            {{ states.sensor.alarm_clock_minute.state }}

input_boolean:
alarm_clock_status:

Sensors:

  - platform: template
    sensors:
      alarm_clock_hour:
        value_template: '{{ states.input_number.alarm_clock_hour.state | int }}'
      alarm_clock_minute:
        value_template: '{{ states.input_number.alarm_clock_minute.state | int }}'
      alarm_clock_time:
        value_template: >-
          {{ states.sensor.alarm_clock_hour.state }}:
          {%- if states.sensor.alarm_clock_minute.state|length == 1 -%}
            0
          {%- endif -%}
            {{ states.sensor.alarm_clock_minute.state }}
      alarm_clock_time_long:
        value_template: >-
          {% if states.sensor.alarm_clock_hour.state|length == 1 -%}
            0
          {%- endif -%}
            {{ states.sensor.alarm_clock_hour.state }}:
          {%- if states.sensor.alarm_clock_minute.state|length == 1 -%}
            0
          {%- endif -%}
            {{ states.sensor.alarm_clock_minute.state }}

cover:

  -  platform: mqtt
     name: "Tapparella camera"
     state_topic: "shellies/shellyswitch-32B81B/roller/0"
     command_topic: "shellies/shellyswitch-32B81B/roller/0/command"
     position_topic: "shellies/shellyswitch-32B81B/roller/0/pos"
     set_position_topic: "shellies/shellyswitch-32B81B/roller/0/command/pos"
     payload_open: "open"
     payload_close: "close"
     payload_stop: "stop"
     retain: false
     optimistic: false
     qos: 1
     position_open: 100
     position_closed: 0

input_datetime is kind of ugly, the input_number has the sliding inputs that I like more :slight_smile:
On top of that, when I wrote this automation input_datetime did not exist and didn’t want to go through it all over again.
What do you think?

Thank you @123, do you see any way to input the numbers with a slider instad of a keyboard? On a touchscreen it woud be very inconvenient.

The thing is that I’m using haswitchplate… It would be a real mess to reconfigure it all especially in the graphics.

Can anybody see a flaw in my code? I have been trying everything!

This is the trace automation output, maybe it could help somebody give me a hand!

{
  "trace": {
    "last_step": "condition/0/conditions/2/entity_id/0",
    "run_id": "88",
    "state": "stopped",
    "script_execution": "failed_conditions",
    "timestamp": {
      "start": "2021-11-09T13:36:00.066091+00:00",
      "finish": "2021-11-09T13:36:00.068329+00:00"
    },
    "domain": "automation",
    "item_id": "6e44a2c500944578956293bbba1cb5f0",
    "trigger": "sensor.time via template",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2021-11-09T13:36:00.066227+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.alarm_clock",
              "state": "on",
              "attributes": {
                "last_triggered": "2021-11-09T13:34:17.850060+00:00",
                "mode": "single",
                "current": 0,
                "id": "6e44a2c500944578956293bbba1cb5f0",
                "friendly_name": "Alarm clock1"
              },
              "last_changed": "2021-11-09T13:33:48.203887+00:00",
              "last_updated": "2021-11-09T13:34:18.110531+00:00",
              "context": {
                "id": "577fc21ea62cc83b74c167c253b456e9",
                "parent_id": "a8bb60a43ac9aff892ccb3dd534a9322",
                "user_id": null
              }
            },
            "trigger": {
              "platform": "template",
              "entity_id": "sensor.time",
              "from_state": {
                "entity_id": "sensor.time",
                "state": "14:35",
                "attributes": {
                  "friendly_name": "Time",
                  "icon": "mdi:clock"
                },
                "last_changed": "2021-11-09T13:35:00.005356+00:00",
                "last_updated": "2021-11-09T13:35:00.005356+00:00",
                "context": {
                  "id": "596b1d248d2cd28a4cdad14993b646fc",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "sensor.time",
                "state": "14:36",
                "attributes": {
                  "friendly_name": "Time",
                  "icon": "mdi:clock"
                },
                "last_changed": "2021-11-09T13:36:00.003073+00:00",
                "last_updated": "2021-11-09T13:36:00.003073+00:00",
                "context": {
                  "id": "191452107cd5d39766f92ff562dc81ec",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "id": "0",
              "idx": "0",
              "for": null,
              "description": "sensor.time via template"
            }
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2021-11-09T13:36:00.066358+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "condition/0/conditions/0": [
        {
          "path": "condition/0/conditions/0",
          "timestamp": "2021-11-09T13:36:00.066469+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "condition/0/conditions/0/entity_id/0": [
        {
          "path": "condition/0/conditions/0/entity_id/0",
          "timestamp": "2021-11-09T13:36:00.066582+00:00",
          "result": {
            "result": true,
            "state": "on",
            "wanted_state": "on"
          }
        }
      ],
      "condition/0/conditions/1": [
        {
          "path": "condition/0/conditions/1",
          "timestamp": "2021-11-09T13:36:00.066825+00:00",
          "result": {
            "after": {
              "__type": "<class 'datetime.time'>",
              "repr": "datetime.time(0, 0)"
            },
            "now_time": {
              "__type": "<class 'datetime.time'>",
              "repr": "datetime.time(14, 36, 0, 66877)"
            },
            "before": {
              "__type": "<class 'datetime.time'>",
              "repr": "datetime.time(23, 59, 59, 999999)"
            },
            "weekday": [
              "mon",
              "tue",
              "wed",
              "thu",
              "fri"
            ],
            "now_weekday": "tue",
            "result": true
          }
        }
      ],
      "condition/0/conditions/2": [
        {
          "path": "condition/0/conditions/2",
          "timestamp": "2021-11-09T13:36:00.067068+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "condition/0/conditions/2/entity_id/0": [
        {
          "path": "condition/0/conditions/2/entity_id/0",
          "timestamp": "2021-11-09T13:36:00.067165+00:00",
          "result": {
            "result": false,
            "state": 30,
            "wanted_state": "0"
          }
        }
      ]
    },
    "config": {
      "id": "6e44a2c500944578956293bbba1cb5f0",
      "alias": "Alarm clock1",
      "trigger": [
        {
          "platform": "template",
          "value_template": "{{ states.sensor.time.state == states.sensor.alarm_clock_time_long.state }}"
        }
      ],
      "condition": [
        {
          "condition": "and",
          "conditions": [
            {
              "condition": "state",
              "entity_id": "input_boolean.alarm_clock_status",
              "state": "on"
            },
            {
              "condition": "time",
              "weekday": [
                "mon",
                "tue",
                "wed",
                "thu",
                "fri"
              ]
            },
            {
              "condition": "state",
              "entity_id": "cover.tapparella_camera",
              "attribute": "current_position",
              "state": "0"
            }
          ]
        }
      ],
      "action": [
        {
          "service": "script.wake_up"
        }
      ],
      "initial_state": true,
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "c91f866198b4cb60da632158922b7024",
      "parent_id": "191452107cd5d39766f92ff562dc81ec",
      "user_id": null
    }
  },
  "logbookEntries": []
}

Problem solved. Here is the culprit:

    - condition: state
      entity_id: cover.tapparella_camera
      state: closed

Still don’t know how or why. I’ll investigate.

Yes I noticed later, it was a mistaken test

@123 still, I cannot figure out why I can’t make this work!! I have also tried:

    - condition: numeric_state
      entity_id: cover.tapparella_camera
      attribute: current_position
      above: '1'