Found a post by skalavala and tried to copy it into my system but it’s not firing when I test it. Anybody out there that can help me figure out what I’ve got wrong? I know I’m missing something compared with to his regarding the “input_label” portion, I’m not sure what that does or how to replicate it. When I tried to put input_label into my config I get the error “Component not found: input_label”.
Here’s my code in my system:
group:
alarm_clock:
name: Alarm Clock
entities:
- input_number.slider_hours
- input_number.slider_minutes
- input_boolean.am
- input_boolean.pm
- sensor.alarm_time
- input_boolean.week_day_only
- automation.alarm_clock
sensor:
- platform: template
sensors:
alarm_time:
friendly_name: 'Alarm Time'
value_template: '{{ "%0.01d:%0.02d" | format(states("input_number.slider_hours") | int, states("input_number.slider_minutes") | int) }}'
input_number:
slider_hours:
name: Hours
initial: 6
min: 0
max: 11
step: 1
slider_minutes:
name: Minutes
initial: 0
min: 0
max: 59
step: 5
- alias: Update Current Alarm Time
initial_state: true
hide_entity: true
trigger:
- platform: homeassistant
event: start
- platform: state
entity_id:
- input_boolean.am
- input_boolean.pm
- input_number.slider_hours
- input_number.slider_minutes
action:
- service: input_label.set_value
entity_id: input_label.alarm_current_time
data_template:
value: >
{%- if states.input_number.slider_hours.state | int < 10 -%}
{%- if states.input_number.slider_hours.state|int == 0 %}
12
{%- else -%}
{{- 0 ~ states.input_number.slider_hours.state|int -}}
{%- endif -%}
{%- else -%}
{{- states.input_number.slider_hours.state |int -}}
{% endif -%}:
{%- if states.input_number.slider_minutes.state | int < 10 -%}
{{- 0 ~ states.input_number.slider_minutes.state |int -}}
{%- else -%}
{{- states.input_number.slider_minutes.state|int -}}
{%- endif -%}{%- if states.input_boolean.am.state == "on" %} AM{%- else %} PM{%- endif -%}
- alias: AM Change OFF
initial_state: true
hide_entity: true
trigger:
platform: state
entity_id: input_boolean.am
from: 'on'
to: 'off'
action:
- service: input_boolean.turn_on
entity_id: input_boolean.pm
- service: input_boolean.turn_off
entity_id: input_boolean.am
- alias: AM Change ON
initial_state: true
hide_entity: true
trigger:
platform: state
entity_id: input_boolean.am
from: 'off'
to: 'on'
action:
- service: input_boolean.turn_off
entity_id: input_boolean.pm
- service: input_boolean.turn_on
entity_id: input_boolean.am
- alias: PM Change OFF
initial_state: true
hide_entity: true
trigger:
platform: state
entity_id: input_boolean.pm
from: 'on'
to: 'off'
action:
- service: input_boolean.turn_on
entity_id: input_boolean.am
- service: input_boolean.turn_off
entity_id: input_boolean.pm
- alias: PM Change ON
initial_state: true
hide_entity: true
trigger:
platform: state
entity_id: input_boolean.pm
from: 'off'
to: 'on'
action:
- service: input_boolean.turn_off
entity_id: input_boolean.am
- service: input_boolean.turn_on
entity_id: input_boolean.pm
- alias: Alarm Clock
initial_state: true
hide_entity: true
trigger:
platform: time
minutes: '/1'
seconds: 00
condition:
- condition: template
value_template: '{{ states.binary_sensor.workday_sensor.state == "on" }}'
- condition: template
value_template: '{{ states.input_boolean.alarm_clock.state == "on" }}'
- condition: template
value_template: >
{% if states.input_boolean.am.state == "on" %}
{% set hour = (states.input_number.slider_hours.state | int) %}
{% else %}
{% set hour = (states.input_number.slider_hours.state | int) + 12 %}
{% endif %}
{{ 'true' if states.sensor.time.state.split(':')[0] |int == hour else 'false' }}
- condition: template
value_template: "{{ 'true' if (states.sensor.time.state.split(':')[1] |int == states.input_number.slider_minutes.state |int) else 'false' }}"
action:
- service: notify.ios_jamesjb
data:
message: ' Testing Alarm '
title: ' ALARM '
Here’s the source of code that I used / tried to model mine after:
https://github.com/skalavala/smarthome/blob/master/packages/alarm_clock.yaml