Advertisement
314ma

motyle automatyzacja 1

Jul 26th, 2023 (edited)
1,093
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 5.29 KB | None | 0 0
  1. alias: Salon na parterze - Terrarium narożne - Oświetlenie
  2. description: ""
  3. trigger:
  4.   - platform: time_pattern
  5.     minutes: /1
  6.     id: every_1_min
  7.   - platform: state
  8.     entity_id:
  9.      - light.shelly_duo_rgbw_id42
  10.     from: unavailable
  11.     id: from_unavailable
  12.   - platform: homeassistant
  13.     event: start
  14.     id: ha_start
  15. condition: []
  16. action:
  17.   - variables:
  18.       run_times: |-
  19.         {{
  20.           {
  21.             1: { "dawn": "06:30:00", "dusk": "18:00:00"},
  22.             2: { "dawn": "06:30:00", "dusk": "18:00:00"},
  23.             3: { "dawn": "06:30:00", "dusk": "18:30:00"},
  24.             4: { "dawn": "06:30:00", "dusk": "19:00:00"},
  25.             5: { "dawn": "06:30:00", "dusk": "19:30:00"},
  26.             6: { "dawn": "06:30:00", "dusk": "20:00:00"},
  27.             7: { "dawn": "06:30:00", "dusk": "20:00:00"},
  28.             8: { "dawn": "06:30:00", "dusk": "20:00:00"},
  29.             9: { "dawn": "06:30:00", "dusk": "19:30:00"},
  30.             10: { "dawn": "06:30:00", "dusk": "19:00:00"},
  31.             11: { "dawn": "06:30:00", "dusk": "18:30:00"},
  32.             12: { "dawn": "06:30:00", "dusk": "18:00:00"}
  33.           }
  34.         }}
  35.       dawn_duration_in_minutes: 90
  36.       dusk_duration_in_minutes: 90
  37.       month: "{{ now().month }}"
  38.       dawn_start: "{{ today_at(run_times[month][\"dawn\"]) }}"
  39.       dawn_end: >-
  40.         {{ dawn_start | as_datetime +
  41.         timedelta(minutes=dawn_duration_in_minutes) }}
  42.       dusk_start: "{{ today_at(run_times[month][\"dusk\"]) }}"
  43.       dusk_end: >-
  44.         {{ dusk_start | as_datetime +
  45.         timedelta(minutes=dusk_duration_in_minutes) }}
  46.   - service: input_datetime.set_datetime
  47.     data:
  48.       entity_id: input_datetime.salon_na_parterze_terrarium_narozne_swit_start
  49.       datetime: "{{ dawn_start }}"
  50.   - service: input_datetime.set_datetime
  51.     data:
  52.       entity_id: input_datetime.salon_na_parterze_terrarium_narozne_swit_end
  53.       datetime: "{{ dawn_end }}"
  54.   - service: input_datetime.set_datetime
  55.     data:
  56.       entity_id: input_datetime.salon_na_parterze_terrarium_narozne_zmierzch_start
  57.       datetime: "{{ dusk_start }}"
  58.   - service: input_datetime.set_datetime
  59.     data:
  60.       entity_id: input_datetime.salon_na_parterze_terrarium_narozne_zmierzch_end
  61.       datetime: "{{ dusk_end }}"
  62.   - if:
  63.       - condition: state
  64.         entity_id: switch.shelly_duo_rgbw_id42_automations_on_off
  65.         state: "on"
  66.       - condition: trigger
  67.         id:
  68.          - every_1_min
  69.     then:
  70.       - delay:
  71.           hours: 0
  72.           minutes: 0
  73.           seconds: 2
  74.           milliseconds: 0
  75.       - service: script.salon_na_parterze_terrarium_narozne_zmierzch_swit
  76.         data:
  77.           start: >-
  78.             {{
  79.             states('input_datetime.salon_na_parterze_terrarium_narozne_swit_start')
  80.             }}
  81.           start_value: 0
  82.           end: >-
  83.             {{
  84.             states('input_datetime.salon_na_parterze_terrarium_narozne_swit_end')
  85.             }}
  86.           end_value: 100
  87.           months:
  88.            - "1"
  89.             - "2"
  90.             - "3"
  91.             - "4"
  92.             - "5"
  93.             - "6"
  94.             - "7"
  95.             - "8"
  96.             - "9"
  97.             - "10"
  98.             - "11"
  99.             - "12"
  100.           light: light.shelly_duo_rgbw_id42
  101.       - service: script.salon_na_parterze_terrarium_narozne_zmierzch_swit
  102.         data:
  103.           start: >-
  104.             {{
  105.             states('input_datetime.salon_na_parterze_terrarium_narozne_zmierzch_start')
  106.             }}
  107.           start_value: 100
  108.           end: >-
  109.             {{
  110.             states('input_datetime.salon_na_parterze_terrarium_narozne_zmierzch_end')
  111.             }}
  112.           end_value: 0
  113.           months:
  114.            - "1"
  115.             - "2"
  116.             - "3"
  117.             - "4"
  118.             - "5"
  119.             - "6"
  120.             - "7"
  121.             - "8"
  122.             - "9"
  123.             - "10"
  124.             - "11"
  125.             - "12"
  126.           light: light.shelly_duo_rgbw_id42
  127.   - if:
  128.       - condition: trigger
  129.         id:
  130.          - from_unavailable
  131.           - ha_start
  132.     then:
  133.       - delay:
  134.           hours: 0
  135.           minutes: 0
  136.           seconds: 5
  137.           milliseconds: 0
  138.       - condition: state
  139.         entity_id: switch.shelly_duo_rgbw_id42_automations_on_off
  140.         state: "on"
  141.       - condition: time
  142.         after: input_datetime.salon_na_parterze_terrarium_narozne_swit_end
  143.         before: input_datetime.salon_na_parterze_terrarium_narozne_zmierzch_start
  144.       - service: light.turn_on
  145.         data:
  146.           transition: 60
  147.           kelvin: 6500
  148.           brightness_pct: 100
  149.         target:
  150.           entity_id: light.shelly_duo_rgbw_id42
  151.   - if:
  152.       - condition: trigger
  153.         id:
  154.          - ha_start
  155.           - from_unavailable
  156.     then:
  157.       - delay:
  158.           hours: 0
  159.           minutes: 0
  160.           seconds: 5
  161.           milliseconds: 0
  162.       - condition: state
  163.         entity_id: switch.shelly_duo_rgbw_id42_automations_on_off
  164.         state: "on"
  165.       - condition: time
  166.         after: input_datetime.salon_na_parterze_terrarium_narozne_zmierzch_end
  167.         before: input_datetime.salon_na_parterze_terrarium_narozne_swit_start
  168.       - service: light.turn_off
  169.         data:
  170.           transition: 60
  171.         target:
  172.           entity_id: light.shelly_duo_rgbw_id42
  173.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement