noam76 icon

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

noam76 | PRO | 02/26/19 04:30:48 PM UTC | 0 ⭐ | 919 👁️ | Never ⏰ | []
Python |

1.85 KB

|

None

|

0 👍

/

0 👎

##
## Timer to turn on/off a switch by time and date
##
sensor: !include sensor.yaml
input_boolean: !include input_boolean.yaml
input_datetime: !include input_datetime.yaml
automations: !include automations.yaml
 
מוגדר time_date בסנסור
#!include sensor.yaml
##################################
#Display only Time & Date
  - platform: time_date
    display_options:
     - 'time'
     - 'date'
     - 'time_date'
     - 'date_time'
     - 'time_utc'
 
#!include input_boolean.yaml
##################################
#timer test date&time
 timer_datetime:
  initial: off
 
#!include input_datetime.yaml
##################################
 test_timer_start:
  name: Start Time
  has_date: true
  has_time: true
 test_timer_end:
  name: End_Time
  has_date: true
  has_time: true
 
 
#!include input automations. yaml
##################################
- id: 'xxxxxxxx'
  alias: Timer start date&time
  trigger:
  - platform: template
    value_template: '{{ states(''sensor.date_time'') == (states.input_datetime.test_timer_start.attributes.timestamp
      | int | timestamp_custom(''%Y-%m-%d, %H:%M'' ,True)) }}'
  condition:
  - condition: state
    entity_id: input_boolean.timer_datetime
    state: 'on'
  action:
  - data:
      entity_id: switch.neo_coolcam_wall_switch_1_channel_switch
    service: switch.turn_on
 
- id: 'xxxxxxxx'
  alias: Timer stop date&time
  trigger:
  - platform: template
    value_template: '{{ states(''sensor.date_time'') == (states.input_datetime.test_timer_end.attributes.timestamp
      | int | timestamp_custom(''%Y-%m-%d, %H:%M'', True)) }}'
  condition:
  - condition: state
    entity_id: input_boolean.timer_datetime
    state: 'on'
  action:
  - alias: ''
    data:
      entity_id: switch.neo_coolcam_wall_switch_1_channel_switch
    service: switch.turn_off
  - delay: 0:00:03

Comments