noxx
(Ralf B)
September 19, 2021, 2:39pm
1
hello,
i want controll my WLED effect with my AQARA switch.
add this code to my automations.yaml, but if i press a button, nothing happens. where
is my error?
button 6 should go to the next effect, and button 5 to the last.
- alias: Effect Minus
trigger:
platform: mqtt
topic: 'zigbee2mqtt/Partyraum Schalter/action'
payload: 'button_5_single'
action:
- service: wled.effect
entity_id: light.wled
data:
effect: >-
{{ state_attr('light.wled', 'effect') - 1 }}
- alias: Effect Plus
trigger:
platform: mqtt
topic: 'zigbee2mqtt/Partyraum Schalter/action'
payload: 'button_6_single'
action:
- service: wled.effect
entity_id: light.wled
data:
effect: >-
{{ state_attr('light.wled', 'effect') + 1 }}
noxx
(Ralf B)
September 19, 2021, 5:49pm
2
… i havent found a solution yet.
the values should only be between 1 and 117, no negative values…
noxx
(Ralf B)
September 19, 2021, 6:12pm
3
i found this script and had try it, it works. but random isnt what i want
- alias: Lichtleiste Effekt Plus
trigger:
platform: mqtt
topic: 'zigbee2mqtt/Partyraum Schalter/action'
payload: 'button_6_single'
condition:
condition: state
entity_id: light.wled
state: 'on'
action:
- service: wled.effect
target:
entity_id: light.wled
data:
effect: >-
{{ state_attr('light.wled', 'effect_list') | random }}
VDRainer
(🍻)
September 19, 2021, 8:28pm
4
This should do it for count up,
service: wled.effect
entity_id: light.wled
data:
effect: >
{% set effect_count = state_attr('light.wled', 'effect_list') | length %}
{% set current_index = state_attr('light.wled', 'effect_list').index(state_attr('light.wled', 'effect')) %}
{% set next_index = current_index +1 %}
{% if next_index == effect_count %}
{% set next_index = 0 %}
{% endif %}
{{ state_attr('light.wled', 'effect_list')[next_index] }}
and to play with it in DevTools templates for the count down
{{ state_attr('light.wled', 'effect') }}
{{ state_attr('light.wled', 'effect_list') }}
{% set effect_count = state_attr('light.wled', 'effect_list') | length %}
{{ effect_count }}
{% set current_index = state_attr('light.wled', 'effect_list').index(state_attr('light.wled', 'effect')) %}
{{ current_index }}
{% set next_index = current_index +1 %}
{{ next_index }}
{% if next_index == effect_count %}
{% set next_index = 0 %}
{% endif %}
{{ state_attr('light.wled', 'effect_list')[next_index] }}
2 Likes
noxx
(Ralf B)
September 20, 2021, 7:55pm
5
i will try it. thx
Edit: works perfect…
- alias: Lichtleiste Effekt Minus
trigger:
platform: mqtt
topic: 'zigbee2mqtt/Partyraum Schalter/action'
payload: 'button_5_single'
condition:
condition: state
entity_id: light.wled_2
state: 'on'
action:
- service: wled.effect
entity_id: light.wled_2
data:
effect: >
{% set effect_count = state_attr('light.wled_2', 'effect_list') | length %}
{% set current_index = state_attr('light.wled_2', 'effect_list').index(state_attr('light.wled_2', 'effect')) %}
{% set next_index = current_index -1 %}
{% if next_index == 0 %}
{% set next_index = effect_count %}
{% endif %}
{{ state_attr('light.wled_2', 'effect_list')[next_index] }}
- alias: Lichtleiste Effekt Plus
trigger:
platform: mqtt
topic: 'zigbee2mqtt/Partyraum Schalter/action'
payload: 'button_6_single'
condition:
condition: state
entity_id: light.wled_2
state: 'on'
action:
- service: wled.effect
entity_id: light.wled_2
data:
effect: >
{% set effect_count = state_attr('light.wled_2', 'effect_list') | length %}
{% set current_index = state_attr('light.wled_2', 'effect_list').index(state_attr('light.wled_2', 'effect')) %}
{% set next_index = current_index +1 %}
{% if next_index == effect_count %}
{% set next_index = 0 %}
{% endif %}
{{ state_attr('light.wled_2', 'effect_list')[next_index] }}
1 Like