[SOLVED] Using visibility and formatting

Hi all,
I am trying to be a little fancier recently and using the visibility parameter to provide more information to the user when a switch is OFF

Here is the sitemap entry that I am struggling with

				Text item=HO_NodeRed_IP_Online icon=network label="Node Red Online" visibility=[HO_NodeRed_IP_Online==ON]
				Text item=HO_NodeRed_IP_LastSeen icon=network label="Node Red Last Seen [%1$ta %1$tR]" visibility=[HO_NodeRed_IP_Online==OFF]

I get this error in my log

2019-07-19 16:35:09.024 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value 'ON' of item HO_NodeRed_IP_Online with format '%1$ta %1$tR': a != java.lang.String

Is there a way to prevent the exception and still keep the functionality?

Thanks

Paul

That’s a bit weird, it seems to have mungled which Item to apply the [%1$ta %1$tR] format to.

There have been many reports in the past with visibility= that just go away after a reboot (some caching thing I suppose)

Do those lines work without the visibility applied? The error is indeed very odd.

Is HO_NodeRed_IP_LastSeen a DateTime Item?

Thanks guys, it was exactly the poke I needed, this has been bugging me for weeks and I could not work out why either, it survives across reboots and when I went off looking for the items definitions I realised that this must have started when I went through a cleanup period to move many thing and item definitions to PaperUI something I am still in the process of doing.

It turns out I had deleted the item HO_NodeRed_IP_LastSeen and not created it through PaperUI :roll_eyes:

I will now create the missing item and expect it will solve the error.

Regards

Paul

That’s a really odd way for it reveal the problem though, complain about some other Item that happens to be mentioned in visibility.

Well back to this one once again. I am still getting the same errors it did not go away :frowning:

LOG:

 2019-08-26 05:49:12.376 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value 'ON' of item HO_NodeRed_IP_Online with format '%1$ta %1$tR': a != java.lang.String

SITEMAP:

Text item=HO_NodeRed_IP_LastSeen icon=network label="Node Red Last Seen [%1$ta %1$tR]" visibility=[HO_NodeRed_IP_Online==ON]
Text item=HO_Plex_IP_Online icon=network label="Plex Online" visibility=[HO_Plex_IP_Online==ON]

I have both items defined in PaperUI
Checking the two defined items in REST provides this outcome:

REST:HO_Plex_IP_Online

{
  "link": "http://192.168.0.4:8080/rest/items/HO_Plex_IP_Online",
  "state": "ON",
  "stateDescription": {
    "readOnly": true,
    "options": []
  },
  "editable": true,
  "type": "Switch",
  "name": "HO_Plex_IP_Online",
  "label": "Online",
  "tags": [],
  "groupNames": [
    "gHO_Diags"
  ]
}

REST:HO_NodeRed_IP_LastSeen

{
  "link": "http://192.168.0.4:8080/rest/items/HO_NodeRed_IP_LastSeen",
  "state": "2019-08-26T16:28:22.762+1200",
  "stateDescription": {
    "readOnly": true,
    "options": []
  },
  "editable": true,
  "type": "DateTime",
  "name": "HO_NodeRed_IP_LastSeen",
  "label": "Last seen",
  "tags": [],
  "groupNames": []
}

Let me know any mistakes you can see or ideas you may have

Thanks

Paul

The error message does not fit the definition:
the item HO_NodeRed_IP_Online is not the one choosen in Sitemap… maybe this helps…

Does the sitemap work fine (so without errors) if you remove the visibility code?

Assuming @LeftHanded has not spotted the problem for you - that the Item HO_NodeRed_IP_Online referred to in the visibility actually exists and has a valid state.

This could be UI specific - could you try viewing the sitemap with a different UI?

This is a WARN not an error - what effect does it have in the UI, a line unexpectedly shown or hidden perhaps?

Yup, sorry… did not read the complete line… will try to get more concentrated before i guess a meaning

No, I think you are on target. @idkpmiller didn’t show us REST for HO_NodeRed_IP_Online so maybe it doesn’t exist.

I actually I thought I had and then when I checked what I had posted I had made a mistake and given another one.

REST: HO_NodeRed_IP_Online

{
  "link": "http://192.168.0.4:8080/rest/items/HO_NodeRed_IP_Online",
  "state": "ON",
  "stateDescription": {
    "readOnly": true,
    "options": []
  },
  "editable": true,
  "type": "Switch",
  "name": "HO_NodeRed_IP_Online",
  "label": "Online",
  "tags": [],
  "groupNames": [
    "gHO_Diags"
  ]
}

SITEMAP: Whole frame so I get it all correctly shown.

	Frame label="Network" {
		Text item=HO_NodeRed_IP_Online icon=network label="Node Red Online" visibility=[HO_NodeRed_IP_Online==ON]
		Text item=HO_NodeRed_IP_Online  icon=network label="Node Red Last Seen [%1$ta %1$tR]" visibility=[HO_NodeRed_IP_Online==OFF]
		Text item=XiaomiGW_Online icon=network label="Xiaomi Gateway Online" visibility=[XiaomiGW_Online==ON]
		Text item=XiaomiGW_LastSeen  icon=network label="Xiaomi Gateway Last Seen [%1$ta %1$tR]" visibility=[XiaomiGW_Online==OFF]
		Text item=HueHub_Online icon=network label="Hue Hub Online" visibility=[HueHub_Online==ON]
		Text item=HueHub_LastSeen  icon=network label="Hue Hub Last Seen [%1$ta %1$tR]" visibility=[HueHub_Online==OFF]
	}

Does the sitemap work fine (so without errors) if you remove the visibility code?

Sitemap looks like this with the current code and Online.
ONLINE

It looks like this when it goes offline
OFFLINE

So yes an error is displayed.

I have also checked with two separate browsers one that I rarely use, same deal.

Do you still need the same thing doing without the visibility code?

[EDIT] After checking it many times since I had buggered it up when posting I spotted what @LeftHanded had pointed out.

I have now changed the sitemap line to read:

		Text item=HO_NodeRed_IP_LastSeen  icon=network label="Node Red Last Seen [%1$ta %1$tR]" visibility=[HO_NodeRed_IP_Online==OFF]

It is now working correctly when I test:

Thank you so much!
And apologies if anyone is wondering the avatar of a blind man with a cane is correct, I am actually legally blind although not an excuse we all have problems sometimes seeing the wood for the trees.

Thanks & Regards
Paul

Yes, don’t feel bad.
I have just spent ten minutes looking for the difference between the broken line and the good version, too.

Usability suggestion for this kind of thing;
instead of visibility test for ==OFF you can use !=ON, “not on”, which is not quite the same and will match NULL and UNDEF as well as OFF

Funny you should mention that, I realised that it could be improved when I was digging into the issue but I waited until I found the fix before I changed it, so thank you for mentioning it. I have indeed set it !=ON.

Regards

Paul