Guest User

Anchor Examples

a guest
Oct 27th, 2022
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. - name: Light Living Room
  2. unique_id: light_living_room
  3. state: &light_state >-
  4. {% set area = area_id(this.entity_id) %}
  5. {% set values = expand(area_entities(area) | select('match', '^light\.')) | selectattr('attributes.brightness', 'defined') | map(attribute='attributes.brightness') | map('float') | list | select('gt', 31) | list %}
  6. {% if selectattr('attributes.brightness', 'defined') | count < 1 %}
  7. 0
  8. {% else %}
  9. {% set result = ((values | average | int + 1) / 4) | round * 4 %}
  10. {% if result > 250 %}
  11. 255
  12. {% else %}
  13. {{ result }}
  14. {% endif %}
  15. {% endif %}
  16. step: &light_step 32
  17. min: &light_min 0
  18. max: &light_max 255
  19. set_value: &light_action
  20. - delay:
  21. hours: 0
  22. minutes: 0
  23. seconds: 1
  24. milliseconds: 0
  25. - service: script.smart_light_control
  26. data:
  27. area: "{% set area = area_id(this.entity_id) %}{{ area }}"
  28. colour: "{{ states['select.light_colour_' ~ area_id(this.entity_id)].state|default('Cool', true) }}"
  29. brightness: "{{ value | int }}"
  30. icon: &light_icon "{% if this.state|int(0) > 0 %}mdi:ceiling-light-outline{% else %}mdi:ceiling-light{% endif %}"
  31.  
  32. # {% set forcast = state_attr('calendar.xyz', 'forecast') %}
  33. # {% set end = (today_at() + timedelta(days=3)).isoformat() %}
  34. # {{ forcast | selectattr('datetime', '<=', end) | map(attribute='temperature') | list | average }}
  35.  
  36. - name: Light Kitchen
  37. unique_id: light_kitchen
  38. state: *light_state
  39. step: *light_step
  40. min: *light_min
  41. max: *light_max
  42. set_value: *light_action
  43. icon: "{% if this.state|int(0) > 0 %}mdi:ceiling-light-multiple-outline{% else %}mdi:ceiling-light-multiple{% endif %}"
  44.  
  45. - name: Light Bedroom
  46. unique_id: light_bedroom
  47. state: *light_state
  48. step: *light_step
  49. min: *light_min
  50. max: *light_max
  51. set_value: *light_action
  52. icon: *light_icon
Advertisement
Add Comment
Please, Sign In to add comment