Hi guys, this is my first blueprint. I’ve bought this device from Ikea (model STYRBAR E2001/E2002) to play with blueprints and automations.
I’ve connected this device with my Yeelight dimmerable/colorable bulb and everything’s fine for events like button up/down/left/right clicked.
My problem is about long press events like for example brightness_move_up when hold, brightness_stop when released. In blueprint I’ve tried to create a loop to increase/descrease brightness while holding button but my bulb receive an error with message:
Error when calling async_set_brightness for bulb Yeelight Color 0x12c713a3 at 192.168.1.14: {‘code’: -1, ‘message’: ‘client quota exceeded’}
It seems related to a bug (???) or to many call sent in my loop, but I don’t understand why even if I set a loop delay of 500 millisec.
If I set the delay to 1 sec. the error occur rarely (but occurs) and anyway the effect is to much slow for a nice experience. I tried to set automation mode to parallel/queued/single and it seems the the last settings is preferable but not perfect.
How can I manage long pressing in correct/kindly mode, please? Thanks.
Below the blueprint:
blueprint:
name: Ikea STYRBAR automation light
description: Turn a light on/off - increase/decrease brightness - set color and temperature
domain: automation
source_url: http://localhost.it
input:
remote:
name: Ikea STYRBAR 2001/2002
description: This remote device will manage the light.
selector:
entity:
domain: sensor
target_light:
name: Light color
description: The light color to keep in sync.
selector:
entity:
domain: light
brightness_step:
name: Brightness increment
description: Value to increment brightness.
default: 20
selector:
number:
min: 10
max: 100
target_hue:
name: Hue increment
description: Value to increment hue.
default: 30
selector:
number:
min: 10
max: 360
target_sat:
name: Saturation increment
description: Value to increment saturation.
default: 90
selector:
number:
min: 10
max: 100
target_color_temp:
name: Color temperature increment
description: Value to increment color temperature.
default: 40
selector:
number:
min: 153
max: 500
trigger_variables:
target_light_variable: !input target_light
target_hue_variable: !input target_hue
target_sat_variable: !input target_sat
target_color_temp_variable: !input target_color_temp
brightness_step_variable: !input brightness_step
trigger:
- platform: state
entity_id: !input remote
condition: []
action:
- variables:
command: "{{ trigger.to_state.state }}"
loop_delay: 1000
- choose:
- conditions:
- condition: template
value_template: "{{ command == 'on' }}"
sequence:
- service: light.turn_on
target:
entity_id: !input target_light
data: {}
- conditions:
- condition: template
value_template: "{{ command == 'off' }}"
sequence:
- service: light.turn_off
target:
entity_id: !input target_light
data: {}
- conditions:
- condition: template
value_template: "{{ command == 'arrow_left_click' }}"
sequence:
- service: light.turn_on
target:
entity_id: !input target_light
data_template:
color_temp: >-
{% if (target_color_temp_variable +
(state_attr(target_light_variable, 'color_temp') or
0) > 500) %}
153
{% elif (target_color_temp_variable +
(state_attr(target_light_variable, 'color_temp') or
0) < 153) %}
500
{% else %}
{{ (target_color_temp_variable + (state_attr(target_light_variable, 'color_temp') or 0)) }}
{% endif %}
- conditions:
- condition: template
value_template: "{{ command == 'arrow_right_click' }}"
sequence:
- service: light.turn_on
target:
entity_id: !input target_light
data_template:
hs_color:
- >-
{{ (target_hue_variable +
(state_attr(target_light_variable, 'hs_color')[0]
or 0)) % 360 }}
- "{{ target_sat_variable }}"
- conditions:
condition: and
conditions:
- condition: template
value_template: "{{ command == 'brightness_move_up' }}"
sequence:
- repeat:
sequence:
- service: light.turn_on
target:
entity_id: !input target_light
data:
brightness_step: "{{ brightness_step_variable }}"
- delay:
milliseconds: "{{ loop_delay }}"
until:
condition: or
conditions:
- condition: template
value_template: "{{ command == 'brightness_stop' }}"
- condition: template
value_template: "{{ state_attr(target_light_variable, 'brightness') >= 255 }}"
- conditions:
condition: and
conditions:
- condition: template
value_template: "{{ command == 'brightness_move_down' }}"
sequence:
- repeat:
sequence:
- service: light.turn_on
target:
entity_id: !input target_light
data:
brightness_step: "{{ - brightness_step_variable }}"
- delay:
milliseconds: "{{ loop_delay }}"
until:
condition: or
conditions:
- condition: template
value_template: "{{ command == 'brightness_stop' }}"
- condition: template
value_template: "{{ state_attr(target_light_variable, 'brightness') <= -200 }}"
Every suggest aimed to improve my code is wellcome