Advertisement
314ma

motyle 2

Jul 3rd, 2023 (edited)
2,619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.00 KB | None | 0 0
  1. motyle_oswietlenie:
  2.   alias: Motyle - Oświetlenie
  3.   mode: parallel
  4.   fields:
  5.     start:
  6.       name: Początek
  7.       description: Czas rozpoczęcia ściemniania/rozjaśniania (czas dla którego ma być 100/0%)
  8.       required: true
  9.       example: "17:30"
  10.       default: "17:30"
  11.       selector:
  12.         time:
  13.     end:
  14.       name: Koniec
  15.       description: Czas zakończenia ściemniania/rozjaśniania (czas dla którego ma być 0/100%)
  16.       required: true
  17.       example: "19:10"
  18.       default: "19:10"
  19.       selector:
  20.         time:
  21.     light:
  22.       name: Światło
  23.       description: Światło do sterowania
  24.       required: true
  25.       example: light.motyle_oswietlenie
  26.       default: light.motyle_oswietlenie
  27.       selector:
  28.         entity:
  29.           domain: light
  30.     mode:
  31.       name: Tryb
  32.       description: Tryb działania skryptu
  33.       required: true
  34.       example: darken
  35.       default: darken
  36.       selector:
  37.         select:
  38.           options:
  39.             - label: Przyciemnianie
  40.               value: darken
  41.             - label: Rozjaśnianie
  42.               value: lighten
  43.     months:
  44.       name: Miesiące
  45.       description: Miesiące w których ma działać skrypt
  46.       required: true
  47.       example: "[1, 2, 3, 4, 9, 10, 11, 12]"
  48.       default: "[1, 2, 3, 4, 9, 10, 11, 12]"
  49.       selector:
  50.         select:
  51.           multiple: true
  52.           mode: list
  53.           options:
  54.             - label: Styczeń
  55.               value: "1"
  56.             - label: Luty
  57.               value: "2"
  58.             - label: Marzec
  59.               value: "3"
  60.             - label: Kwiecień
  61.               value: "4"
  62.             - label: Maj
  63.               value: "5"
  64.             - label: Czerwiec
  65.               value: "6"
  66.             - label: Lipiec
  67.               value: "7"
  68.             - label: Sierpień
  69.               value: "8"
  70.             - label: Wrzesień
  71.               value: "9"
  72.             - label: Październik
  73.               value: "10"
  74.             - label: Listopad
  75.               value: "11"
  76.             - label: Grudzień
  77.               value: "12"
  78.   sequence:
  79.     - variables:
  80.         start_int: "{{ start.split(':')[0] | int * 60 + start.split(':')[1] | int }}"
  81.         end_int: "{{ end.split(':')[0] | int * 60 + end.split(':')[1] | int }}"
  82.         time_int: "{{ now().hour * 60 + now().minute }}"
  83.         start_value: "{{ (mode != 'darken') | iif(0, 100) }}"
  84.         end_value: "{{ (mode != 'darken') | iif(100, 0) }}"
  85.         current_value: "{{ start_value + ((time_int - start_int) / (end_int - start_int)) * (end_value - start_value) }}"
  86.     - if:
  87.         - condition: template
  88.           value_template: "{{ start_int <= time_int <= end_int }}"
  89.         - condition: template
  90.           value_template: "{{ now().month | string in months }}"
  91.       then:
  92.         - service: light.turn_on
  93.           data:
  94.             transition: 5
  95.             brightness_pct: "{{ min(max(current_value | float, 0), 100) }}"
  96.             kelvin: 6500
  97.           target:
  98.             entity_id: "{{ light }}"
  99.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement