Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - name: Light Living Room
- unique_id: light_living_room
- state: &light_state >-
- {% set area = area_id(this.entity_id) %}
- {% set values = expand(area_entities(area) | select('match', '^light\.')) | selectattr('attributes.brightness', 'defined') | map(attribute='attributes.brightness') | map('float') | list | select('gt', 31) | list %}
- {% if selectattr('attributes.brightness', 'defined') | count < 1 %}
- 0
- {% else %}
- {% set result = ((values | average | int + 1) / 4) | round * 4 %}
- {% if result > 250 %}
- 255
- {% else %}
- {{ result }}
- {% endif %}
- {% endif %}
- step: &light_step 32
- min: &light_min 0
- max: &light_max 255
- set_value: &light_action
- - delay:
- hours: 0
- minutes: 0
- seconds: 1
- milliseconds: 0
- - service: script.smart_light_control
- data:
- area: "{% set area = area_id(this.entity_id) %}{{ area }}"
- colour: "{{ states['select.light_colour_' ~ area_id(this.entity_id)].state|default('Cool', true) }}"
- brightness: "{{ value | int }}"
- icon: &light_icon "{% if this.state|int(0) > 0 %}mdi:ceiling-light-outline{% else %}mdi:ceiling-light{% endif %}"
- # {% set forcast = state_attr('calendar.xyz', 'forecast') %}
- # {% set end = (today_at() + timedelta(days=3)).isoformat() %}
- # {{ forcast | selectattr('datetime', '<=', end) | map(attribute='temperature') | list | average }}
- - name: Light Kitchen
- unique_id: light_kitchen
- state: *light_state
- step: *light_step
- min: *light_min
- max: *light_max
- set_value: *light_action
- icon: "{% if this.state|int(0) > 0 %}mdi:ceiling-light-multiple-outline{% else %}mdi:ceiling-light-multiple{% endif %}"
- - name: Light Bedroom
- unique_id: light_bedroom
- state: *light_state
- step: *light_step
- min: *light_min
- max: *light_max
- set_value: *light_action
- icon: *light_icon
Advertisement
Add Comment
Please, Sign In to add comment