Sitemap files - Use of variables

491 views
Skip to first unread message

Max Stephan

unread,
Nov 13, 2013, 9:26:05 AM11/13/13
to ope...@googlegroups.com
Hi,

I am using some charts in my configuration and want to make the period configurable based on a selection widget. For this I have the following in my items file:

String EnergyChartPeriod "[%s]"

And in my sitemap file:

Frame label="Energie" {
Text item=TotalEnergyMeter
Text item=CurrentEnergyMeter
Chart item=gEnergy period=EnergyChartPeriod refresh=99999
Group item=gPower
Text item=TotalGasMeter
Text item=CurrentGasMeter
Chart item=CurrentGasMeter period=EnergyChartPeriod refresh=99999
Selection item=EnergyChartPeriod label="Chart period selection" mappings=[h="h", 4h="4h", 8h="8h", 12h="12h", d="D"]
Text item=EnergyChartPeriod
}

The selection item works fine, I can select between the different choices and ChartView also gets assigned the expected value (visible in the last text item for debugging). But the period in the chart items do not reflect my selection, instead only the default day view is shown. Thus I think the "period=ChartPeriod" statement is wrong, but I could not find anywhere how to do this.

Is that supposed to work at all and if yes how ?

Thx,
Max

Chris Jackson

unread,
Nov 13, 2013, 10:03:46 AM11/13/13
to ope...@googlegroups.com

If I remember correctly, the period is not parsed to see if it's an item and then used accordingly, so no, it won't work as you want.

 

There's currently a number of sitemap additions in the pipeline for review (pull request 57). This will allow different charts based on an items value as it adds dynamic visibility. So, you can say "if EnergyChartPeriod=10, show chart 1; if period = 20, show chart 2" type of thing. This works well on my modified version of HABDroid.

 

Kai expects to get on to the review of this quite soon, so hopefully we'll have this in the next week or two (depending on how many changes I need to make).

 

Cheers

Chris

 

Max Stephan

unread,
Nov 13, 2013, 10:34:20 AM11/13/13
to ope...@googlegroups.com
Thx Chris - I understand this is also valid for item type image ? Otherwise I might build a dynamic URL for rrdchart.png and use image instead of chart...

Chris Jackson

unread,
Nov 13, 2013, 10:44:39 AM11/13/13
to ope...@googlegroups.com

Yes - dynamic visibility is added to all widgets.

 

However, I also added a image=item type definition, so you can get an image filename directly from a string item. I had some security concerns about this which I raised for review, so we'll see how that pans out :)

 

Will Stewart

unread,
Nov 14, 2013, 7:07:19 PM11/14/13
to ope...@googlegroups.com
Where can we find documentation on how to declare and use item variables such as the above? 

Chris Jackson

unread,
Nov 15, 2013, 4:07:03 AM11/15/13
to ope...@googlegroups.com
This functionality isn't available in the master repository yet - the pull request is currently undergoing review. You can find the pull request here (https://github.com/openhab/openhab/pull/57) which contains some details, or do a search in the forum (use "dynamic sitemap" and that will come up with my original post from a few weeks back. This explains the changes.

Kai is currently reviewing the request but I'm expecting to have to make some changes so I would like to think that in the next week or two it will be available.

Chris
Reply all
Reply to author
Forward
0 new messages