Sitemaps: Color and dynamic features to be added....

3,349 views
Skip to first unread message

Chris Jackson

unread,
Oct 20, 2013, 8:18:07 AM10/20/13
to ope...@googlegroups.com
I've made a few small modifications to the sitemap model and rendering system to add support for various new features to make the sitemap more dynamic. These are mainly on the issues list, so shouldn't be major surprises, but I think they improve the sitemap system considerably. I intend to release an initial test version of this in the next day or two, but thought I'd post what I'm doing now in case people have thoughts on the topic.

Currently, all of the features listed below are implemented and working - I'm just testing various bits and pieces before I make it available.

Any comments welcome.

Chris


1) Dynamic Colors
Colors have been added to "all" widget components - icon, label and value (labelcolor/iconcolor/valuecolor). Each can be specified individually, and they can be a static value (eg. labelcolor=[green]), or a conditional array of colors (eg iconcolor=[ON=green, OFF=red]). The conditional test is against the item defined in the widgets item= tag, and numeric values are tested as > so ordering of the list is important.
Linked to issue: 317

2) Dynamic Icons
Similar to colors, icons can now be changed dynamically. The existing static icon can still be used (eg icon="temperature"), but you can now add a dynamic array of icons (eg icon="30=temperature_high, 20=temperature_norm, 10=temperature_low"). The test is against the item defined in the widgets item= tag.

3) Widget dynamic visibility
Widgets can now have a visibility rule applied. By default, a widget is visible, but you can add the rule to make it hidden (eg visibility=[Heating=ON]).
Multiple "rules" can be added, and the "rule" is simply an item name and a state. If any rule returns true, the item will be visible, otherwise it will be hidden. Each rule can use a different item - so you could have "show the temperature control if temperature is below 10 or heating is on" - 
item=temperature_button visibility=[Temperature=10, Heating=ON]. Note that numeric values are tested as >, not as =.
Linked to issue: 118

4) Dynamic URLs (Image/Video)
Widgets with URLs can now have the URL dynamically changed based on an items state. The existing url="address" is retained, and will be the default URL if none of the conditional URLs meet the conditional test. An additional conditional URL array is now defined to account for the dynamic content (eg urlarray=[ON="address-when-on.com", OFF="address-when-off.com"]. The test is against the item defined in the widgets item= tag.
Linked to issue: 310

5) Updated sitemap tag
I've added icon and label to sitemap list
Linked to issue: 328

Ben Jones

unread,
Oct 20, 2013, 3:08:36 PM10/20/13
to ope...@googlegroups.com
Wow - Chris this sounds very very cool. Great work!

Chris Jackson

unread,
Oct 22, 2013, 9:08:31 AM10/22/13
to ope...@googlegroups.com
Attached is the initial version of the updated dynamic sitemap. This should be 100% compatible with all existing sitemaps, but adds the following extra configuration keywords to all widgets -:

labelcolor=[state="color", "state="color"]
iconcolor=[state="color", "state="color"]
valuecolor=[state="color", "state="color"]
These allow setting of the label, the value and the icon colors respectively. For numeric values, the comparison is done as a greater than, so you should list the values in DESCENDING order for it to work correctly.
These can also be set to a static color using iconcolor=["green"].
Colors are passed as written to the REST interface to be processed by the GUI. Generally, this means you can use standard HTML colors (red, green, yellow etc, as well as the #00ff6633 style).
For dates, the value is compared to current time, and the value is in seconds. For example, to make a date go yellow after it is older than 600 seconds, use iconcolor=[600="yellow"]

icon="icon"
icon="state=icon1, state2=icon2"
This sets the icon to a different icon depending on the item state. Note that the format is slightly different to the others as I was having a fight with the xtext parser! I might change this in future


visibility=[item=state, item=state]
This allows changing the visibility of the widget. Here you can specify a list of items and states - if ANY of the conditions are true, the widget will be visible.

For image and video widgets, the following is also possible
urlarray=[state="url, state="url"]
The same rule is applied as for the colors, but this time the URL is changed depending on the value of the item. The existing url="" is still available and it is used as a default if none of the conditions are met.
It is also possible to set the "url" to the value of a stringitem. This should be possible for url statements as it is checked after evaluating the conditional array. For this to work, the check is made against the url to see if it is a stringitem, and a valid item name.

I've given the colors and icons a good test over the past few days, along with the visibility function. In HABDroid, the sitemap updates very quickly after the state is changed and I've found more uses for this than I thought I would :)

A few examples -:
Text item=Outside_RainGauge_LastUpdate valuecolor=[10800="red", 3600="yellow", 0="green"]
This will set the last update indicator to show red if the value is older than 3 hours and yellow if older than 1 hour - green otherwise.

Text item=Outside_RainGauge_Battery  valuecolor=[2.9="green", 2.7="yellow", 2.6="red"]
Similar for battery voltage

Setpoint item=HallThermostat_SetTemp label="Hall Setpoint [%d °C]" minValue=14 maxValue=25 step=1 visibility=[HallThermostat_Enable=ON]
Switch item=HallThermostat_HWEnable label="Hot Water Enable" visibility=[HallThermostat_Enable=ON]
This will only show the hot water enable switch and temperature setpoint if the hall thermostat is ON (since hot water is controlled by this thermostat).

I've also attached a version of HABDroid that supports the colors. It may not be 100% (I've seen some colors being set to the value of the previous widget) so treat it with caution. I don't intend this to be a released version as I hope this will be integrated into HABDroid "properly" at some stage, but it allowed me to test this out over the past few days.

Please consider this a TEST version - usual caveats apply! I haven't tested all features - colours and visibility have had a good workout on my production system over the past few days, but I've only tested the URL/IMAGE processing while I was writing the code since I don't currently use these widgets in my sitemap.

To install, copy the JAR files into your /addons directory, and remove the same JAR file from the /server/plugins directory then restart OH. It would be advisable to keep the original files, but they must be removed from the plugins directory - not just renamed!

If you have any comments, bugs, or suggestions, please let me know. Personally, I find these features make the UI a LOT more usable :)

Cheers
Chris
org.openhab.habdroid-1.3.0-SNAPSHOT.apk
org.openhab.ui-1.4.0-SNAPSHOT.jar
org.openhab.model.sitemap-1.4.0-SNAPSHOT.jar
org.openhab.io.rest-1.4.0-SNAPSHOT.jar

Chris Jackson

unread,
Oct 22, 2013, 10:36:35 AM10/22/13
to ope...@googlegroups.com
It might be worth adding that I've currently only implemented these features in the REST interface - so the classic UI won't be any different.

GreenT also doesn't seem to support the dynamic features, but I know Mihail is looking at implementing these features in GreenT soon.

As per my previous message, HABDroid works out of the box for the visibility features, and the version I attached to this thread also has the color support.

Chris

Victor Belov

unread,
Nov 23, 2013, 5:34:01 PM11/23/13
to ope...@googlegroups.com
Hi,

Chris, I merged your code to support icon/label/value colour into HABDroid. Could you please check that the latest snapshot from CI works as expected with your extensions? :-)

Best regards,
Victor Belov



--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/groups/opt_out.

Chris Jackson

unread,
Nov 23, 2013, 5:42:42 PM11/23/13
to ope...@googlegroups.com

Hi Victor,

That's great - I'll grab it and let you know.

 

Cheers

Chris
 

Chris Jackson

unread,
Nov 23, 2013, 6:31:29 PM11/23/13
to ope...@googlegroups.com

Hi Victor,

First run looks good. I'm still running the "broken" io.rest so it's a bit flakey, but the colors look good. I'll compile up the new sitemap/rest changes tonight and try it properly tomorrow.

 

Many thanks for this.

 

Cheers

Chris

 

Chris Jackson

unread,
Nov 24, 2013, 3:57:51 AM11/24/13
to ope...@googlegroups.com
Hi Victor,
Two comments - firstly the chart servlet has been moved from /chart.png to /chart. Secondly the iconcolor tag has been removed from my original proposal so if you copied that from my changes it should be removed. 

Cheers
Chris


Sent from Samsung Mobile

Chris Jackson

unread,
Nov 24, 2013, 12:11:22 PM11/24/13
to ope...@googlegroups.com
Hi Victor,
Ok, so I've had a bit more of a play, and the colors aren't right somehow. I must admit that I had seen this previously when I made the mods to my test version, but it seems worse now.

I have a page on a sitemap that has a lot of colors in the values. Some of them are ok, but many are either normal (white) or maybe green, but they should be white... I have a number of frames each with 3 text widgets, the first and third widgets have no color associated with them, but the middle one of each group has color. Sometimes the third widget in each group is colored, sometimes none. It seems a bit random.

The output from the REST looks fine as does the Classic UI. I've attached the REST output for the page in XML/JSON - note they might be a little different as they are from slightly different times. I've also attached the output in HABdroid and here you can see for example that "Lounge absolute humidity" is red, but there is no color set for this in the output from the rest interface. I'd seen this a little in the past, and I had a suspicion that in cases where there was no color, HABdroid was sometimes using the previous colour, but I couldn't see how this could happen in the source. However in this case, I don't know where the red has come from.

If there's anything you'd like me to try, please let me know.

Cheers
Chris




02.xml
Screenshot_2013-11-24-16-59-39.png
02.json.txt

Victor Belov

unread,
Nov 25, 2013, 11:27:46 PM11/25/13
to ope...@googlegroups.com

Hi,

A great help would be to create a colored version of demo sitemap which can be used for tests and then be included into demo bundle instead of the current one?

--

Kai Kreuzer

unread,
Nov 26, 2013, 3:18:37 AM11/26/13
to ope...@googlegroups.com
Victor,

Chris has already pimped the demo sitemap, so as soon as I merge it, you will have these new functionality being shown in the demo setup.

Regards,
Kai

Victor Belov

unread,
Nov 26, 2013, 7:01:22 AM11/26/13
to ope...@googlegroups.com
Hi,

Ok, when do you plan to merge? I will wait till then and test again standard demo setup, as I always do then.

Best regards,
Victor Belov

karsten.k...@gmail.com

unread,
Nov 26, 2013, 11:39:49 AM11/26/13
to ope...@googlegroups.com
All,
 
Just one question - will the mapping have as well the possibility to change the color of the text - like:
 
Selection item=Scene_General label="Scene Selection" mappings=[0=off, 1=TV, 2=Dinner, 3=Reading]
 
as I currently have the issue with standard coloring in Internet explorer that the mappings are shown white on white :)
 
Thanks
Karsten

Chris Jackson

unread,
Nov 26, 2013, 6:55:19 PM11/26/13
to ope...@googlegroups.com

As it currently stands, the selection widget only supports the label color - I'll have a look and see if value can be added.

 

Chris
 

-----Original message-----
From: karsten.k...@gmail.com
Sent: Tue 26-11-2013 16:40
Subject: Re: [openhab] Re: Sitemaps: Color and dynamic features to be added....
To: ope...@googlegroups.com;
--

karsten.k...@gmail.com

unread,
Nov 27, 2013, 5:22:10 AM11/27/13
to ope...@googlegroups.com
Hi Chris,
 
I didn't want to have it flexible in color - just visible on ClassicUI in IE or Firefox with standard settings.
 
I tried to check the current CSS but wasn't able to sort where the HTML code is generated.
 
The addition needed would be something like (standard CSS Style definition):
 
<style type="text/css">
a:link { font-weight:bold; color:blue; text-decoration:none; }
a:visited { font-weight:bold; color:silver; text-decoration:none; }
a:focus { font-weight:bold; color:red; text-decoration:underline; }
a:hover { font-weight:bold; color:green; text-decoration:none; }
a:active { font-weight:bold; color:lime; text-decoration:underline; }
</style>
Cheers and thanks
Karsten
 

Chris Jackson

unread,
Nov 27, 2013, 5:44:07 AM11/27/13
to ope...@googlegroups.com

Hi Karsten,

I'm afraid I'm not overly familiar with the classic UI. I can say that the html is specified in the "snippits" folder in org.openhab.ui and then generated dynamically with the renderers. However, I've spent some time trying to work out how to change this and can't find anywhere I can set a style that actually works for the selector widget.

 

Feel free to have a play with the ui, and if you can work out where to set a style that works for the selector then I'd be happy to make it dynamic. Maybe someone with more knowledge on the ClassicUI than me can comment?

 

Chris
 

-----Original message-----
From: karsten.k...@gmail.com
Sent: Wed 27-11-2013 10:22
Subject: Re: [openhab] Re: Sitemaps: Color and dynamic features to be added....
To: ope...@googlegroups.com;
--

Kai Kreuzer

unread,
Nov 28, 2013, 6:51:11 AM11/28/13
to ope...@googlegroups.com

just visible on ClassicUI in IE or Firefox

The Classic UI does not work correctly with those browsers as they are not webkit-based.
This is due to the used UI framework, which is http://trywebapp.net/features.php
I therefore do not recommend trying to fix the UI for IE or Firefox - will be probably hard to do.
I would rather hope for somebody starting the implementation of an HTML5 UI, which could then work on all relevant browsers.

Regards,
Kai

Kai Kreuzer

unread,
Nov 28, 2013, 7:31:15 AM11/28/13
to ope...@googlegroups.com
Just merged it!
So start testing HABDroid against the new features.

Regards,
Kai

Ben Jones

unread,
Mar 22, 2014, 4:41:30 PM3/22/14
to ope...@googlegroups.com
Chris - I finally got around to having a play with this stuff. Should the visibility rules work on String items? I have the following;

Frame label="XBMC" {
Text item=XbmcLiving_State label="State [%s]"
Text item=XbmcLiving_Title label="Title [%s]" visibility=[XbmcLiving_State=Play, XbmcLiving_State=Pause]
Text item=XbmcLiving_ShowTitle label="Show [%s]" visibility=[XbmcLiving_State=Play, XbmcLiving_State=Pause]
Switch item=XbmcLiving_PlayPause label="Play" mappings=[ON="Play"] visibility=[XbmcLiving_State=Pause]
Switch item=XbmcLiving_PlayPause label="Pause" mappings=[ON="Pause"] visibility=[XbmcLiving_State=Play]
Switch item=XbmcLiving_Stop label="Stop" mappings=[ON="Stop"] visibility=[XbmcLiving_State=Play, XbmcLiving_State=Pause]
}

Where XbmcLiving_State is one of 'Play', 'Pause' or 'Stop'. 

When I view the sitemap in either the classic UI or HABDroid I only see the state item, and nothing else, regardless of the state value. 

I have tried these visibility rules with both XbmcLiving_State=Pause and XbmcLiving_State="Pause" - i.e. without/with quotes - but no joy.

Just wondering if this is actually supported, or if it only works for ON/OFF and numerical values?

Cheers,
Ben

Chris Jackson

unread,
Mar 22, 2014, 4:45:24 PM3/22/14
to ope...@googlegroups.com
Hey Ben,
It should work but I think the = should be ==.

ie
XbmcLiving_State==Pause

Let me know if that helps - if not I’ll take a better look.

Cheers
Chris


--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.

Ben Jones

unread,
Mar 22, 2014, 5:02:52 PM3/22/14
to ope...@googlegroups.com
Brilliant - works like a charm!

Daniel Martinez

unread,
Sep 11, 2014, 7:28:11 PM9/11/14
to
Hi, Chris.

I'm playing with this for the color of the battery level text on the sitemap. On the sitemap I'm trying something like:

Text item=BatteryDoor_FF_Living valuecolor=[90="green",50="yellow",20="red"]

and it does nothing, it seems that the values got evaluated with "equal" and no ">", because if I try something like

Text item=BatteryDoor_FF_Living valuecolor=[83="yellow"]

in which 83 is the actual value of the battery, it works.

My item is define as:

Number BatteryDoor_FF_Living "Bateria Ventana [%d %%]" <battery> (gSensors,MainRoom) { zwave="10:command=battery" }

Thanks,

Daniel


Edit: nevermind, I found your answer in https://groups.google.com/forum/#!searchin/openhab/dynamic$20colors/openhab/e8QVxV-nzc0/x1zBJ6O4qrwJ thanks anyway, keep the great work. =D


Chris Jackson

unread,
Sep 12, 2014, 5:23:44 PM9/12/14
to ope...@googlegroups.com
Yes, you are right. I checked the code, and the default is ==. This is also what I wrote in the Wiki, so everything seems OK?

If you want to test for >, then change to >90=“green”, >50=“yellow” etc.

Cheers
Chris

Message has been deleted

Juan Pinto

unread,
Feb 12, 2015, 10:38:35 PM2/12/15
to ope...@googlegroups.com
 Hi It's possible assign an icon based on a string? I want to add an icon based on season returned by astro bindin

Item:
 
String Season_Name      "Season [%s]"                            (Astro) {astro="planet=sun, type=season, property=name"}

Sitemap:
 
Text item=Season_Name icon="Winter==winter,Autumn==autumn,Spring==spring,Summer==summer"

Regards
 

Mark

unread,
Feb 12, 2015, 11:52:22 PM2/12/15
to ope...@googlegroups.com
Have you tried the visibility attribute? In theory, you'd define 4x Sitemap entries using the same Item, each with a different seasonal icon, having the visibility attribute set such that it only appears in the relevant season.

The visibility expression is defined near the bottom of this document:
https://github.com/openhab/openhab/wiki/Explanation-of-Sitemaps

Chris Jackson

unread,
Feb 13, 2015, 2:41:12 AM2/13/15
to ope...@googlegroups.com
Dynamic icons, specified in a similar way to the colours and visbility was something I originally added but I was asked to remove it as Kai wanted to do this a different way. Now that this isn't being done on OH1, maybe it's something that could be merged now (although we'd need to find the removed code - it'll be in the repository "somewhere").

Chris

Juan Pinto

unread,
Feb 17, 2015, 3:46:10 PM2/17/15
to ope...@googlegroups.com
I've done with this option, ty Mark! :P
 
Chris, if possible recover the code would be great !
 
Regards

Chris Jackson

unread,
Feb 18, 2015, 12:19:04 PM2/18/15
to ope...@googlegroups.com
The original code (or PR at least) is here -:

This should have all the old commits if they haven’t been deleted (I’m not sure how long it’s retained) and it should therefore be possible to extract it and present them again if people are interested…

Chris

Amy Pearson

unread,
Feb 23, 2015, 10:56:54 AM2/23/15
to ope...@googlegroups.com
On Sunday, October 20, 2013 at 8:18:07 AM UTC-4, Chris Jackson wrote:
2) Dynamic Icons
Similar to colors, icons can now be changed dynamically. The existing static icon can still be used (eg icon="temperature"), but you can now add a dynamic array of icons (eg icon="30=temperature_high, 20=temperature_norm, 10=temperature_low"). The test is against the item defined in the widgets item= tag.

Trying to get this to work:

Text item=Battery_Charge valuecolor=[Battery_Charge>80="green",>80="yellow",>70="orange",>60="red"] icon=[Battery_Charge>80="battery-100",>80="battery-80",>70="battery-60",>60="battery-40"]
Text item=Battery_Voltage valuecolor=[Battery_Charge>80="green",>80="yellow",>70="orange",>60="red"]  icon=[Battery_Charge>80="battery-100",>80="battery-80",>70="battery-60",>60="battery-40"]

The valuecolor works, but I can't get the icon part to work.

-Amy

Chris Jackson

unread,
Feb 23, 2015, 11:58:50 AM2/23/15
to ope...@googlegroups.com
>
> The valuecolor works, but I can't get the icon part to work.

No - that’s what I said earlier. I was asked to remove the icon part as it wasn’t something Kai wanted at the time as he had another idea. As this other idea wasn’t implemented, and we’re on to OH2, if someone wanted to pick up the icon mods again for OH1, it should be possible to cherry pick it out of my repo…

Chris

Amy Pearson

unread,
Feb 23, 2015, 7:45:27 PM2/23/15
to ope...@googlegroups.com


On Monday, February 23, 2015 at 11:58:50 AM UTC-5, Chris Jackson wrote:

> The valuecolor works, but I can't get the icon part to work.

No - that’s what I said earlier. I was asked to remove the icon part as it wasn’t something Kai wanted at the time as he had another idea. As this other idea wasn’t implemented, and we’re on to OH2, if someone wanted to pick up the icon mods again for OH1, it should be possible to cherry pick it out of my repo…

That is a bit beyond me, is this something I will be able to do in OH2?

-Amy

Chris Jackson

unread,
Feb 24, 2015, 3:01:08 AM2/24/15
to ope...@googlegroups.com
Yes - I'm sure there will be a mechanism for doing this in OH2. I've not looked that closely yet, but I think Kai has implemented his idea that he had originally for this in OH2.

Chris

Frode Fuglestad

unread,
Jul 14, 2015, 3:48:43 AM7/14/15
to ope...@googlegroups.com
Hey,

So for now, we need to write a rule against items to accomplish dynamic icons in OH1?

Any examples for this approach?

Thanks

Frode

Rich Koshak

unread,
Jul 14, 2015, 4:45:55 PM7/14/15
to ope...@googlegroups.com
I've accomplished this using the visibility option in the sitemap.

For example, I have two items, one is a switch that controls my garage and the other is a contact sensor which tells me if the garage is open or closed. Then I have two entries in my sitemap for the garage door. One with the garage closed icon which is visible when the contact is CLOSED and invisible otherwise and the other with the garage open icon which is visible when the contact is OPEN.

Items:

Switch    T_D_Garage1         "Garage Door 1 Opener"
Contact   N_D_GarageDoor1  "Garage Door 1 Sensor"


Sitemap

Switch item=T_D_Garage1 label="Garage Door 1" icon="garagedoor-closed" mapping=[ON=Open] visibility=[N_D_GarageDoor1!="OPEN"]
Switch item=T_D_Garage1 label="Garage Door 1" icon="garagedoor-open" mapping=[ON=Close] visibility=[N_D_GarageDoor1=="OPEN"]

One disadvantage I've seen with this approach though is that the sitemap doesn't always immediately update itself on the Android client.

Rich

Nathan Stratton

unread,
Jul 14, 2015, 4:56:29 PM7/14/15
to ope...@googlegroups.com
Really would be nice if you could merge items.......


><>
nathan stratton | vp technology | broadsoft, inc | +1-240-404-6580 | www.broadsoft.com

--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
Reply all
Reply to author
Forward
0 new messages