This post is modified to include these enhancements:
- no restriction any more about the charting period (the charting has been enhanced) (Aug 04)
- intchart.rules has been made platform independent (to be confirmed on linux) (Jun 17)
- the url pattern has changed and it is now possible to access data file through the web (Jun 17)
Hi,
In a previous post I described a new charting solution offered by intchart.
I must admit that the installation procedure was rather complicated.
That’s why below you can find a simplified procedure.
The solution now offers more flexibility :
It can be used alongside all other functionalities in OH (also webviews).
And multiple charts can be drawn, even on the same page.
To have an idea of what the charts looks like, have a look at www.intchart.com.
The charting solution is proposed for OH 1.8.x. , a solution for 2.0 is being looked at.
These are the installation steps.
1. Install the files
The files needed can be found in this zip file :
-
intchart.rules
To be installed in :...\openhab\configurations\rules
-
org.openhab.ui.webapp_1.8.x.jar
To be installed in :...\openhab\server\plugins
All you need for the logging is included in this one rule file (intchart.rules).
In the jar, the only file changed is : snippets\main.html
:
- An EventListener ‘beginslide’ is added.
- In the EventListener ‘endslide’ a block is added.
(For now, the webpage including the chart is not refreshed.)
2. Customize the logging rules
In intchart.rules, at the bottom, the following block can be customized.
rule "Logging" // enter unique rule name
when
Time cron "0/10 * * * * ?" // every 10 seconds
//Time cron "0 0/10 * * * ?" // every 10 minutes
then
var fileName = 'data.txt' // enter unique file name
var itemList = newArrayList(Weather_Temperature,Weather_Humidity) // enter items to log
var nameList = newArrayList('Temperature','Humidity') // enter legend names
var round = 1 // enter value decimals
count = new Integer((intchart_log.apply(fileName,itemList,nameList,round,count)).toString) // function (not to be changed)
end
In this block you should give
-
A unique rule name
-
The logging period
-
The four variables indicated
As example the items temperature and humidity from the demo are used.
For every chart you need, you should duplicate this logging block.
3. Include frame in Sitemap
In the sitemap, include the following frame:
Frame {
Webview url="https://www.intchart.com/api/open_HAB/chart?file=data/data.txt&width=1200"
}
This link will create the charts.
The following parameters can be defined:
-
Userid : as default user id open_HAB is used.
If you prefer you can use you own API user id, which you can get here (if you are registered):
https://www.intchart.com/account/api_key -
File name : as default data.txt is used
This name should be the same as defined in the rules -
The path is set to data, which should not be changed
-
Many other parameters can be added to customize your chart.
To have the full list, have a look here:
IntChart - API to access or feed your online charts - page chart_url_composer
For every chart, of course, you need a new link.
So, this is, I think, a much more simplified procedure.
If you have any problems with this installation, do not hesitate to contact me.
All other feedback is also welcome.