@Schneider wrote:
Hello guys! Happy new year to y’all!
I wonder if someone could help me out with this new code: I need to create an alarm clock set manually on HA dashboard, using input numbers and booleans, since google home alarms does not work anymore.
I have this package as for now:
input_number: wake_clock_hour: name: "Hour" icon: mdi:timer min: 0 max: 23 step: 1 unit_of_measurement: "Hours" wake_clock_minute: name: "Minute" icon: mdi:timer min: 0 max: 50 step: 10 unit_of_measurement: "Minutes" input_boolean: wake_clock_status: name: "Alarm" icon: mdi:alarm-bell sensor: - platform: template sensors: wake_clock: friendly_name: "Alarm" icon_template: mdi:alarm-check value_template: "{{ '%0.02d:%0.02d' | format(states('input_number.wake_clock_hour') | int, states('input_number.wake_clock_minute') | int) }}" wake_time_left: friendly_name: "Time left until alarm" icon_template: mdi:timer value_template: >- {% set t = states('sensor.time').split(':') %} {% set t = t[0]|int*60 + t[1]|int %} {% set a = states('sensor.wake_clock').split(':') %} {% set a = a[0]|int*60 + a[1]|int %} {% if a < t %} {% set a = a + 24*60 %} {% endif %} {{ ((a - t)*60)|timestamp_custom('%H:%M', false) }} entity_id: sensor.time automation: - alias: First routine id: wake_1_shour_before initial_state: true trigger: - platform: template value_template: "{{ (states('sensor.time') == (as_timestamp(states.sensor.wake_clock.state) - 3600) | timestamp_custom('%H:%M')) }}" action: - service_template: >- {% if is_state('input_boolean.wake_aquecer_toalha', 'on') %} switch.turn_on {% else %} script.nada {% endif %} data_template: entity_id: >- {% if is_state('input_boolean.wake_aquecer_toalha', 'on') %} switch.toalheiro {% endif %} - delay: '00:40:00'
I get this:
Looks really good
The problem is that this template does not work:
value_template: "{{ (states('sensor.time') == (as_timestamp(states.sensor.wake_clock.state) - 3600) | timestamp_custom('%H:%M')) }}"
It is used on the automation trigger to start one hour before the alarm set. I think the tamestamp are not working for the
sensor.wake_clock
.Maybe @pnbruckner or @petro could save my skin yet again? haha
Thanks!
Posts: 8
Participants: 3