Sitemap doesn't show value


I’ve starting to use sitemaps now for my basicUI interface, but I won’t work the way I want.
I have a switch for a smart power outlet (with integrated meter), and I want to show the power consumption of the lamp under the switch.

My sitemap looks like this:

sitemap R207 label=“R207”
Switch item=R207_Power label=“lamp”
Text item=R207_Power_Meter label=“power consumption”


It shows the label “power consumption”, but not the value.

The item is included in default.items as:

Number R207_Power_Meter “consumption” {channel=tplinksmarthome:hs110:563023:power}

Is there anything I’m missing? Thanks!

Your item is wrong, and missing the value code… This is all my items for the same device (hs110):

Switch 	MySmartPlug1SW	    "My Smart Plug1 on/off [%s]"			<poweroutlet_eu> 	[ "Outlet" ]	        { channel="tplinksmarthome:hs110:82E954:switch" }
Switch 	MySmartPlug1SWLed	"My Smart Plug1 Switch Led [%s]"		<switch> 	 				{ channel="tplinksmarthome:hs110:82E954:led" }
Number 	MySmartPlug1Signal	"My Smart Plug1 Signal [%d dBm]"		<cu_wifi>					{ channel="tplinksmarthome:hs110:82E954:rssi" }
Number 	MySmartPlug1Power	"My Smart Plug1 Power [%d W]" 			<Energy>					{ channel="tplinksmarthome:hs110:82E954:power" }
Number 	MySmartPlug1Energy	"My Smart Plug1 Energy Usage [%.1f kWh]" 	<Energy>					{ channel="tplinksmarthome:hs110:82E954:energyUsage" }
Number 	MySmartPlug1Current	"My Smart Plug1 Current Power [%.1f A]" 	<Energy>					{ channel="tplinksmarthome:hs110:82E954:current" }
Number 	MySmartPlug1Voltage	"My Smart Plug1 voltage [%.1f V]"	 	<Energy>					{ channel="tplinksmarthome:hs110:82E954:voltage" }


Is there a guide for the [%…] codes?
What does the d, .1f and s mean?

As Kim says, the part of the label in square brackets [ ] describes how to display the Item state value. No [ ], no display.

Note that specifying the label in the sitemap overrides the default label in the Item definition, so in this case you’d need to edit the sitemap label (or omit it so that it defaults to the Item version)
EDIT - ive just read that I’m wrong here; sitemap label=“text” should retain the [format] from an Item definition. label=“text []” would supress it.

There is, but I cant remember where it´s documented… :blush:
There is something here:
Actually, you should perhaps read most of the items docs through. It will give you a major overview of how to create items. You seem to be missing some very basic part of it.

I think I recall there is a full list somewhere showing all syntaxs. It´s some java-stuff as far as I recall. I normally search the community when I have problems, otherweise I use what I remember.

EDIT… While I remember…
You should look at your logfile as well. I believe openhab should have showed an error for your item due to the missing " " in the channel definition.

Okay thanks. Will read through it.

I’ve now added the state with [%…] in my default.items file and in the sitemap.
Instead of the value, it shows " - ".

Not sure what went wrong, the channel is correct. Is there anything else missing?

Look in events.log or PaperUI to find out what the state of your Item actually is. a display “-” usually means it is NULL or UNDEF.
When you edit an xxx.items file the reload causes states to go NULL until the next update comes along.

What is the secret format that you actually used? [%s] is useful for temporary diagnostics.

In the paper UI control panel I can see 155W power when the switch is turned on.

in default.items I set

Number R207_Power_Meter "Power [%d W] " <energy> {channel="tplinksmarthome:hs110:563023:power"}

like Kim_Andersen did.

In the sitemap file, I didnt use [%], because as you said, I will take the one from the item file, am I right?

Try [%s] in the sitemap to investigate. Editing sitemap does not mess up Items, but be sure to refresh browser afterwards.

[%s] in Sitemap gives me " - " again.

I dont use labels in sitemaps, unless I have a very specific reason to… I define the labels in my items insted as you can see from my items, and in sitemap I just enter:

sitemap R207 label=“R207”
Switch item=MySmartPlug1SW
Text item=MySmartPlug1SWLed
Text item=MySmartPlug1Signal
Text item=MySmartPlug1Power
Text item=MySmartPlug1Energy
Text item=MySmartPlug1Current
Text item=MySmartPlug1Voltage

There is no reason to do anything else, unless you want a specific methode/look in BasicUI.

It will happen if the items hasn´t updated yet or if the item definition is wrong somehow…
Look at your logfile, it may show something, cause it will show if the item isn´t defined correctly.

If it´s the same item which shows 155W in paperUI, the item do update, and it should show value in sitemap as well, if you have the item defined correctly in your sitemap. (look out for mispelling/typos etc).

Ok so I tried to begin from scratch:

I take the channel ID from the power channel of the plug and create a new item in default.items like this:

Number R207Power "Power [%d W]" <energy> {channel=tplinksmarthome:hs110:563023:power}.

In the sitemap file,
I just use

sitemap R207 label=“R207”
Text item=R207Power

Still not working, and the log files delivers:

If I use Habpanel to create a dummy to show me the value, I can easily select the channel=tplinksmarthome:hs110:563023:power

It looks like the item R207Power doesn’t exists. Did you save your default.items?

You item is still wrong… It´s missing the " " in the channel definition. Like this:

Number R207Power "Power [%d W]" <energy> { channel="tplinksmarthome:hs110:563023:power" }

There it was… Thx Rich! :slight_smile: