Skip to content

Instantly share code, notes, and snippets.

@Zuulcode
Last active February 11, 2025 23:28

Revisions

  1. Zuulcode revised this gist Mar 14, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #Zuulcode(2023), all right reserved.
    #Zuulcode(2023), all rights reserved.
    blueprint:
    name: Styrbar multiple lights
    description: A blueprint that allows Ikea styrbar light controller to be used to
  2. Zuulcode revised this gist Mar 14, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #Zuulcode(2023),all right reserved.
    #Zuulcode(2023), all right reserved.
    blueprint:
    name: Styrbar multiple lights
    description: A blueprint that allows Ikea styrbar light controller to be used to
  3. Zuulcode revised this gist Mar 14, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    #Zuulcode(2023),all right reserved.
    blueprint:
    name: Styrbar multiple lights
    description: A blueprint that allows Ikea styrbar light controller to be used to
  4. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 115 additions and 126 deletions.
    241 changes: 115 additions & 126 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -1,155 +1,144 @@
    blueprint:
    name: Styrbar multiple lights
    description: A blueprint that allows Ikea styrbar light controller to be used to controll multiple lights made by Zuul.
    description: A blueprint that allows Ikea styrbar light controller to be used to
    control multiple lights, made by Zuul.
    domain: automation
    input:
    controller:
    name: Controller
    description: The styrbar controller to be used to controll the lights.
    description: The styrbar controller to be used to control the lights.
    selector:
    entity:
    domain: sensor

    multiple: false
    light_number:
    name: Light number
    description: An input_number helper with minimum value 1 and maximum value of at least the amount of lights used. This input should be configured to use increments of 1.
    description: An input_number helper with minimum value 1 and maximum value of
    at least the amount of lights used. This input should be configured to use
    increments of 1.
    selector:
    entity:
    domain: input_number

    multiple: false
    lights:
    name: Light(s)
    description: The lights that will be controlled by the controller.
    selector:
    entity:
    domain: light
    multiple: true

    source_url: https://gist.github.com/Zuulcode/6149d9c61c8679d963aeecde02055269
    variables:
    light_number: !input light_number
    lights: !input lights
    mode: restart

    trigger:
    - platform: state
    entity_id:
    - !input controller
    to: "on"
    id: "on"
    - platform: state
    entity_id:
    - !input controller
    to: "off"
    id: "off"
    - platform: state
    entity_id:
    - !input controller
    to: "arrow_left_click"
    id: "arrow_left_click"
    - platform: state
    entity_id:
    - !input controller
    to: "arrow_right_click"
    id: "arrow_right_click"
    - platform: state
    entity_id:
    - !input controller
    to: "brightness_move_up"
    id: "brightness_move_up"
    - platform: state
    entity_id:
    - !input controller
    to: "brightness_move_down"
    id: "brightness_move_down"
    - platform: state
    entity_id:
    - !input controller
    to: "brightness_stop"
    id: "brightness_stop"

    - platform: state
    entity_id:
    - !input controller
    to: 'on'
    id: 'on'
    - platform: state
    entity_id:
    - !input controller
    to: 'off'
    id: 'off'
    - platform: state
    entity_id:
    - !input controller
    to: arrow_left_click
    id: arrow_left_click
    - platform: state
    entity_id:
    - !input controller
    to: arrow_right_click
    id: arrow_right_click
    - platform: state
    entity_id:
    - !input controller
    to: brightness_move_up
    id: brightness_move_up
    - platform: state
    entity_id:
    - !input controller
    to: brightness_move_down
    id: brightness_move_down
    - platform: state
    entity_id:
    - !input controller
    to: brightness_stop
    id: brightness_stop
    action:
    - choose:
    - conditions:
    - condition: trigger
    id: "on"
    sequence:
    - service: light.turn_on
    target:
    entity_id: "{{ lights[int(states(light_number)) - 1] }}"
    - conditions:
    - condition: trigger
    id: "off"
    sequence:
    - service: light.turn_off
    target:
    entity_id: "{{ lights[int(states(light_number)) - 1] }}"
    - conditions:
    - condition: trigger
    id: "arrow_left_click"
    sequence:
    - service: input_number.set_value
    data:
    value: >-
    {% if int(states(light_number)) > 1 %}
    {{ int(states(light_number)) - 1 }}
    {% else %}
    {{ lights|length }}
    {% endif %}
    target:
    entity_id: !input light_number
    - conditions:
    - condition: trigger
    id: "arrow_right_click"
    sequence:
    - service: input_number.set_value
    data:
    value: >-
    {% if int(states(light_number)) < lights|length %}
    {{ int(states(light_number)) + 1 }}
    {% else %} 1
    {% endif %}
    target:
    entity_id: !input light_number

    - conditions:
    - condition: trigger
    id: "brightness_move_up"
    - choose:
    - conditions:
    - condition: trigger
    id: 'on'
    sequence:
    - service: light.turn_on
    target:
    entity_id: '{{ lights[int(states(light_number)) - 1] }}'
    - conditions:
    - condition: trigger
    id: 'off'
    sequence:
    - service: light.turn_off
    target:
    entity_id: '{{ lights[int(states(light_number)) - 1] }}'
    - conditions:
    - condition: trigger
    id: arrow_left_click
    sequence:
    - service: input_number.set_value
    data:
    value: '{% if int(states(light_number)) > 1 %} {{ int(states(light_number))
    - 1 }} {% else %} {{ lights|length }} {% endif %}'
    target:
    entity_id: !input light_number
    - conditions:
    - condition: trigger
    id: arrow_right_click
    sequence:
    - service: input_number.set_value
    data:
    value: '{% if int(states(light_number)) < lights|length %} {{ int(states(light_number))
    + 1 }} {% else %} 1 {% endif %}'
    target:
    entity_id: !input light_number
    - conditions:
    - condition: trigger
    id: brightness_move_up
    sequence:
    - repeat:
    until:
    - condition: trigger
    id: brightness_stop
    sequence:
    - repeat:
    until:
    - condition: trigger
    id: brightness_stop
    sequence:
    - service: light.turn_on
    target:
    entity_id: "{{ lights[int(states(light_number)) - 1] }}"
    data:
    brightness_step_pct: 10
    - delay:
    hours: 0
    minutes: 0
    seconds: 0
    milliseconds: 500

    - conditions:
    - condition: trigger
    id: "brightness_move_down"
    - service: light.turn_on
    target:
    entity_id: '{{ lights[int(states(light_number)) - 1] }}'
    data:
    brightness_step_pct: 10
    - delay:
    hours: 0
    minutes: 0
    seconds: 0
    milliseconds: 500
    - conditions:
    - condition: trigger
    id: brightness_move_down
    sequence:
    - repeat:
    until:
    - condition: trigger
    id: brightness_stop
    sequence:
    - repeat:
    until:
    - condition: trigger
    id: "brightness_stop"
    sequence:
    - service: light.turn_on
    target:
    entity_id: "{{ lights[int(states(light_number)) - 1] }}"
    data:
    brightness_step_pct: -10
    - delay:
    hours: 0
    minutes: 0
    seconds: 0
    milliseconds: 500



    - service: light.turn_on
    target:
    entity_id: '{{ lights[int(states(light_number)) - 1] }}'
    data:
    brightness_step_pct: -10
    - delay:
    hours: 0
    minutes: 0
    seconds: 0
    milliseconds: 500
  5. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 0 additions and 11 deletions.
    11 changes: 0 additions & 11 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -17,15 +17,6 @@ blueprint:
    entity:
    domain: input_number

    light_brightness:
    name: Light brightness
    description: The brightness the lights will be when turned on by the controller.
    selector:
    number:
    min: 0
    max: 100
    unit_of_measurement: "%"

    lights:
    name: Light(s)
    description: The lights that will be controlled by the controller.
    @@ -85,8 +76,6 @@ action:
    - service: light.turn_on
    target:
    entity_id: "{{ lights[int(states(light_number)) - 1] }}"
    data:
    brightness_pct: !input light_brightness
    - conditions:
    - condition: trigger
    id: "off"
  6. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -101,8 +101,8 @@ action:
    - service: input_number.set_value
    data:
    value: >-
    {% if int(states(light_number)) < lights|length %}
    {{ int(states(light_number)) + 1 }}
    {% if int(states(light_number)) > 1 %}
    {{ int(states(light_number)) - 1 }}
    {% else %}
    {{ lights|length }}
    {% endif %}
    @@ -116,9 +116,8 @@ action:
    data:
    value: >-
    {% if int(states(light_number)) < lights|length %}
    {{ int(states(light_number)) - 1 }}
    {% else %}
    {{ lights|length - 1 }}
    {{ int(states(light_number)) + 1 }}
    {% else %} 1
    {% endif %}
    target:
    entity_id: !input light_number
  7. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -101,7 +101,7 @@ action:
    - service: input_number.set_value
    data:
    value: >-
    {% if int(states(light_number)) < lights|length %} 1
    {% if int(states(light_number)) < lights|length %}
    {{ int(states(light_number)) + 1 }}
    {% else %}
    {{ lights|length }}
    @@ -115,7 +115,7 @@ action:
    - service: input_number.set_value
    data:
    value: >-
    {% if int(states(light_number)) < lights|length %} 1
    {% if int(states(light_number)) < lights|length %}
    {{ int(states(light_number)) - 1 }}
    {% else %}
    {{ lights|length - 1 }}
  8. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -103,7 +103,8 @@ action:
    value: >-
    {% if int(states(light_number)) < lights|length %} 1
    {{ int(states(light_number)) + 1 }}
    {% else %} 1
    {% else %}
    {{ lights|length }}
    {% endif %}
    target:
    entity_id: !input light_number
    @@ -117,7 +118,7 @@ action:
    {% if int(states(light_number)) < lights|length %} 1
    {{ int(states(light_number)) - 1 }}
    {% else %}
    {{ len(lights) - 1 }}
    {{ lights|length - 1 }}
    {% endif %}
    target:
    entity_id: !input light_number
  9. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -101,8 +101,8 @@ action:
    - service: input_number.set_value
    data:
    value: >-
    {% if states(light_number) < lights|length %} 1
    {{ states(light_number) + 1 }}
    {% if int(states(light_number)) < lights|length %} 1
    {{ int(states(light_number)) + 1 }}
    {% else %} 1
    {% endif %}
    target:
    @@ -114,8 +114,8 @@ action:
    - service: input_number.set_value
    data:
    value: >-
    {% if states(light_number) < lights|length %} 1
    {{ states(light_number) - 1 }}
    {% if int(states(light_number)) < lights|length %} 1
    {{ int(states(light_number)) - 1 }}
    {% else %}
    {{ len(lights) - 1 }}
    {% endif %}
  10. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -101,7 +101,7 @@ action:
    - service: input_number.set_value
    data:
    value: >-
    {% if states(light_number) < len(lights) %} 1
    {% if states(light_number) < lights|length %} 1
    {{ states(light_number) + 1 }}
    {% else %} 1
    {% endif %}
    @@ -114,7 +114,7 @@ action:
    - service: input_number.set_value
    data:
    value: >-
    {% if states(light_number) < len(lights) %} 1
    {% if states(light_number) < lights|length %} 1
    {{ states(light_number) - 1 }}
    {% else %}
    {{ len(lights) - 1 }}
  11. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ blueprint:
    domain: sensor

    light_number:
    name: Zone number
    name: Light number
    description: An input_number helper with minimum value 1 and maximum value of at least the amount of lights used. This input should be configured to use increments of 1.
    selector:
    entity:
    @@ -132,7 +132,8 @@ action:
    id: brightness_stop
    sequence:
    - service: light.turn_on
    entity_id: "{{ lights[int(states(light_number)) - 1] }}"
    target:
    entity_id: "{{ lights[int(states(light_number)) - 1] }}"
    data:
    brightness_step_pct: 10
    - delay:
    @@ -151,7 +152,8 @@ action:
    id: "brightness_stop"
    sequence:
    - service: light.turn_on
    entity_id: "{{ lights[int(states(light_number)) - 1] }}"
    target:
    entity_id: "{{ lights[int(states(light_number)) - 1] }}"
    data:
    brightness_step_pct: -10
    - delay:
  12. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 85 additions and 4 deletions.
    89 changes: 85 additions & 4 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -77,7 +77,88 @@ trigger:
    id: "brightness_stop"

    action:
    - device_id: 592dc7173bd1a228aaab20dd3d61164c
    domain: mobile_app
    type: notify
    message: "{{ lights[int(states(light_number) - 1)] }}"
    - choose:
    - conditions:
    - condition: trigger
    id: "on"
    sequence:
    - service: light.turn_on
    target:
    entity_id: "{{ lights[int(states(light_number)) - 1] }}"
    data:
    brightness_pct: !input light_brightness
    - conditions:
    - condition: trigger
    id: "off"
    sequence:
    - service: light.turn_off
    target:
    entity_id: "{{ lights[int(states(light_number)) - 1] }}"
    - conditions:
    - condition: trigger
    id: "arrow_left_click"
    sequence:
    - service: input_number.set_value
    data:
    value: >-
    {% if states(light_number) < len(lights) %} 1
    {{ states(light_number) + 1 }}
    {% else %} 1
    {% endif %}
    target:
    entity_id: !input light_number
    - conditions:
    - condition: trigger
    id: "arrow_right_click"
    sequence:
    - service: input_number.set_value
    data:
    value: >-
    {% if states(light_number) < len(lights) %} 1
    {{ states(light_number) - 1 }}
    {% else %}
    {{ len(lights) - 1 }}
    {% endif %}
    target:
    entity_id: !input light_number

    - conditions:
    - condition: trigger
    id: "brightness_move_up"
    sequence:
    - repeat:
    until:
    - condition: trigger
    id: brightness_stop
    sequence:
    - service: light.turn_on
    entity_id: "{{ lights[int(states(light_number)) - 1] }}"
    data:
    brightness_step_pct: 10
    - delay:
    hours: 0
    minutes: 0
    seconds: 0
    milliseconds: 500

    - conditions:
    - condition: trigger
    id: "brightness_move_down"
    sequence:
    - repeat:
    until:
    - condition: trigger
    id: "brightness_stop"
    sequence:
    - service: light.turn_on
    entity_id: "{{ lights[int(states(light_number)) - 1] }}"
    data:
    brightness_step_pct: -10
    - delay:
    hours: 0
    minutes: 0
    seconds: 0
    milliseconds: 500



  13. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 4 additions and 85 deletions.
    89 changes: 4 additions & 85 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -77,88 +77,7 @@ trigger:
    id: "brightness_stop"

    action:
    - choose:
    - conditions:
    - condition: trigger
    id: "on"
    sequence:
    - service: light.turn_on
    target:
    entity_id: "{{ lights[int(states(light_number) - 1)] }}"
    data:
    brightness_pct: !input light_brightness
    - conditions:
    - condition: trigger
    id: "off"
    sequence:
    - service: light.turn_off
    target:
    entity_id: "{{ lights[int(states(light_number) - 1)] }}"
    - conditions:
    - condition: trigger
    id: "arrow_left_click"
    sequence:
    - service: input_number.set_value
    data:
    value: >-
    {% if states(light_number) < len(lights) %} 1
    {{ states(light_number) + 1 }}
    {% else %} 1
    {% endif %}
    target:
    entity_id: !input light_number
    - conditions:
    - condition: trigger
    id: "arrow_right_click"
    sequence:
    - service: input_number.set_value
    data:
    value: >-
    {% if states(light_number) < len(lights) %} 1
    {{ states(light_number) - 1 }}
    {% else %}
    {{ len(lights) - 1 }}
    {% endif %}
    target:
    entity_id: !input light_number

    - conditions:
    - condition: trigger
    id: "brightness_move_up"
    sequence:
    - repeat:
    until:
    - condition: trigger
    id: brightness_stop
    sequence:
    - service: light.turn_on
    entity_id: "{{ lights[int(states(light_number) - 1)] }}"
    data:
    brightness_step_pct: 10
    - delay:
    hours: 0
    minutes: 0
    seconds: 0
    milliseconds: 500

    - conditions:
    - condition: trigger
    id: "brightness_move_down"
    sequence:
    - repeat:
    until:
    - condition: trigger
    id: "brightness_stop"
    sequence:
    - service: light.turn_on
    entity_id: "{{ lights[int(states(light_number) - 1)] }}"
    data:
    brightness_step_pct: -10
    - delay:
    hours: 0
    minutes: 0
    seconds: 0
    milliseconds: 500



    - device_id: 592dc7173bd1a228aaab20dd3d61164c
    domain: mobile_app
    type: notify
    message: "{{ lights[int(states(light_number) - 1)] }}"
  14. Zuulcode revised this gist Mar 13, 2023. No changes.
  15. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -84,7 +84,7 @@ action:
    sequence:
    - service: light.turn_on
    target:
    entity_id: "{{ lights[states(light_number) - 1] }}"
    entity_id: "{{ lights[int(states(light_number) - 1)] }}"
    data:
    brightness_pct: !input light_brightness
    - conditions:
    @@ -93,7 +93,7 @@ action:
    sequence:
    - service: light.turn_off
    target:
    entity_id: "{{ lights[states(light_number) - 1] }}"
    entity_id: "{{ lights[int(states(light_number) - 1)] }}"
    - conditions:
    - condition: trigger
    id: "arrow_left_click"
    @@ -132,7 +132,7 @@ action:
    id: brightness_stop
    sequence:
    - service: light.turn_on
    entity_id: "{{ lights[states(light_number) - 1] }}"
    entity_id: "{{ lights[int(states(light_number) - 1)] }}"
    data:
    brightness_step_pct: 10
    - delay:
    @@ -151,7 +151,7 @@ action:
    id: "brightness_stop"
    sequence:
    - service: light.turn_on
    entity_id: "{{ lights[states(light_number) - 1] }}"
    entity_id: "{{ lights[int(states(light_number) - 1)] }}"
    data:
    brightness_step_pct: -10
    - delay:
  16. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 21 additions and 21 deletions.
    42 changes: 21 additions & 21 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -43,44 +43,44 @@ trigger:
    - platform: state
    entity_id:
    - !input controller
    to: on
    id: on
    to: "on"
    id: "on"
    - platform: state
    entity_id:
    - !input controller
    to: off
    id: off
    to: "off"
    id: "off"
    - platform: state
    entity_id:
    - !input controller
    to: arrow_left_click
    id: arrow_left_click
    to: "arrow_left_click"
    id: "arrow_left_click"
    - platform: state
    entity_id:
    - !input controller
    to: arrow_right_click
    id: arrow_right_click
    to: "arrow_right_click"
    id: "arrow_right_click"
    - platform: state
    entity_id:
    - !input controller
    to: brightness_move_up
    id: brightness_move_up
    to: "brightness_move_up"
    id: "brightness_move_up"
    - platform: state
    entity_id:
    - !input controller
    to: brightness_move_down
    id: brightness_move_down
    to: "brightness_move_down"
    id: "brightness_move_down"
    - platform: state
    entity_id:
    - !input controller
    to: brightness_stop
    id: brightness_stop
    to: "brightness_stop"
    id: "brightness_stop"

    action:
    - choose:
    - conditions:
    - condition: trigger
    id: on
    id: "on"
    sequence:
    - service: light.turn_on
    target:
    @@ -89,14 +89,14 @@ action:
    brightness_pct: !input light_brightness
    - conditions:
    - condition: trigger
    id: off
    id: "off"
    sequence:
    - service: light.turn_off
    target:
    entity_id: "{{ lights[states(light_number) - 1] }}"
    - conditions:
    - condition: trigger
    id: arrow_left_click
    id: "arrow_left_click"
    sequence:
    - service: input_number.set_value
    data:
    @@ -109,7 +109,7 @@ action:
    entity_id: !input light_number
    - conditions:
    - condition: trigger
    id: arrow_right_click
    id: "arrow_right_click"
    sequence:
    - service: input_number.set_value
    data:
    @@ -124,7 +124,7 @@ action:

    - conditions:
    - condition: trigger
    id: brightness_move_up
    id: "brightness_move_up"
    sequence:
    - repeat:
    until:
    @@ -143,12 +143,12 @@ action:

    - conditions:
    - condition: trigger
    id: brightness_move_down
    id: "brightness_move_down"
    sequence:
    - repeat:
    until:
    - condition: trigger
    id: brightness_stop
    id: "brightness_stop"
    sequence:
    - service: light.turn_on
    entity_id: "{{ lights[states(light_number) - 1] }}"
  17. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    blueprint:
    name: Styrbar zones
    name: Styrbar multiple lights
    description: A blueprint that allows Ikea styrbar light controller to be used to controll multiple lights made by Zuul.
    domain: automation
    input:
  18. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -82,16 +82,18 @@ action:
    - condition: trigger
    id: on
    sequence:
    .- service: light.turn_on
    entity_id: "{{ lights[states(light_number) - 1] }}"
    data:
    brightness_pct: !input light_brightness
    - service: light.turn_on
    target:
    entity_id: "{{ lights[states(light_number) - 1] }}"
    data:
    brightness_pct: !input light_brightness
    - conditions:
    - condition: trigger
    id: off
    sequence:
    - service: light.turn_off
    entity_id: "{{ lights[states(light_number) - 1] }}"
    target:
    entity_id: "{{ lights[states(light_number) - 1] }}"
    - conditions:
    - condition: trigger
    id: arrow_left_click
  19. Zuulcode revised this gist Mar 13, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ blueprint:
    number:
    min: 0
    max: 100
    unit_of_measurement: %
    unit_of_measurement: "%"

    lights:
    name: Light(s)
  20. Zuulcode created this gist Mar 13, 2023.
    162 changes: 162 additions & 0 deletions styrbar.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,162 @@
    blueprint:
    name: Styrbar zones
    description: A blueprint that allows Ikea styrbar light controller to be used to controll multiple lights made by Zuul.
    domain: automation
    input:
    controller:
    name: Controller
    description: The styrbar controller to be used to controll the lights.
    selector:
    entity:
    domain: sensor

    light_number:
    name: Zone number
    description: An input_number helper with minimum value 1 and maximum value of at least the amount of lights used. This input should be configured to use increments of 1.
    selector:
    entity:
    domain: input_number

    light_brightness:
    name: Light brightness
    description: The brightness the lights will be when turned on by the controller.
    selector:
    number:
    min: 0
    max: 100
    unit_of_measurement: %

    lights:
    name: Light(s)
    description: The lights that will be controlled by the controller.
    selector:
    entity:
    domain: light
    multiple: true

    variables:
    light_number: !input light_number
    lights: !input lights
    mode: restart

    trigger:
    - platform: state
    entity_id:
    - !input controller
    to: on
    id: on
    - platform: state
    entity_id:
    - !input controller
    to: off
    id: off
    - platform: state
    entity_id:
    - !input controller
    to: arrow_left_click
    id: arrow_left_click
    - platform: state
    entity_id:
    - !input controller
    to: arrow_right_click
    id: arrow_right_click
    - platform: state
    entity_id:
    - !input controller
    to: brightness_move_up
    id: brightness_move_up
    - platform: state
    entity_id:
    - !input controller
    to: brightness_move_down
    id: brightness_move_down
    - platform: state
    entity_id:
    - !input controller
    to: brightness_stop
    id: brightness_stop

    action:
    - choose:
    - conditions:
    - condition: trigger
    id: on
    sequence:
    .- service: light.turn_on
    entity_id: "{{ lights[states(light_number) - 1] }}"
    data:
    brightness_pct: !input light_brightness
    - conditions:
    - condition: trigger
    id: off
    sequence:
    - service: light.turn_off
    entity_id: "{{ lights[states(light_number) - 1] }}"
    - conditions:
    - condition: trigger
    id: arrow_left_click
    sequence:
    - service: input_number.set_value
    data:
    value: >-
    {% if states(light_number) < len(lights) %} 1
    {{ states(light_number) + 1 }}
    {% else %} 1
    {% endif %}
    target:
    entity_id: !input light_number
    - conditions:
    - condition: trigger
    id: arrow_right_click
    sequence:
    - service: input_number.set_value
    data:
    value: >-
    {% if states(light_number) < len(lights) %} 1
    {{ states(light_number) - 1 }}
    {% else %}
    {{ len(lights) - 1 }}
    {% endif %}
    target:
    entity_id: !input light_number

    - conditions:
    - condition: trigger
    id: brightness_move_up
    sequence:
    - repeat:
    until:
    - condition: trigger
    id: brightness_stop
    sequence:
    - service: light.turn_on
    entity_id: "{{ lights[states(light_number) - 1] }}"
    data:
    brightness_step_pct: 10
    - delay:
    hours: 0
    minutes: 0
    seconds: 0
    milliseconds: 500

    - conditions:
    - condition: trigger
    id: brightness_move_down
    sequence:
    - repeat:
    until:
    - condition: trigger
    id: brightness_stop
    sequence:
    - service: light.turn_on
    entity_id: "{{ lights[states(light_number) - 1] }}"
    data:
    brightness_step_pct: -10
    - delay:
    hours: 0
    minutes: 0
    seconds: 0
    milliseconds: 500