Advertisement
energywave

Telecomandi Zigbee

Jan 5th, 2022
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 8.34 KB | None | 0 0
  1. input_select:
  2.   light_armadio_color:
  3.     name: Colori strip armadio
  4.     icon: mdi:palette
  5.     options:
  6.      - "[255, 0, 0]"
  7.       - "[255, 255, 0]"
  8.       - "[0, 255, 0]"
  9.       - "[0, 255, 255]"
  10.       - "[0, 0, 255]"
  11.       - "[255, 0, 255]"
  12.       - "[255, 255, 255]"
  13.  
  14.   light_strip_cameretta_erica_color:
  15.     name: Colori strip cameretta Erica
  16.     icon: mdi:palette
  17.     options:
  18.      - "[128, 0, 255, 0]"
  19.       - "[255, 0, 0, 0]"
  20.       - "[255, 255, 0, 0]"
  21.       - "[0, 255, 0, 0]"
  22.       - "[0, 255, 255, 0]"
  23.       - "[0, 0, 255, 0]"
  24.       - "[255, 0, 255, 0]"
  25.       - "[0, 0, 0, 255]"
  26.  
  27. automation:
  28.  # Telecomando cameretta Erica
  29.   - id: a2f50e8a-09bd-42bc-9533-59a0ec315e05
  30.     alias: 'Luci - Azione - Telecomando cameretta Erica'
  31.     trigger:
  32.       - platform: event
  33.         event_type: zha_event
  34.         event_data:
  35.           device_ieee: "xx:xx:xx:xx:xx:xx:xx:xx"
  36.     action:
  37.       - variables:
  38.           command: "{{ trigger.event.data.command }}"
  39.           args: "{{ trigger.event.data.args }}"
  40.           light_dest: switch.abat_jour_mansarda
  41.           input_color: input_select.light_strip_cameretta_erica_color
  42.           rgbw: "{{state_attr(light_dest, 'rgbw_color')}}"
  43.       - alias: "A seconda del tasto premuto"
  44.         choose:
  45.          # Click su ON quando abat jour e strip sono accese (cambio colore)
  46.           - conditions: "{{ command == 'on' and is_state('light.strip_cameretta_erica', 'on') }}"
  47.             sequence:
  48.               - service: input_select.select_next
  49.                 target:
  50.                   entity_id: "{{ input_color }}"
  51.               - service: light.turn_on
  52.                 target:
  53.                   entity_id: light.strip_cameretta_erica
  54.                 data:
  55.                   rgbw_color: "{{ states(input_color) }}"
  56.           # Se tenuto premuto l'ON oppure click su ON con abat jour accesa da oltre 1 secondo
  57.           - conditions: "{{ command == 'move_with_on_off' or (command == 'on' and is_state('switch.abat_jour_mansarda', 'on') and (now() - states.switch.abat_jour_mansarda.last_changed).total_seconds() > 0.5)}}"
  58.             sequence:
  59.               - alias: "Accende strip cameretta Erica"
  60.                 service: light.turn_on
  61.                 target:
  62.                   entity_id: light.strip_cameretta_erica
  63.           # Se tenuto premuto l'OFF oppure click su OFF con abat jour spenta da oltre 1 secondo
  64.           - conditions: "{{ command == 'move' or (command == 'off' and is_state('switch.abat_jour_mansarda', 'off') and (now() - states.switch.abat_jour_mansarda.last_changed).total_seconds() > 0.5)}}"
  65.             sequence:
  66.               - alias: "Spegne strip cameretta Erica"
  67.                 service: light.turn_off
  68.                 target:
  69.                   entity_id: light.strip_cameretta_erica
  70.               - alias: "Spegne Abat Jour (serve su pressione prolungata)"  
  71.                 service: switch.turn_off
  72.                 target:
  73.                   entity_id: switch.abat_jour_mansarda
  74.          
  75.   # Telecomando RGB armadio camera
  76.   - id: 12c75001-291f-41db-8b56-978143118402
  77.     alias: 'Gestione telecomando luce RGB camera'
  78.     mode: restart
  79.     trigger:
  80.       - platform: event
  81.         event_type: zha_event
  82.         event_data:
  83.           device_ieee: 'xx:xx:xx:xx:xx:xx:xx:xx'
  84.     action:
  85.       - variables:
  86.           command: "{{ trigger.event.data.command }}"
  87.           args: "{{ trigger.event.data.args }}"
  88.           light_dest: light.luce_armadio
  89.           input_color: input_select.light_armadio_color
  90.           rgbw: "{{state_attr(light_dest, 'rgbw_color')}}"
  91.       - choose:
  92.          # ON/OFF
  93.           - conditions: "{{ command == 'toggle' }}"
  94.             sequence:
  95.              # Determino se la luce è accesa
  96.               - choose:
  97.                   - conditions: "{{ is_state(light_dest, 'on') }}"
  98.                     sequence:
  99.                      # Se la luce è accesa la spengo
  100.                       - service: light.turn_off
  101.                         target:
  102.                           entity_id: "{{ light_dest }}"
  103.                 default:
  104.                  # La luce è spenta, quindi la devo accendere ma lo faccio diversamente se fuori è buio o no
  105.                   - choose:
  106.                     - conditions: "{{ state_attr('sun.sun', 'elevation') < -6 }}"
  107.                       sequence:
  108.                        # Fuori è buio: accendo la luce tenue
  109.                         - service: input_select.select_option
  110.                           target:
  111.                             entity_id: "{{ input_color }}"
  112.                           data:
  113.                             option: "[0, 0, 255]"
  114.                         - service: light.turn_on
  115.                           target:
  116.                             entity_id: "{{ light_dest }}"
  117.                           data:
  118.                             color_name: blue
  119.                             white_value: 0
  120.                             brightness: 10
  121.                     default:
  122.                      # Fuori è chiaro: accendo la luce più forte
  123.                       - service: input_select.select_option
  124.                         target:
  125.                           entity_id: "{{ input_color }}"
  126.                         data:
  127.                           option: "[0, 255, 0]"
  128.                       - service: light.turn_on
  129.                         target:
  130.                           entity_id: "{{ light_dest }}"
  131.                         data:
  132.                           color_name: green
  133.                           white_value: 255
  134.                           brightness: 255
  135.           # Luminosità up hold (aumenta luminosità RGB)
  136.           - conditions: "{{ command == 'move_with_on_off' }}"
  137.             sequence:
  138.               repeat:
  139.                 while: "{{ repeat.index <= 10 }}"
  140.                 sequence:
  141.                 - service: light.turn_on
  142.                   target:
  143.                     entity_id: "{{ light_dest }}"
  144.                   data:
  145.                     brightness_step_pct: 10
  146.                 - delay: 1
  147.           # Luminosità down hold (diminuisce luminosità RGB)
  148.           - conditions: "{{ command == 'move' }}"
  149.             sequence:
  150.               repeat:
  151.                 while: "{{ repeat.index <= 10 }}"
  152.                 sequence:
  153.                 - service: light.turn_on
  154.                   target:
  155.                     entity_id: "{{ light_dest }}"
  156.                   data:
  157.                     brightness_step_pct: -10
  158.                 - delay: 1
  159.           # Luminosità up click (white on)
  160.           - conditions:
  161.             - "{{ command == 'step_with_on_off' }}"
  162.             - "{{ args == [0, 43, 5] }}"
  163.             sequence:
  164.               - service: light.turn_on
  165.                 target:
  166.                   entity_id: "{{ light_dest }}"
  167.                 data:
  168.                   rgbw_color: ["{{rgbw[0]}}", "{{rgbw[1]}}", "{{rgbw[2]}}", 255]
  169.           # Luminosità down click (white off)
  170.           - conditions:
  171.            - "{{ command == 'step' }}"
  172.             - "{{ args == [1, 43, 5] }}"
  173.             sequence:
  174.               - service: light.turn_on
  175.                 target:
  176.                   entity_id: "{{ light_dest }}"
  177.                 data:
  178.                   rgbw_color: ["{{rgbw[0]}}", "{{rgbw[1]}}", "{{rgbw[2]}}", 0]
  179.           # Rilascio luminosità up/down
  180.           - conditions: "{{ command == 'stop' }}"
  181.             sequence:
  182.             - service: light.turn_on
  183.               target:
  184.                 entity_id: "{{ light_dest }}"
  185.           # right
  186.           - conditions:
  187.            - "{{ command == 'press' }}"
  188.             - "{{ args == [256, 13, 0] }}"
  189.             sequence:
  190.               - service: input_select.select_next
  191.                 target:
  192.                   entity_id: "{{ input_color }}"
  193.               - service: light.turn_on
  194.                 target:
  195.                   entity_id: "{{ light_dest }}"
  196.                 data:
  197.                   rgb_color: "{{ states(input_color) }}"
  198.           # left
  199.           - conditions:
  200.            - "{{ command == 'press' }}"
  201.             - "{{ args == [257, 13, 0] }}"
  202.             sequence:
  203.               - service: input_select.select_previous
  204.                 target:
  205.                   entity_id: "{{ input_color }}"
  206.               - service: light.turn_on
  207.                 target:
  208.                   entity_id: "{{ light_dest }}"
  209.                 data:
  210.                   rgb_color: "{{ states(input_color) }}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement