Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script:
- update_lights_attributes:
- fields:
- brightness_pct:
- description: "brightness in %"
- example: "75"
- transition:
- description: "transition time in seconds"
- example: "1"
- xy_color:
- description: "color in xy color notation"
- example: "[0.5, 0.5]"
- sequence:
- - service: light.turn_on
- target:
- entity_id: "{{states.light|rejectattr('state', 'eq', 'off')|selectattr('attributes.entity_id', 'undefined')|map(attribute='entity_id')|list}}"
- data: >
- {% if brightness_pct and transition and xy_color %}
- {% set data = {"brightness_pct": brightness_pct, "transition": transition, "xy_color": xy_color} %}
- {% elif brightness_pct and transition %}
- {% set data = {"brightness_pct": brightness_pct, "transition": transition} %}
- {% elif brightness_pct %}
- {% set data = {"brightness_pct": brightness_pct } %}
- {% else %}
- {% set data = {"brightness_pct": 100} %}
- {% endif %}
- {{ data }}
- automation:
- - alias: "dim lights in nacht"
- id: "56132890612345689532108"
- trigger:
- - platform: state
- entity_id: input_select.house_mode
- to: "nacht"
- condition:
- condition: state
- entity_id: light.lampen
- state: "on"
- action:
- - service: scene.create
- data:
- scene_id: before
- snapshot_entities:
- - light.hue_lightstrip_plus_1
- - light.staande_lamp
- - light.hue_color_pendant_down_1
- - light.hue_color_pendant_up_1
- - light.computer
- - light.hal
- - light.reserve
- - light.sk_ceiling
- - light.sk_duo_spot_1
- - light.sk_duo_spot_2
- - light.overloop
- - light.keuken_1
- - light.keuken_2
- - light.keuken_3
- - light.trap_hal
- - service: script.update_lights_attributes
- data:
- brightness_pct: 10
- transition: 2
- xy_color:
- - 0.167
- - 0.04
- - delay:
- seconds: 5
- - service: scene.turn_on
- target:
- entity_id: scene.before
- data:
- transition: 2
Advertisement
Add Comment
Please, Sign In to add comment