[BasicUI] change selected switch mapping

Hello everyone,

I can set the temperature for my heating in two ways:

Setpoint item=Thermo1 label="SOLL Temperatur [%.0f °C]" icon="temperature" minValue=4.5 maxValue=26 step=1
Switch item=ThermoMapping label="Temp." icon="temperature" mappings=[18="18°C", 20="20°C", 22="22°C"]

Both work!

However, the temperature set for Thermo1 should also be transferred to ThermoMapping, if available (if nothing is selected in the mapping).
How is this possible?

This is not working:

rule "Heizung2Mapping"
when
	Item Thermo1 changed
then
	ThermoMapping.sendCommand(Thermo1.state.toString)
end

Explanation: If you set 18°C in ThermoMapping and then freely adjust the temperature in Thermo1, the (now incorrect) 18°C remains displayed in ThermoMapping and when you click on 18°C nothing happens. (You first have to click on another temperature and then on 18°C).

Thank you!

Not working how? Error?

Typically you’ll want to postUpdate instead of commanding the Item unless that Item is linked to a Channel and you want the device to do something. In this case you are just keeping two Items in sync inside of OH so updates are what you want to use.

Both Thermo1 and TermoMapping are Number Items?

Note, if you freely adjust Thermo1 to anything other than exactly 18, 20, and 22 (note 18.0 is not the same as 18 in this case), there won’t be a mapping that matches the current state of the Item so it won’t change because it has nothing to change to.

Finally, I’m not certain that BasicUI updates the mappings without a refresh of the page anyway.

1 Like

Basic UI of course updates the selected button based on the current item state.

In case there is no mapping, all buttons will become unselected.

1 Like

Replace label=“Temp.” By label=“Temp. [%s[” To see exactly the item state that is set by your rule.
Or check the value in events.log

1 Like

I don’t think you need thermomapping at all. Just do

Setpoint item=Thermo1 label="SOLL Temperatur [%.0f °C]" icon="temperature" minValue=4.5 maxValue=26 step=1
Switch item=Thermo1 label="Temp." icon="temperature" mappings=[18="18°C", 20="20°C", 22="22°C"]
1 Like

To control the thermostat, it does not matter whether it is an Int or Float (with a decimal place).
But you are right, for mapping it must be exactly the same number.

Quite funny, but I restarted my OH (because of other errors) and now the code I posted above works to set the mapping.

Thank you, it works, but not as intended. You save a variable, but the mapping is never marked, you always have to press the button twice for this.
And if you change the temperature manually in the setpoint, the temperature is unfortunately not visible in the mapping.

Thank you all very much!

What exactly do you want to see? If you want to see the exact set point temperature @Lolodomo gave the answer above I think. Add the format to your label.

"Temperature [%d °C]" or %s depending on what formatting you want. typed on a phone so double check that degree symbol.

No.

I would like the temperature that is currently selected to be displayed directly in the mapping. This works with my code:
ezgif-5-9d86eb8cc3-1

If you only have one variable (and display the temperature in the switch in an unattractive way), it looks like this:
ezgif-5-613d024c87

Thanks for the detailed screen video!

What you want to achieve can be done using one item like I posted above.
The key here is to make sure the mapping command matches the item’s state. I’m guessing (since I haven’t seen your item’s definition) that Thermo1 is a Number:Temperature item?

Try this:

Switch item=Thermo1 label="Temp." icon="temperature" mappings=["18 °C"="18°C", "20 °C"="20°C", "22 °C"="22°C"]