Contact Item Type throwing an error

  • Platform information:

    • Hardware: Raspberry Pi3
    • OS: Openhabian
    • Java Runtime Environment: openjdk version “1.8.0_212” OpenJDK Runtime Environment (Zulu8.38.0.163-CA-linux_aarch32hf) (build 1.8.0_212-b163) OpenJDK Client VM (Zulu8.38.0.163-CA-linux_aarch32hf) (build 25.212-b163, mixed mode, Evaluation)
    • openHAB version: 2.4.0-1
  • Issue of the topic:

I have the below item & sitemap files throwing the warnings in the log which result in not loading up the sitemap in the Basic UI. Any suggestions why?

default.items:

Switch FF_Toilet_Motion “Toilet Motion Sensor” {channel=“mihome:sensor_motion:158d000163e344:motion”}
Contact FF_MasterBedroom_Door Master Bedroom Door" {channel=“mihome:sensor_magnet:158d00016c82ff:isOpen”}

test.sitemap:
sitemap test label=“My first sitemap”
{
Switch item=FF_Toilet_Motion label=“Toilet Motion”
// Contact item=FF_MasterBedroom_Door label=“Room Door”
}

  • If logs where generated please post these here using code fences:

==> /var/log/openhab2/openhab.log <==
2019-07-28 21:22:31.416 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘test.sitemap’ has errors, therefore ignoring it: [4,2]: mismatched input ‘Contact’ expecting ‘}’

2019-07-28 21:22:31.515 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘default.items’ has errors, therefore ignoring it: [2,31]: missing EOF at ‘Master’
[2,111]: mismatched character ‘’ expecting ‘"’

I do not think that line beginning is permitted, at least that is what the error indicates. Sometimes reading it can give a clue to what is wrong. :wink:

1 Like

Please How to use code fences.

Details like spaces and new lines are important.

In your Items, you are missing the starting " for the label.

That might be causing both errors. I don’t see anything obviously won’t with the sitemap.

To expand on what Bruce says, there is no Contact widget for sitemaps.

When you add lines to a sitemap, you’re adding elements that are really widgets to display this way or that way.
Some of those widgets have the same name as Item types - like Switch - but there is no direct relation. Often any given widget could be used with a variety of Item types.

A good starting point to display a Contact type Item would be to use a Text widget in the sitemap. That allows you to show the Item’s label, state, icon etc. but does not offer a way for the UI user to change it.
https://www.openhab.org/docs/configuration/sitemaps.html

2 Likes

thanks @rossko57, I think this is the fix for my problem. I dont have access to my Openhabian environment now but I will definitely try this first thing I get hold of it this evening. The reason I was trying to use the syntax above was because this was part of the code generated for the sitemap through the UI Builder. If there is not widget named Contact, I guess its a bug in the UI Builder that needs to be fixed. Since I’m new to OpenHAB, I’m not sure where to post this so that the team can fix it in the next release. Once again, thank for the feedback.

UI Builder ? I guess the first step here is identifying the feature you’re using.

1 Like

Correction “Home Builder” NOT “UI Builder”

Ok so I tried the below. Basically, I’m now using the Text Widget in the site map to display the status of the Contact type item in the items file. Unfortunately the status returned by FF_MasterBedroom_Door item is not shown in Basic UI. I dont see any errors nor warnings in the logs too. Are there any additional steps that needs to be followed?

Default.items:

Switch FF_Toilet_Motion “Toilet Motion Sensor” {channel=“mihome:sensor_motion:158d000163e344:motion”}
Contact FF_MasterBedroom_Door “Master Bedroom Door” {channel=“mihome:sensor_magnet:158d00016c82ff:isOpen”}

Test.sitemap:

sitemap test label=“My first sitemap”
{
Switch item=FF_Toilet_Motion label=“Toilet Motion”
Text item=FF_MasterBedroom_Door label=“Room Door”
}

That’s because you haven’t asked for the state to be displayed. There is an important part of the Item label which is the formatter, the part in [ square brackets ]. This telss the Ui how to display the Item state.
[%s] produces a simple string.

Contact myItem “my door [%s]” …

When you specify the label in an Item definition, that is the default label (and formatter) n the UI.
When you choose to give the optional label in the sitemap, this will override the Items label (and formatter).

2 Likes

Thanks @rossko57, you are the man :-). It worked finally! Would you be able to point me to the documentation related to what other formatter option we have?

The Items documentation mentions this.
https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax