Can't make a basic sitemap work

I’m trying to make a basic sitemap work, and I’m having difficulty making it display any values.

My sitemap is really simple:

sitemap home label="Home" {
    Frame label="Date" {
        Text item=LocalTime_Date2
    }

}

I have an item LocalTime_Date2 bound to the Date channel on the ntp binding. The label comes out correctly, but no value is displayed. In the log there is an error:

017-06-02 16:50:33.946 [ERROR] [.core.internal.folder.FolderObserver] - Error handling update of file '/etc/openhab2/sitemaps/home.sitemap': null.
java.lang.NullPointerException
	at org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener.getAllItems(PageChangeListener.java:125)[118:org.eclipse.smarthome.io.rest.sitemap:0.9.0.201706012026]
	at org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener.updateItemsAndWidgets(PageChangeListener.java:75)[118:org.eclipse.smarthome.io.rest.sitemap:0.9.0.201706012026]
	at org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener.sitemapContentChanged(PageChangeListener.java:217)[118:org.eclipse.smarthome.io.rest.sitemap:0.9.0.201706012026]
	at org.eclipse.smarthome.io.rest.sitemap.SitemapSubscriptionService.modelChanged(SitemapSubscriptionService.java:277)[118:org.eclipse.smarthome.io.rest.sitemap:0.9.0.201706012026]
	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:286)[123:org.eclipse.smarthome.model.core:0.9.0.201706012026]
	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:136)[123:org.eclipse.smarthome.model.core:0.9.0.201706012026]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:244)[123:org.eclipse.smarthome.model.core:0.9.0.201706012026]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:315)[123:org.eclipse.smarthome.model.core:0.9.0.201706012026]
	at org.eclipse.smarthome.core.service.WatchQueueReader.run(WatchQueueReader.java:206)[99:org.eclipse.smarthome.core:0.9.0.201706012026]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]

I can display a chart of some other items, but not their current values, which is odd. I have a “Text” and a “Chart” both referencing the same item, and the chart displays but the text shows nothing.

This is with openHAB 2.1.0 Build #934

Any ideas?

Perhaps the Item definitions would be relevant

I have a ntp time server called “ntp:ntp:local”, and I have bound an item to the “ntp:ntp:local:dateTime” channel. I used the PaperUI interface to create the item definition from the thing end (I didn’t create the item first and then link, I created the item from the “thing” end). It’s of type DateTime.

It’s the simplest possible configuration I can construct, requiring only the “NTP” binding.

Since I created the definitions from the user interface there’s no item definition line I can copy and paste from an items file.

Does that help?

I wondered what might be set for the item’s label, as none is defined in sitemap.

Label was set up by the wizard, and was “Date”. I also tried setting a label on the sitemap and I get the same result.

So here’s a curious thing.

I’ve been working trying to debug this within eclipse.
I think the exception is a red herring.

I have a site map:

sitemap home label="Main Menu"
{
Frame label="Demo" {
    Text item=CurrentDate
    Text item=NTPServer_Date1
   }
}

The “CurrentDate” item is the item defined in the demo.items file. The NTPServer_Date1 item is an item I’ve created through the PaperUI, bound to exactly the same channel. It’s a DateTime item bound to the same ntp:ntp:demo:dateTime channel.
The “CurrentDate” value comes out, but not the NTPServer_Date1 value.

I’ve tried binding to the “ntp:ntp:demo:string” channel as well, and that also comes out blank.

So it looks to me like sitemaps don’t work with items that have been created in the user interface. This seems very odd, so I’m sure that can’t be right, that just seems to basic a thing to be wrong.

If I remove the “format” string from the CurrentDate item in the demo.items file it also comes out blank, so it looks like DateTime values need to have a format string associated with them. There appears to be no way to specify this in the user interface that I’ve found. Indeed viewing the “CurrentDate” item defined in the .items file doesn’t display any “format” string. So is it as simple as that? That item definitions in the user interface are broken, or just not ready for use yet?

It’s always somewhat surprised me that editing in the user interface doesn’t just create a “.items” file like you would manually. I’ve yet to work out where the definitions you edit in the user interface are stored to be able to tweak manually.

This what I was trying to prompt you to look at. I don’t know how you set that in Item label under PaperUI. You may alternatively/also set labels and formatting in sitemaps.

Hmm, OK. Apologies for not twigging earlier that “label” meant “label, and by the way how to format the value too, forget and you get nothing” :slight_smile:

The documentation doesn’t indicate that this is a necessary field in a sitemap (emphasis mine):

Second, it can be used to format or transform output from the item (for example, making DateTime output more readable)

I’m surprised that with lack of anything else it doesn’t do a naive “toString()” on the value to get something to print. There’s nothing in the sitemap documentation to indicate that a format string is required somewhere either on the item itself or in the sitemap.

Looking at items that are declared in an item file from the PaperUI, you don’t see the “format” string in the label field, so it’s as if the format portion is stripped of ans stored separately.

All highly un-intuitive in my opinion.

Anyway problem solved I think. If you are creating the items in PaperUI, you need to specify a format string in the sitemap by the looks of it.

When I get a bit of time, and and a bit more sure, I’ll try and submit some clarification to the docs.

Anyway resolved now so thatnks for our help.

yes, but I suppose some means is needed for ‘dont show any value’. (Some folk will want to use icons only)

Yes please!
For anyone else coming across this, this posting covers similar ground

I’ll try and get some more understanding first. I need to understand the situation more fully, but when I have some time, I’ll try and gather together some experiences and confusions I had along the way and try and contribute them in some way.

That is a good point that I hadn’t considered. However for a newbie like me, the default behaviour being to print out blank was mightily confusing. Interestingly though, the implication is that if you have a format string defined on the item itself, there would be no way to get “icon only” in the sitemap?

Anyway. Once I’ve gained a more complete understanding I’ll try and get my experiences straightened up.

Here’s a curious thing.

I have a zwave weather station that reports a bunch of battery levels. I have bound all of these to “number” items with category “battery”.
I have all of the battery levels in a group, and have a sitemap “Group” entry to show them all.
Looking at the values in the “Control” section of the “PaperUI”, some of them show as “100%”, some of them only show as “100”.

Looking at the values through the sitemap, those that are displayed as “100%” in PaperUI have values displayed, those that are displayed as “100” don’t. They all have suitable icons showing full batteries. So somewhere the formatting is going awry for some of the values.

There is no discernible difference that I can find in the channel definitions or in the item definitions. Here’s the JSONDB for one that works:

  "WeatherStationBatteryLevel3": {
    "class": "org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem",
    "value": {
      "groupNames": [
        "BatteryLevels"
      ],
      "itemType": "Number",
      "tags": [],
      "label": "Weather Station Battery Level 3",
      "category": "Battery"
    }
  },

Here’s one that doesn’t:

  "WeatherStationBatteryLevel4": {
    "class": "org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem",
    "value": {
      "groupNames": [
        "BatteryLevels"
      ],
      "itemType": "Number",
      "tags": [],
      "label": "Weather Station Battery Level 4",
      "category": "Battery"
    }
  },

They are identical. the “item - channel” links are similarly identical.
So I have no idea what the difference is. I can’t alter the formatting in the sitemap, as it’s just done through a “Group” element. I have no idea where the “%” formatting is coming from, but it’s being applied inconsistently, or at least according to some setting I haven’t found or don’t have access to.

This is most peculiar.
Anyone shed any light?

OK. So I’ve solved it :slight_smile:

Turns out I had some duplicate item-channel links from an old copy of the “thing” (I had deleted it and recreated it in an attempt to get it to work – deleting the thing obviously left the item-thinks in place).
Having stopped openHAB, cleaned out the relevant entries from the relevant JSONDB file and restarted openHAB, it now displays all of the values correctly.

Very odd.