Icon Mapping

My heatingwater has a temperature between ~35 and 55°C
Is there a way to represent this with the heating-icons?
30° should display the heating-0.png and 60° the heating-100.png

Use a rule to create a Percent value item and have that shown in your site map. If you’re not familiar with rules I can post an example.

1 Like

I have a similar solution for my heating, maybe this helps you. Also if anybody knows a better way to do it i’m grateful for any hints.

What i’ve done is creating additional items for the Icons:

Number WZHIcon "Heating Icon Livingroom"

with a rule i check the temperature at every change and change the value of the item depending on the temperature range:

rule "ChangeHeatingWZHIcon" when Item WZHeizung received update then if (WZHeizung.state >= 0 && WZHeizung.state <=20) {postUpdate(WZHIcon, 0) } if (WZHeizung.state > 20 && WZHeizung.state <= 40) {postUpdate(WZHIcon, 20) } if (WZHeizung.state > 40 && WZHeizung.state <= 60) {postUpdate(WZHIcon, 40) } if (WZHeizung.state > 60 && WZHeizung.state <= 80) {postUpdate(WZHIcon, 60) } if (WZHeizung.state > 80 && WZHeizung.state < 100) {postUpdate(WZHIcon, 80) } end

after this i’ve made multiple entries in the sitemap and used the visibility to only show the one entry depending on the value of the item WZHIcon:

Text item=WZHeizung label="Heizung [%d %%]" icon="heating-0" visibility=[WZHIcon==0] Text item=WZHeizung label="Heizung [%d %%]" icon="heating-20" visibility=[WZHIcon==20] Text item=WZHeizung label="Heizung [%d %%]" icon="heating-40" visibility=[WZHIcon==40] Text item=WZHeizung label="Heizung [%d %%]" icon="heating-60" visibility=[WZHIcon==60] Text item=WZHeizung label="Heizung [%d %%]" icon="heating-80" visibility=[WZHIcon==80]

1 Like

Thank you - that will help me to continue!
I never heard of the visibility-parameter. Nice.

Here is an example I quickly put together. Not tested, so it may contain an error.


Number Heating_WaterTemperature        <temperature> "Temperature [%.1f °C]" (Heating)
Number Heating_WaterTemperaturePercent <heating>     "Temperature [%.1f %%]" (Heating)


rule "ComputeWaterTemperaturePercent"
	Item Heating_WaterTemperature received update

	// limits
	var Number tmin=30 // 0%
	var Number tmax=60 // 100%

	// compute
	var Number t = (Heating_WaterTemperature.state as DecimalType)
	t = Math::max(t, tmin) // not < 0
	t = Math::min(t, tmax) // not > 100
	var Number p = ((t - tmin) / (tmax - tmin))

	// you could round the value first if you need to

	logDebug("ComputeWaterTemperaturePercent", 'Temperature in %: ' + p)
	postUpdate(Heating_WaterTemperaturePercent, p)

Thank you Robert.
But it’s not possible to combine the icon and the temperature. Right?
They’ll stay two different Items.

In my understanding the icon is depending on the item itself (multiple items for multiple icons) OR the value of the corresponding icon (multiple different icons for one specific item).

So I understand that you like to show the temperature and a varying icon?

A dirty workaround would be to compute the percentage as above and then use a JS transformation to show that as a temperature again.

1 Like