We need the value of the widget in variable x
for a couple of other triggers too, like on_release
, on_click
, on_defocus
.
The most prominent case is the use of slider
and arc
for adjustments which need only target values, and not intermediate values.
For example this:
- slider:
...
on_value:
- logger.log:
format: "Value on_value: %.0f"
args: [ 'x' ]
dragged from min to max, results in:
[D][main:881]: Value on_value: 1
[D][main:881]: Value on_value: 2
[D][main:881]: Value on_value: 3
[D][main:881]: Value on_value: 7
[D][main:881]: Value on_value: 15
[D][main:881]: Value on_value: 21
[D][main:881]: Value on_value: 28
[D][main:881]: Value on_value: 32
[D][main:881]: Value on_value: 47
[D][main:881]: Value on_value: 53
[D][main:881]: Value on_value: 57
[D][main:881]: Value on_value: 67
[D][main:881]: Value on_value: 73
[D][main:881]: Value on_value: 78
[D][main:881]: Value on_value: 83
[D][main:881]: Value on_value: 86
[D][main:881]: Value on_value: 93
[D][main:881]: Value on_value: 98
[D][main:881]: Value on_value: 99
[D][main:881]: Value on_value: 100
Which means that on_value
is being triggered this often. Which is very good for adjusting the volume of a media player which immediately jumps the volume level to the specified value.
Not sure about a dimmable light, because if the transition time of the light from one value to the other is longer than the time between these triggers, something nasty may happen unless the transition is cancelled when the next command comes in. Maybe this is already handled on the light side.
But if we want to adjust for example a window cover like a roller-shutter which is actuated by a motor and is implemented with a time-based cover platform, that is surely going to go nuts with relays ticking all around and likely break the whole thing.
Also if used as a thermostat control, a more complex heating device like a heatpump wouldn't really reward it if you'd repeatedly set a new target temperature as often as a 10 times per second...
For such cases we need on_release
which is trigggered only once at the end, with the new value of the slider, which represents the target value where the component should go by itself (dimmer with its own transition speed, or motorized cover by its own mechanical features).
If it's easier to just add it to all the triggers, I don't think it would be redundant.