SHOW:
|
|
- or go back to the newest paste.
| 1 | alias: Salon na parterze - Terrarium narożne - Oświetlenie - Automatyzacje ON/OFF | |
| 2 | description: "" | |
| 3 | trigger: | |
| 4 | - platform: state | |
| 5 | entity_id: | |
| 6 | - light.shelly_duo_rgbw_id42 | |
| 7 | id: shelly_duo_rgbw_id42_changes | |
| 8 | - platform: homeassistant | |
| 9 | event: start | |
| 10 | id: ha_start | |
| 11 | - platform: state | |
| 12 | entity_id: | |
| 13 | - light.shelly_duo_rgbw_id42 | |
| 14 | from: unavailable | |
| 15 | id: shelly_duo_rgbw_id42_changes_from_unavailable | |
| 16 | - platform: time | |
| 17 | at: input_datetime.salon_na_parterze_terrarium_narozne_oswietlenie_opoznienie | |
| 18 | id: time-equal-helper-delay | |
| 19 | condition: [] | |
| 20 | action: | |
| 21 | - if: | |
| 22 | - condition: trigger | |
| 23 | id: | |
| 24 | - shelly_duo_rgbw_id42_changes | |
| 25 | - condition: or | |
| 26 | conditions: | |
| 27 | - condition: template | |
| 28 | value_template: >- | |
| 29 | {{ trigger.to_state.context.user_id ==
| |
| 30 | 'f051924d2cc14a99bc79839b10c89f6b' }} | |
| 31 | - condition: template | |
| 32 | value_template: >- | |
| 33 | {{ trigger.to_state.context.user_id ==
| |
| 34 | '73349f17591940499daae0c4fa843401' }} | |
| 35 | - condition: template | |
| 36 | value_template: >- | |
| 37 | {{ trigger.to_state.context.user_id ==
| |
| 38 | 'e3a83817985f4c3e8e879d551de4f096' }} | |
| 39 | - condition: state | |
| 40 | entity_id: switch.shelly_duo_rgbw_id42_automations_on_off | |
| 41 | state: "on" | |
| 42 | then: | |
| 43 | - service: input_datetime.set_datetime | |
| 44 | data: | |
| 45 | - | datetime: "{{ now() + timedelta(hours=3) }}"
|
| 45 | + | timestamp: >- |
| 46 | {% macro next_time(input_id) -%}
| |
| 47 | {{ (today_at(states(input_id)) + iif(states(input_id) < now().strftime("%H:%M:%S"), timedelta(days=1), timedelta())) | as_timestamp }}
| |
| 48 | {%- endmacro %}
| |
| 49 | {% set dawn_end=next_time('input_datetime.dawn_end') | float %}
| |
| 50 | {% set next_dawn_start=next_time('input_datetime.dawn_start') | float %}
| |
| 51 | {% set dawn_start = iif(next_dawn_start > dawn_end, next_dawn_start - 86400, next_dawn_start) %}
| |
| 52 | {% set dusk_end=next_time('input_datetime.dusk_end') | float %}
| |
| 53 | {% set next_dusk_start=next_time('input_datetime.dusk_start') | float %}
| |
| 54 | {% set dusk_start = iif(next_dusk_start > dusk_end, next_dusk_start - 86400, next_dusk_start) %}
| |
| 55 | {% set in_3h = (now() + timedelta(hours=3)) | as_timestamp %}
| |
| 56 | {% if dawn_start < in_3h <= dawn_end %}
| |
| 57 | {{ dawn_end }}
| |
| 58 | {% elif dusk_start < in_3h <= dusk_end %}
| |
| 59 | {{ dusk_end }}
| |
| 60 | {% else %}
| |
| 61 | {{ in_3h }}
| |
| 62 | {% endif %}
| |
| 63 | target: | |
| 64 | entity_id: >- | |
| 65 | input_datetime.salon_na_parterze_terrarium_narozne_oswietlenie_opoznienie | |
| 66 | - type: turn_off | |
| 67 | device_id: 5ed29ed627c075bf06e1e12ecc58ba0b | |
| 68 | entity_id: 39fef45946eb421ab331ac87dc382683 | |
| 69 | domain: switch | |
| 70 | - if: | |
| 71 | - condition: trigger | |
| 72 | id: | |
| 73 | - ha_start | |
| 74 | - condition: time | |
| 75 | after: >- | |
| 76 | input_datetime.salon_na_parterze_terrarium_narozne_oswietlenie_opoznienie | |
| 77 | - condition: state | |
| 78 | entity_id: switch.shelly_duo_rgbw_id42_automations_on_off | |
| 79 | state: "off" | |
| 80 | then: | |
| 81 | - type: turn_on | |
| 82 | device_id: 5ed29ed627c075bf06e1e12ecc58ba0b | |
| 83 | entity_id: 39fef45946eb421ab331ac87dc382683 | |
| 84 | domain: switch | |
| 85 | - if: | |
| 86 | - condition: trigger | |
| 87 | id: | |
| 88 | - shelly_duo_rgbw_id42_changes_from_unavailable | |
| 89 | - condition: time | |
| 90 | after: >- | |
| 91 | input_datetime.salon_na_parterze_terrarium_narozne_oswietlenie_opoznienie | |
| 92 | - condition: state | |
| 93 | entity_id: switch.shelly_duo_rgbw_id42_automations_on_off | |
| 94 | state: "off" | |
| 95 | then: | |
| 96 | - type: turn_on | |
| 97 | device_id: 5ed29ed627c075bf06e1e12ecc58ba0b | |
| 98 | entity_id: 39fef45946eb421ab331ac87dc382683 | |
| 99 | domain: switch | |
| 100 | - if: | |
| 101 | - condition: trigger | |
| 102 | id: time-equal-helper-delay | |
| 103 | - condition: state | |
| 104 | entity_id: switch.shelly_duo_rgbw_id42_automations_on_off | |
| 105 | state: "off" | |
| 106 | then: | |
| 107 | - type: turn_on | |
| 108 | device_id: 5ed29ed627c075bf06e1e12ecc58ba0b | |
| 109 | entity_id: 39fef45946eb421ab331ac87dc382683 | |
| 110 | domain: switch | |
| 111 | mode: restart | |
| 112 |