Page 1 of 3

graph and trends...

Posted: Sat Aug 21, 2004 7:19 pm
by wallebalboa
i would like to do a plot/graph of the change of a property over time (for example the last 24 hours outside temperature).



any plugins or plans for a control like this.. (or have i lost that page in the manual :oops: ...)



i could see two different aproaches to this:

realtime - just plot the change locally in the software remote.

historical - retreve historical data from central DB.



pls advice if any job done or planned development of this.

regs

Posted: Sun Aug 22, 2004 2:16 am
by Circe640
HouseBot does not have a historical database. No values are archived. However, if there is interest, once the vbWrapper for Meedio HouseBot is available, I might be persuaded to put together a little generic plugin that would save data and create a historical DB for properties. Any interest??

Posted: Sun Aug 22, 2004 4:09 am
by maze42
Yea, I am very interested!!! especially if you could save data to a database.

That way I could do all kinds of (offline) analyses with external programs or HB e.g max/min temp last 24 h, last week, accumulated rain etc.

Posted: Sun Aug 22, 2004 1:04 pm
by ScottBot
If you just wanted to log the property changes, you could do this now. However, if you wanted to show a nice graph of the data on a Software Remote, that's a bit more difficult.



To store Property Value changes to a log file:
  • Create a new Log file [File / New / Log...].
  • Specify the output to a file and give it a name.
  • Navigate to the Property to log in the tree view.
  • Select the Log changes to User Log checkbox and select the log that you just created.
A more involved solution that would allow you to customize the format of the data or even save to a DB would be to:
  • Create a Task that has a condition that will cause it to execute whenever the Property Value has changed.
  • Have an action in the Task to execute a Script Device.
  • The Script Device can pull the current value of the property and do whatever it wants with it. It can save it to a DB or write it to a file.
If you're interested in more info on either of these solutions, let me know.

graph on remote...

Posted: Wed Aug 25, 2004 12:53 pm
by wallebalboa
I see the log part... do you have any hint on ´how to get it on the screen of a remote?



tnx

Re: graph on remote...

Posted: Wed Aug 25, 2004 1:24 pm
by ScottBot
do you have any hint on ´how to get it on the screen of a remote?
The only way you can get it on the screen is to use a dynamic image on the Theme.



The trick is how to create the image/graph from the data. I though that I could find some simple freeware app that takes a data file as input and will generate a JPEG or BMP file as output. However, nothing surfaced in my quick search. If you could find such a program, then you can run it after new data is collected and update the image.

Posted: Wed Aug 25, 2004 3:42 pm
by Automate
One option would be to use RRDTool http://people.ee.ethz.ch/~oetiker/webto ... index.html

It is a very well supported open source database specifically designed for logging time series data. It is often used by Linux users but they also have a pre-compiled Windows version.

You can check out all the clients written for it here http://people.ee.ethz.ch/~oetiker/webto ... /rrdworld/



It probably would not be very hard to write a script that generated a image file on a timed bases for HouseBot to use.

Posted: Wed Aug 25, 2004 4:20 pm
by ScottBot
Also, if you have Excel on the machine, you could probably use some VBA scripting to have it generate a chart and then save the chart to a JPEG file. I'd imagine that it could all be automated, but it would take a little work to get it all working.

Posted: Sun Sep 17, 2006 7:13 pm
by loo_hoo_ser
Hi all -

I thought I'd chime in and add to this dusty thread. I found what I think is a perfect companion to Housebot for plotting data trends. It is "gnuplot" and you can find it here:

http://www.gnuplot.info/

It is freeware and it has a GUI and a command line interface. The GUI is perfect for testing and debugging the plot files. Once the plot files are good to go, Housebot will happily execute the command line version and you can load the resulting plots into Housebot as PNG images (dynamic images). It does all kinds of plots, 3-D plots, polar, etc. It will also let you specify the output image sizes and will even rotate text along the bottom axis by 90 degrees! It's a plotter's wet dream come true.

A couple of Caveats:

1) gnuplot is kinda hard to use - once you've practiced using the sample plot files and reading the manual (over and over), it will come together. The hardest part for me was trying to get my date and time formats to be read in from a file. It was kinda tricky.

2) gnuplot claims to support "GIF" but not really, they're really PNG images with a "GIF" extension. Very misleading - fortunately, HB understands PNG just fine - just make sure you use the "PNG" extension when specifying the output filename.

3) I had to use a custom VB script to create the plot files. Housebot's logging didn't cut it for me because it added too much data. For example, I wanted to plot a temperature trend, but the log file saves it as "Temperature Property Has Changed to [30]" or something like that (along with a time and date - still useful). gnuplot doesn't understand that format very well, it wants a file with numbers pretty much. I'm sure with enough blood and sweat, gnuplot can be configured to understand Housebot log data files directly. However, in order to put multiple plots onto one plot, the data still has to be in one file (I think). For Housebot to put multiple property values into a single log file would require some kind of composite property value to be created and then decomposed later by gnuplot. Too much work!!

So, my VB script, which was invoked at regular intervals, would append to a temperature log file containing the date, time, temperature, a high temperature, and a low temperature (I've got another script that keeps track of that stuff). Anyway, it works very well. I'm still testing it out and not sure how well the dynamic image is loading - I've had to use a trick that I found elsewhere in this forum to have a task wake up and refresh the filename of the dynamic image property to force it to update to all the SWRemotes.

Gnuplot, background set-up

Posted: Tue Oct 03, 2006 7:02 am
by dozinjp
GNUPLOT is really very adapted for the generation of dynamic graph integrated into "remotes", I did not find the option allowing to change the background of my graphs.
Could anybody say to me if it is possible, and with which command?
Thank you in advance.

Ethan.

Posted: Tue Oct 03, 2006 9:06 pm
by loo_hoo_ser
I use the GIF (really, PNG) format for my plots that are to be displayed in my SW remotes and you can specify a transparent background so that the background in the SW remote can be seen (and its color). If you look in the gnuplot documentaiton, there are qualifiers to use for the GIF format (size, colors, background etc).

My plot file contains this directive:

Code: Select all

set terminal gif transparent small size 220,180
Which gives me a small GIF image with a transparent background and is 220x180 pixels in size (height x width)

Gnuplot, background set-up

Posted: Wed Oct 04, 2006 4:47 am
by dozinjp
Perfect, it works perfectly.
Thank you for your help.

Posted: Wed Oct 11, 2006 2:14 pm
by wallebalboa
hello guys . great to see activity in this tread. Your way looks as the best solution so far to the trending/plotting issue. Could you elaborate a bit more about your solution and maybe post some examples.
I have about 20 different temperature properties that i would like to plot on my swremotes.
Do you do a log file per day,week or year? whats your samplerate? do you log changes or at a fixed samplerate?
regs

Posted: Sun Oct 15, 2006 7:47 pm
by loo_hoo_ser
Hi -

Sorry for the late reply.

My log file is actually created by a custom VB script. I have a USB Templinc which I wrote a VB script to query and process its temperature data. Because I'm a nerd, I have the script tracking the highest and lowest temperature recorded for the last three days (actually it can be any number of days, I just have it set to three).

After it takes the reading, the last thing the script does is write the date and time and temperature to a file along with the current highest and lowest temperature. When I plot this, I get a temperature swing between the high and low plots (they appear as stairstep lines when the high and lows change over time). Like I said earlier, HB's built in logging capabilities doesn't meet my needs, it adds too much data for gnuplot to use. I found it quite easy to write a VB script to open/append a file, write the data, and close it.

As for my logging rate (also the sampling rate), I update it once every 7 minutes. Why 7? I figured having an odd number would keep it from interfering with any other tasks that might be running at even intervals (like every 5 minutes, every hour, or half hour).

The only thing I haven't solved yet is how to prune my temperature log file that gnuplot uses to plot the data from. I just haven't gotten around to it. What I'd like to do is to prune the oldest data and add the new data so the plot looks like it's moving from right to left as time progresses.

I suppose I could make it work by logging only changes which would definitely be more efficient - why write data if its unchanged. I would think that gnuplot would not produce pretty plots if there were huge gaps in times where the temperature remained unchanged. Hmm. Have to try that. Could work.

Re: graph and trends...

Posted: Tue Mar 09, 2010 9:33 am
by raptor_demon
Hi,

Could you guys share the logging script? i am looking to set this up but i am not very good at scripting.

Thanks

Raptor