bomba23

Untitled

Dec 10th, 2021
1,062
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.30 KB | None | 0 0
  1. script:
  2.   update_lights_attributes:
  3.     fields:
  4.       brightness_pct:
  5.         description: "brightness in %"
  6.         example: "75"
  7.       transition:
  8.         description: "transition time in seconds"
  9.         example: "1"
  10.       xy_color:
  11.         description: "color in xy color notation"
  12.         example: "[0.5, 0.5]"
  13.     sequence:
  14.       - service: light.turn_on
  15.         target:
  16.           entity_id: "{{states.light|rejectattr('state', 'eq', 'off')|selectattr('attributes.entity_id', 'undefined')|map(attribute='entity_id')|list}}"
  17.         data: >
  18.          {% if brightness_pct and transition and xy_color %}
  19.             {% set data = {"brightness_pct":  brightness_pct, "transition": transition, "xy_color": xy_color} %}
  20.           {% elif brightness_pct and transition %}
  21.             {% set data = {"brightness_pct":  brightness_pct, "transition": transition} %}
  22.           {% elif  brightness_pct %}
  23.             {% set data = {"brightness_pct":  brightness_pct } %}
  24.           {% else %}
  25.             {% set data = {"brightness_pct":  100} %}
  26.           {% endif %}
  27.           {{ data }}
  28.  
  29.  
  30. automation:
  31.   - alias: "dim lights in nacht"
  32.     id: "56132890612345689532108"
  33.     trigger:
  34.       - platform: state
  35.         entity_id: input_select.house_mode
  36.         to: "nacht"
  37.     condition:
  38.       condition: state
  39.       entity_id: light.lampen
  40.       state: "on"
  41.     action:
  42.       - service: scene.create
  43.         data:
  44.           scene_id: before
  45.           snapshot_entities:
  46.            - light.hue_lightstrip_plus_1
  47.             - light.staande_lamp
  48.             - light.hue_color_pendant_down_1
  49.             - light.hue_color_pendant_up_1
  50.             - light.computer
  51.             - light.hal
  52.             - light.reserve
  53.             - light.sk_ceiling
  54.             - light.sk_duo_spot_1
  55.             - light.sk_duo_spot_2
  56.             - light.overloop
  57.             - light.keuken_1
  58.             - light.keuken_2
  59.             - light.keuken_3
  60.             - light.trap_hal
  61.       - service: script.update_lights_attributes
  62.         data:
  63.           brightness_pct: 10
  64.           transition: 2
  65.           xy_color:
  66.            - 0.167
  67.             - 0.04
  68.       - delay:
  69.           seconds: 5
  70.       - service: scene.turn_on
  71.         target:
  72.           entity_id: scene.before
  73.         data:
  74.           transition: 2
Advertisement
Add Comment
Please, Sign In to add comment