Manipulate Numbers via a Button in a Widget

Hi Guys,
currently i have a slider for my Thermostat to regulate the desired Temperature (item of type number)
But the Window in which we usually move the desired Temp. is quite small,
So i decided to write a own Widget for the Thermostat.
I would like to start with to Buttons + and - .+ Should increase the Temp 0.5 and - should decrease the Temp about 0.5.
I thought this may work:

Preview:

{{itemValue('Kitchen_Desired_Temp')}}
{{itemValue('Kitchen_Desired_Temp')-0.5}}
{{itemValue('Kitchen_Desired_Temp')+0.5}}

<button class="btn btn-default"
        style="width: 100%; height: 2em;
               font-size: 30px"
        ng-click="sendCmd('Kitchen_Desired_Temp', '{{itemValue('Kitchen_Desired_Temp')+0.5}}')">
<i class="glyphicon glyphicon-menu-up"></i>
</button>

This left me with following:
22.00
21.5
22.000.5

So in the Preview decreasing the temp seems working that way, but increasing is looking weird.
Also the Button is not working, not for + nor for -.

Do you have any advice?

Thanks
Andreas

I’ve done something similar with

ng-click="sendCmd(config.hour, +itemValue(config.hour)+1)"

Notice the “+” in front of itemValue. I can’t remember why it was needed, but it seems to be essential. Also for future compatibility itemState should be used instead of itemValue.

1 Like

Hi Mikael,
thanks for the Feedback.
I got a bit closer, but the button is still not working. My code now looks like this:

Ist: {{itemValue('Kueche_Heizungsthermostat_SOLL_Temperatur')}}<br>
-:{{itemValue('Kueche_Heizungsthermostat_SOLL_Temperatur')-0.5}}<br>
+:{{+itemValue('Kueche_Heizungsthermostat_SOLL_Temperatur')+0.5}}

<button class="btn btn-default"
        style="width: 100%; height: 2em;
               font-size: 30px"
        ng-click="sendCmd('Kueche_Heizungsthermostat_SOLL_Temperatur',{{+itemValue('Kueche_Heizungsthermostat_SOLL_Temperatur')+0.5}})">
<i class="glyphicon glyphicon-menu-up"></i>
</button>

The result for the preview i do at first is now working fine, but i can’t get the button to change the temperature.
What is it i am not seeing at the moment? :-/

Andi

Hi Andreas,

I hade a similar problem a while ago, and ended up with this (although I don’t recall the reason right now):

ng-click="sendCmd(config.t_heat, itemValue(config.t_heat) * 1 + 0.5) "

The {{ }} are invalid there, you’re already inside an expression context, it should be:

ng-click="sendCmd('Kueche_Heizungsthermostat_SOLL_Temperatur', +itemValue('Kueche_Heizungsthermostat_SOLL_Temperatur')+0.5)">

1 Like

Hi Yannick,
what 4 little signs can make a difference :slight_smile:
Now i have a working situation. The changes when i hit the buttons are not really that fast as my current slider is doing it, but to change the temp in 0,5 steps this is perfect.

Also the suggestion from Arnen worked!

My working code is then looking that way:

<button class="btn btn-default"
        style="width: 100%; height: 2em;
               font-size: 30px"
ng-click="sendCmd('Kueche_Heizungsthermostat_SOLL_Temperatur', itemValue('Kueche_Heizungsthermostat_SOLL_Temperatur') * 1 + 0.5) "
<i class="glyphicon glyphicon-menu-up"></i>
</button>

And as click event these both work:

ng-click="sendCmd('Kueche_Heizungsthermostat_SOLL_Temperatur', +itemValue('Kueche_Heizungsthermostat_SOLL_Temperatur')+0.5)">

ng-click="sendCmd('Kueche_Heizungsthermostat_SOLL_Temperatur', itemValue('Kueche_Heizungsthermostat_SOLL_Temperatur') * 1 + 0.5) "

Thank you all
Andreas