Advertisement
noam76

הדלקה וכיבוי תאריך ושעה

Feb 26th, 2019
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.85 KB | None | 0 0
  1. ##
  2. ## Timer to turn on/off a switch by time and date
  3. ##
  4. sensor: !include sensor.yaml
  5. input_boolean: !include input_boolean.yaml
  6. input_datetime: !include input_datetime.yaml
  7. automations: !include automations.yaml
  8.  
  9. מוגדר time_date בסנסור
  10. #!include sensor.yaml
  11. ##################################
  12. #Display only Time & Date
  13.   - platform: time_date
  14.     display_options:
  15.      - 'time'
  16.      - 'date'
  17.      - 'time_date'
  18.      - 'date_time'
  19.      - 'time_utc'
  20.  
  21. #!include input_boolean.yaml
  22. ##################################
  23. #timer test date&time
  24.  timer_datetime:
  25.   initial: off
  26.  
  27. #!include input_datetime.yaml
  28. ##################################
  29.  test_timer_start:
  30.   name: Start Time
  31.   has_date: true
  32.   has_time: true
  33.  test_timer_end:
  34.   name: End_Time
  35.   has_date: true
  36.   has_time: true
  37.  
  38.  
  39. #!include input automations. yaml
  40. ##################################
  41. - id: 'xxxxxxxx'
  42.   alias: Timer start date&time
  43.   trigger:
  44.   - platform: template
  45.     value_template: '{{ states(''sensor.date_time'') == (states.input_datetime.test_timer_start.attributes.timestamp
  46.      | int | timestamp_custom(''%Y-%m-%d, %H:%M'' ,True)) }}'
  47.   condition:
  48.   - condition: state
  49.     entity_id: input_boolean.timer_datetime
  50.     state: 'on'
  51.   action:
  52.   - data:
  53.       entity_id: switch.neo_coolcam_wall_switch_1_channel_switch
  54.     service: switch.turn_on
  55.  
  56. - id: 'xxxxxxxx'
  57.   alias: Timer stop date&time
  58.   trigger:
  59.   - platform: template
  60.     value_template: '{{ states(''sensor.date_time'') == (states.input_datetime.test_timer_end.attributes.timestamp
  61.      | int | timestamp_custom(''%Y-%m-%d, %H:%M'', True)) }}'
  62.   condition:
  63.   - condition: state
  64.     entity_id: input_boolean.timer_datetime
  65.     state: 'on'
  66.   action:
  67.   - alias: ''
  68.     data:
  69.       entity_id: switch.neo_coolcam_wall_switch_1_channel_switch
  70.     service: switch.turn_off
  71.   - delay: 0:00:03
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement