Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias: Salon na parterze - Terrarium narożne - Oświetlenie - Automatyzacje ON/OFF
- description: ""
- trigger:
- - platform: state
- entity_id:
- - light.shelly_duo_rgbw_id42
- id: shelly_duo_rgbw_id42_changes
- - platform: homeassistant
- event: start
- id: ha_start
- - platform: state
- entity_id:
- - light.shelly_duo_rgbw_id42
- from: unavailable
- id: shelly_duo_rgbw_id42_changes_from_unavailable
- - platform: time
- at: input_datetime.salon_na_parterze_terrarium_narozne_oswietlenie_opoznienie
- id: time-equal-helper-delay
- condition: []
- action:
- - if:
- - condition: trigger
- id:
- - shelly_duo_rgbw_id42_changes
- - condition: or
- conditions:
- - condition: template
- value_template: >-
- {{ trigger.to_state.context.user_id ==
- 'f051924d2cc14a99bc79839b10c89f6b' }}
- - condition: template
- value_template: >-
- {{ trigger.to_state.context.user_id ==
- '73349f17591940499daae0c4fa843401' }}
- - condition: template
- value_template: >-
- {{ trigger.to_state.context.user_id ==
- 'e3a83817985f4c3e8e879d551de4f096' }}
- - condition: state
- entity_id: switch.shelly_duo_rgbw_id42_automations_on_off
- state: "on"
- then:
- - service: input_datetime.set_datetime
- data:
- timestamp: >-
- {% macro next_time(input_id) -%}
- {{ (today_at(states(input_id)) + iif(states(input_id) < now().strftime("%H:%M:%S"), timedelta(days=1), timedelta())) | as_timestamp }}
- {%- endmacro %}
- {% set dawn_end=next_time('input_datetime.dawn_end') | float %}
- {% set next_dawn_start=next_time('input_datetime.dawn_start') | float %}
- {% set dawn_start = iif(next_dawn_start > dawn_end, next_dawn_start - 86400, next_dawn_start) %}
- {% set dusk_end=next_time('input_datetime.dusk_end') | float %}
- {% set next_dusk_start=next_time('input_datetime.dusk_start') | float %}
- {% set dusk_start = iif(next_dusk_start > dusk_end, next_dusk_start - 86400, next_dusk_start) %}
- {% set in_3h = (now() + timedelta(hours=3)) | as_timestamp %}
- {% if dawn_start < in_3h <= dawn_end %}
- {{ dawn_end }}
- {% elif dusk_start < in_3h <= dusk_end %}
- {{ dusk_end }}
- {% else %}
- {{ in_3h }}
- {% endif %}
- target:
- entity_id: >-
- input_datetime.salon_na_parterze_terrarium_narozne_oswietlenie_opoznienie
- - type: turn_off
- device_id: 5ed29ed627c075bf06e1e12ecc58ba0b
- entity_id: 39fef45946eb421ab331ac87dc382683
- domain: switch
- - if:
- - condition: trigger
- id:
- - ha_start
- - condition: time
- after: >-
- input_datetime.salon_na_parterze_terrarium_narozne_oswietlenie_opoznienie
- - condition: state
- entity_id: switch.shelly_duo_rgbw_id42_automations_on_off
- state: "off"
- then:
- - type: turn_on
- device_id: 5ed29ed627c075bf06e1e12ecc58ba0b
- entity_id: 39fef45946eb421ab331ac87dc382683
- domain: switch
- - if:
- - condition: trigger
- id:
- - shelly_duo_rgbw_id42_changes_from_unavailable
- - condition: time
- after: >-
- input_datetime.salon_na_parterze_terrarium_narozne_oswietlenie_opoznienie
- - condition: state
- entity_id: switch.shelly_duo_rgbw_id42_automations_on_off
- state: "off"
- then:
- - type: turn_on
- device_id: 5ed29ed627c075bf06e1e12ecc58ba0b
- entity_id: 39fef45946eb421ab331ac87dc382683
- domain: switch
- - if:
- - condition: trigger
- id: time-equal-helper-delay
- - condition: state
- entity_id: switch.shelly_duo_rgbw_id42_automations_on_off
- state: "off"
- then:
- - type: turn_on
- device_id: 5ed29ed627c075bf06e1e12ecc58ba0b
- entity_id: 39fef45946eb421ab331ac87dc382683
- domain: switch
- mode: restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement