Buttons to Increase/Decrease Item Value

(Rob Pope) #1

I’m very new to Angular (as in no experience) so have been getting by with adapting other examples, so apologies if this is actually straight forward.

One thing I struggle with on my tablet is increasing and decreasing the volume. I just kind of stab at the screen at the rough place that I want the volume to be. What would be preferred is a Vol+ and Vol- button.

I’ve managed to get the following (volumeStep is a number set to 5 in my setup) which I can successfully change a volume of 5 to 0 with the minus button, then back to 5 with the plus button (hooray I thought!) and then to 55 with another click of the plus button (damn).

So itemValue + configValue is a string concatenation. If I can do an actual addition that would be great, but I can’t quite work out how and google is giving me the option to create Angular methods, which I’d rather avoid if possible.

So can I do basic math in HabPanel?

0 Likes

(Harry) #2

Do you search for setpoint?

https://docs.openhab.org/configuration/sitemaps.html

or is HabPanel the keyword, than maybe this can help

https://community.openhab.org/t/manipulate-numbers-via-a-button-in-a-widget/34101
https://community.openhab.org/t/template-widget-tutorial-examples-make-your-own-widget/14211/146

0 Likes

(Rob Pope) #3

Thanks @hr3 - That worked like a charm. My code looks like this now:

<div class="volume-buttons">
  	<label class="vol-dn"
           ng-click="sendCmd(config.playerVolume, +itemValue(config.playerVolume) - config.volumeStep)"><i class="glyphicon glyphicon-minus"></i></label>
    {{itemValue(config.playerVolume)}}
    <label class="vol-up"
           ng-click="sendCmd(config.playerVolume, +itemValue(config.playerVolume) + config.volumeStep)"><i class="glyphicon glyphicon-plus"></i></label>
  </div>
1 Like

(Miloslav Janda) #4

How do you solve min and max? Are you happy to share config please? I think lot of us are interested :slight_smile: Thank you

0 Likes

(GonzaloN) #5

I have the same concern. Did you solve it? Are you willing to share it?

Thanks!

0 Likes