frnak
(Frank Cassata)
March 10, 2023, 5:39pm
1
Trying to copy the “Dim lights THE RIGHT WAY ” tutorial, and I have a problem with the loop never ending. Can anyone spot what’s wrong here?
alias: seqrepeattest
description: seqrepeattest
trigger:
- platform: device
domain: mqtt
device_id: d7be3cdd4627110879ece4b209dcabf0
type: action
subtype: dial_rotate_left_step
discovery_id: 0x001788010d12e163 action_dial_rotate_left_step
id: leftstep
condition:
- condition: trigger
id: leftstep
action:
- repeat:
while:
- condition: trigger
id: leftstep
sequence:
- service: light.turn_on
data:
brightness_step_pct: -5
target:
entity_id: light.ljosakrona
- delay:
milliseconds: 200
mode: restart
123
(Taras)
March 10, 2023, 6:33pm
2
You need to change the while
's condition to monitor the device’s current value, not the value it had when it triggered the automation.
The way you have it now, the automation triggers when it detects dial_rotate_left_step
and proceeds to repeatedly decrement the light’s brightness while the trigger.id
is leftstep
which it does endlessly because the automation is designed to trigger for no other value than dial_rotate_left_step
.
1 Like
frnak
(Frank Cassata)
March 10, 2023, 8:18pm
3
Thanks for the pointer, still not getting it though. I’ve added another trigger, but still looping endlessly, pretty much copying directly from another user in this thread who reported his code working
alias: Borðstofa Dimmer
description: Borðstofa Dimmer
trigger:
- platform: device
domain: mqtt
device_id: 9a48f8c1fa36ad56bdbf4b5810a3e5b0
type: action
subtype: button_1_hold
discovery_id: 0x001788010d12c71a action_button_1_hold
id: hold1
- platform: device
domain: mqtt
device_id: 9a48f8c1fa36ad56bdbf4b5810a3e5b0
type: action
subtype: button_3_hold
discovery_id: 0x001788010d12c71a action_button_3_hold
id: hold3
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: hold1
sequence:
- repeat:
while:
- condition: trigger
id: hold1
sequence:
- service: light.turn_on
data:
brightness_step: 10
target:
entity_id: light.ljosakrona
- delay:
milliseconds: 200
- conditions:
- condition: trigger
id: hold3
sequence:
- repeat:
while:
- condition: trigger
id: hold3
sequence:
- service: light.turn_on
data:
brightness_step: -10
target:
entity_id: light.ljoskrona
- delay:
milliseconds: 200
mode: restart
123
(Taras)
March 10, 2023, 11:26pm
4
The first example you posted isn’t like the one in the other topic because it employs a condition that effectively prevents any other kind of button press from interrupting the repeat
(and so it loops endlessly).
I also know why the second example loops endlessly. However I see that you have already posted in the topic where you got the example so, to avoid the duplication of topics (cross-posting is discouraged), I’ll let the author of the example help you sort it out.
frnak
(Frank Cassata)
March 11, 2023, 3:06pm
6
123:
The first example you posted isn’t like the one in the other topic because it employs a condition that effectively prevents any other kind of button press from interrupting the repeat
(and so it loops endlessly).
I also know why the second example loops endlessly. However I see that you have already posted in the topic where you got the example so, to avoid the duplication of topics (cross-posting is discouraged), I’ll let the author of the example help you sort it out.
I would appreciate if you share your information since the other thread seems to be dead.
123
(Taras)
March 11, 2023, 3:57pm
7
I don’t have the means to test the following automation so it may require further adjustments.
It listens for two types of button events: hold
and release
.
When hold
is detected, it increases or decreases the light’s brightness, depending on which button was pressed.
When release
is detected, it stops increasing/decreasing the light’s brightness.
alias: Borðstofa Dimmer
description: Borðstofa Dimmer
trigger:
- platform: device
domain: mqtt
device_id: 9a48f8c1fa36ad56bdbf4b5810a3e5b0
type: action
subtype: button_1_hold
discovery_id: 0x001788010d12c71a action_button_1_hold
- platform: device
domain: mqtt
device_id: 9a48f8c1fa36ad56bdbf4b5810a3e5b0
type: action
subtype: button_1_release
discovery_id: 0x001788010d12c71a action_button_1_release
- platform: device
domain: mqtt
device_id: 9a48f8c1fa36ad56bdbf4b5810a3e5b0
type: action
subtype: button_3_hold
discovery_id: 0x001788010d12c71a action_button_3_hold
- platform: device
domain: mqtt
device_id: 9a48f8c1fa36ad56bdbf4b5810a3e5b0
type: action
subtype: button_3_release
discovery_id: 0x001788010d12c71a action_button_3_release
condition: []
action:
- repeat:
until: "{{ 'release' in trigger.payload }}"
sequence:
- service: light.turn_on
data:
brightness_step: "{{ 10 if trigger.payload == 'button_1_hold' else -10 }}"
target:
entity_id: light.ljosakrona
- delay:
milliseconds: 200
mode: restart
frnak
(Frank Cassata)
March 11, 2023, 4:08pm
8
Thank you kindly for the pointers, this makes sense and I think I can take it from here!
frnak
(Frank Cassata)
March 11, 2023, 4:27pm
9
Yup this absolutely did the trick, thank you very much, also much cleaner syntax.
Is this possible if there is no explicit message accompanied with stopping the action? For example for a rotating knob that only sends a rotate_right/left_step
?
1 Like
123
(Taras)
March 11, 2023, 4:31pm
10
You’re welcome!
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.
For more information about the Solution tag, refer to guideline 21 in the FAQ .
I suggest looking at how blueprints implement it, for example this one:
REMOTE Tradfri Wireless Dimmer (ICTC-G-1) for media player control
[image]
Blueprint to support the IKEA Tradfri Wireless Dimmer (ICTC-G-1) and allow it to control a media player device.
The following features are implemented:
rotation right/left and player is playing: media_player.volume_set up/down (to configured max/min volume)
rotation right and player is paused: media_player.media_play
rotation right with stop and player is playing: media_player.media_next_track
rotation left with s…
frnak
(Frank Cassata)
March 11, 2023, 5:52pm
11
Thanks again, not quite sure what in that automation is relevant. Should I repeat until the action in the device’s state is empty or null?