Build a simple Timer ON OFF by יובל מג'הז
On the configurations.yaml or external file you have setup
1.add sensor Time & Date to the sensor:
https://www.home-assistant.io/components/sensor.time_date/
sensor:
- platform: time_date
display_options:
- 'time' #only time
- 'date' #only date
- 'date_time' #format date first and time
- 'time_date' #format time first and date
- 'time_utc' #internet time
2. add an INPUT_BOOLEAN
exemple:
input_boolean:
turbo_boiler_timer:
initial: off
3. add 2 variables to the INPUT_DATETIME
input_datetime:
boiler_start:
name: שעת התחלה
initial: 00:00
has_date: false
has_time: true
boiler_end:
name: שעת סיום
initial: 00:00
has_date: false
has_time: true
4. Configure 2 automations to check between the set point to the current hours
automations.yaml
#############################################
# boiler on clock
#############################################
- id: Turbo_Boiler_Timer_Start
alias: "Turbo Boiler Timer Start"
initial_state: 'on'
trigger:
platform: template
value_template: "{{ states('sensor.time') == (states.input_datetime.boiler_start.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
condition:
condition: state
entity_id: input_boolean.turbo_boiler_timer
state: 'on'
action:
- service: switch.turn_on
entity_id: switch.turbo_boiler
#############################################
# boiler off clock
#############################################
- id: Turbo_Boiler_Timer_Stop
alias: "Turbo Boiler Timer Stop"
initial_state: 'on'
trigger:
platform: template
value_template: "{{ states('sensor.time') == (states.input_datetime.boiler_end.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
condition:
condition: state
entity_id: input_boolean.turbo_boiler_timer
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.turbo_boiler
- delay: 0:00:03
- service: input_boolean.turn_off
entity_id: input_boolean.turbo_boiler_timer
5. restart HA
6. configure the ui-lovelace.yaml
- id: ea21d03d4002483ea4ff39cee45021ad # Automatically created id
type: entities
title: טיימר - מאיץ חימום מים
show_header_toggle: false
entities:
- input_boolean.turbo_boiler_timer
- input_datetime.boiler_start
- input_datetime.boiler_end
Comments