I have a seemingly simple logical solution, but could not find any way to implement it and have searched high and low. I would appreciate any advice and input.
Summary: I have buttons for volume+/- via Broadlink IR and want to translate this to a volume slider.
Idea:
Create input_number (to use as slider on the dashboard)
Some event/automation that triggers when input_number changes (sliding the volume). (i got stuck here and could not even get this to work)
Get the difference from the new value to the old value - perhaps keep a duplicate input_number for the previous value.
Execute the volume+/- service/button X times. X being the difference from the previous step.
Update the “previous value” to the new value.
e.g.
Slide from 60 to 40
X = -20 (X < 0 means Vol- (X > 0 Vol+))
So call Vol- button 20 times.
Is this even possible or am I chasing my own tail. I have seen some posts trying other methods to achieve a similar thing, but no success. This seems like a pretty common use case.
Since there’s no true feedback of the volume status, and it can be changed by other remotes or service calls, it’s possible to get into a situation where the actual volume is too high but the slider cannot lower it and vice versa.
Wow! This worked. Thank you so much. I never saw example or documentation with the variables.
Missing closing bracket ) in the iif cost me like an hour but got it working.
Thank you so much.
Note for others:
This works, but it is a bit laggy and does not maintain proper state if changed from other sources as the answer mentioned, but I am fine with that for now and is exactly what I needed.