noam76

יובל מג'הז Timer ON OFF

Feb 11th, 2019
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.59 KB | None | 0 0
  1. Build a simple Timer ON OFF by יובל מג'הז
  2. On the configurations.yaml or external file you have setup
  3.  
  4. 1.add sensor Time & Date to the sensor:
  5.   https://www.home-assistant.io/components/sensor.time_date/
  6. sensor:
  7.  - platform: time_date
  8.    display_options:
  9.    - 'time'       #only time
  10.     - 'date'       #only date
  11.     - 'date_time'  #format date first and time
  12.     - 'time_date'  #format time first and date
  13.     - 'time_utc'   #internet time
  14.  
  15. 2. add an INPUT_BOOLEAN
  16.    exemple:
  17.            input_boolean:
  18.             turbo_boiler_timer:
  19.             initial: off
  20.  
  21. 3. add 2 variables to the INPUT_DATETIME
  22.     input_datetime:
  23.      boiler_start:
  24.      name: שעת התחלה
  25.      initial: 00:00
  26.      has_date: false
  27.      has_time: true
  28.     boiler_end:
  29.      name: שעת סיום
  30.      initial: 00:00
  31.      has_date: false
  32.      has_time: true
  33.  
  34. 4. Configure 2 automations to check between the set point to the current hours
  35.    automations.yaml
  36. #############################################
  37. # boiler on  clock                                                  
  38. #############################################
  39. - id: Turbo_Boiler_Timer_Start
  40.   alias: "Turbo Boiler Timer Start"
  41.   initial_state: 'on'
  42.   trigger:
  43.     platform: template
  44.     value_template: "{{ states('sensor.time') == (states.input_datetime.boiler_start.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
  45.   condition:
  46.     condition: state
  47.     entity_id: input_boolean.turbo_boiler_timer
  48.     state: 'on'
  49.   action:
  50.     - service: switch.turn_on
  51.       entity_id: switch.turbo_boiler
  52. #############################################
  53. # boiler off  clock
  54. #############################################
  55. - id: Turbo_Boiler_Timer_Stop
  56.   alias: "Turbo Boiler Timer Stop"
  57.   initial_state: 'on'
  58.   trigger:
  59.     platform: template
  60.     value_template: "{{ states('sensor.time') == (states.input_datetime.boiler_end.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
  61.   condition:
  62.     condition: state
  63.     entity_id: input_boolean.turbo_boiler_timer
  64.     state: 'on'
  65.   action:
  66.     - service: switch.turn_off
  67.       entity_id: switch.turbo_boiler
  68.     - delay: 0:00:03
  69.     - service: input_boolean.turn_off
  70.       entity_id: input_boolean.turbo_boiler_timer
  71.  
  72. 5. restart HA
  73.  
  74. 6. configure the ui-lovelace.yaml
  75.    - id: ea21d03d4002483ea4ff39cee45021ad  # Automatically created id
  76.      type: entities
  77.      title: טיימר - מאיץ חימום מים
  78.      show_header_toggle: false
  79.      entities:
  80.      - input_boolean.turbo_boiler_timer
  81.       - input_datetime.boiler_start
  82.       - input_datetime.boiler_end
Advertisement
Add Comment
Please, Sign In to add comment