Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

ClimateDataCalculation

Questions and comments specific to a particular plugin should go here.
Post Reply
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: ClimateDataCalculation

Post by Mastiff »

I think I'm getting there. I have found a page of javascript that does something quite similar, maybe you can learn something from it? It seems that category doesn't come into it when it's an date time setup. So if you look at this:

Code: Select all

<!DOCTYPE html>
<!-- source: http://jsbin.com/ehebut/1 -->
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id="container" style="height: 300px"></div>  
<script id="jsbin-javascript">
var temp = [0.8446, 0.8445, 0.8444, 0.8451,    0.8418, 0.8264,    0.8258, 0.8232,    0.8233, 0.8258,
                    0.8283, 0.8278, 0.8256, 0.8292,    0.8239, 0.8239,    0.8245, 0.8265,    0.8261, 0.8269,
                    0.8273, 0.8244, 0.8244, 0.8172,    0.8139, 0.8146,    0.8164, 0.82,    0.8269, 0.8269,
                    0.8269, 0.8258, 0.8247, 0.8286,    0.8289, 0.8316,    0.832, 0.8333,    0.8352, 0.8357,
                    0.8355, 0.8354, 0.8403, 0.8403,    0.8406, 0.8403,    0.8396, 0.8418,    0.8409, 0.8384,
                    0.8386, 0.8372, 0.839, 0.84, 0.8389, 0.84, 0.8423, 0.8423, 0.8435, 0.8422,
                    0.838, 0.8373, 0.8316, 0.8303,    0.8303, 0.8302,    0.8369, 0.84, 0.8385, 0.84,
                    0.8401, 0.8402, 0.8381, 0.8351,    0.8314, 0.8273,    0.8213, 0.8207,    0.8207, 0.8215,
                    0.8242, 0.8273, 0.8301, 0.8346,    0.8312, 0.8312,    0.8312, 0.8306,    0.8327, 0.8282,
                    0.824, 0.8255, 0.8256, 0.8273, 0.8209, 0.8151, 0.8149, 0.8213, 0.8273, 0.8273,
                    0.8261, 0.8252, 0.824, 0.8262, 0.8258, 0.8261, 0.826, 0.8199, 0.8153, 0.8097,
                    0.8101, 0.8119, 0.8107, 0.8105,    0.8084, 0.8069,    0.8047, 0.8023,    0.7965, 0.7919,
                    0.7921, 0.7922, 0.7934, 0.7918,    0.7915, 0.787, 0.7861, 0.7861, 0.7853, 0.7867,
                    0.7827, 0.7834, 0.7766, 0.7751, 0.7739, 0.7767, 0.7802, 0.7788, 0.7828, 0.7816,
                    0.7829, 0.783, 0.7829, 0.7781, 0.7811, 0.7831, 0.7826, 0.7855, 0.7855, 0.7845,
                    0.7798, 0.7777, 0.7822, 0.7785, 0.7744, 0.7743, 0.7726, 0.7766, 0.7806, 0.785,
                    0.7907, 0.7912, 0.7913, 0.7931, 0.7952, 0.7951, 0.7928, 0.791, 0.7913, 0.7912,
                    0.7941, 0.7953, 0.7921, 0.7919, 0.7968, 0.7999, 0.7999, 0.7974, 0.7942, 0.796,
                    0.7969, 0.7862, 0.7821, 0.7821, 0.7821, 0.7811, 0.7833, 0.7849, 0.7819, 0.7809,
                    0.7809, 0.7827, 0.7848, 0.785, 0.7873, 0.7894, 0.7907, 0.7909, 0.7947, 0.7987,
                    0.799, 0.7927, 0.79, 0.7878, 0.7878, 0.7907, 0.7922, 0.7937, 0.786, 0.787,
                    0.7838, 0.7838, 0.7837, 0.7836, 0.7806, 0.7825, 0.7798, 0.777, 0.777, 0.7772,
                    0.7793, 0.7788, 0.7785, 0.7832, 0.7865, 0.7865, 0.7853, 0.7847, 0.7809, 0.778,
                    0.7799, 0.78, 0.7801, 0.7765, 0.7785, 0.7811, 0.782, 0.7835, 0.7845, 0.7844,
                    0.782, 0.7811, 0.7795, 0.7794, 0.7806, 0.7794, 0.7794, 0.7778, 0.7793, 0.7808,
                    0.7824, 0.787, 0.7894, 0.7893, 0.7882, 0.7871, 0.7882, 0.7871, 0.7878, 0.79,
                    0.7901, 0.7898, 0.7879, 0.7886, 0.7858, 0.7814, 0.7825, 0.7826, 0.7826, 0.786,
                    0.7878, 0.7868, 0.7883, 0.7893, 0.7892, 0.7876, 0.785, 0.787, 0.7873, 0.7901];
    
    
$(function () {
    var chart;
    $(document).ready(function() {
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                type: 'spline'
            },
            title: {
                text: 'Temperature Today'
            },
            xAxis: {
                type: "datetime",                
                dateTimeLabelFormats: {
                    day: '%H'
                },
                tickInterval: 3600 * 1000
            },
            yAxis: {
                title: {
                    text: 'Temperature'
                },
                minorGridLineWidth: 0,
                gridLineWidth: 0,
                alternateGridColor: null
            },
            plotOptions: {
                spline: {
                    lineWidth: 4,
                    states: {
                        hover: {
                            lineWidth: 5
                        }
                    },
                    marker: {
                        enabled: false,
                        states: {
                            hover: {
                                enabled: true,
                                symbol: 'circle',
                                radius: 5,
                                lineWidth: 1
                            }
                        }
                    }
                }
            },
            series: [{
                pointInterval: 60 * 1000,
                pointStart: Date.UTC(2006, 0, 1),
                name: 'Asen',
                data: temp 
            }],
            navigation: {
                menuItemStyle: {
                    fontSize: '6px'
                }
            }
        });
    });

});
</script>
</body>
</html>
You can see that this shows a bunch of temperatures for a day with hourly intervals. Does it tell you anything more about how this should actually be? The tick interval seems to be milliseconds on a date time axis, but I habe a problem understanding that.
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: ClimateDataCalculation

Post by Mastiff »

When using it with your code I only get the first 00, and nothing else afterwords. I can't really understand why, but maybe that's some formatting issue?
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: ClimateDataCalculation

Post by Mastiff »

Btw I found this that made it a bit better to have x axis values with less clutter:

Code: Select all

	labels: {
            style: {
                fontFamily: 'Tahoma'
            },
            rotation: -45
        },
Put on the line after xAxi: { this will make the values stand in an angle of 45 degrees, so the need for different levels with values is gone.
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: ClimateDataCalculation

Post by krambriw »

I have found a page of javascript that does something quite similar
Thanks, I think this is a very nice example, it solves the problems I think. I will look into how this type can be generated instead
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: ClimateDataCalculation

Post by Mastiff »

Brilliant, thanks! :) I'm not any good with coding, but my google fu is pretty good! :mrgreen:
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: ClimateDataCalculation

Post by krambriw »

I have made a new version now. I think it is getting better, now the x-axis is looking reasonable and scales correctly when you zoom in.

I had some issues to solve and I try to describe them here:

- due to the new x-axis method, I am assuming a data tick every minute
- if one or more data point readings are missing, I am filling out the gap (in most cases with last known value, except for rain where I assume no additional rainfall)
- currently I am only able to cover a gap of maximum one hour...
- if you combine several data sources with gaps in various places, the graph will try to make a 'best possible fit'

In my tests it looks ok what I have seen
Skärmklipp.PNG
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: ClimateDataCalculation

Post by Mastiff »

It looks very nice, unfortunately I get errors of different types with only the create combo updated and the init updated too. This is on startup with the init updated:

Code: Select all

12:34:26      Error in Action: "ClimateDataCalculation: CombinedReport: (u'Badet', u'Stua', u'Yttergangen')"
12:34:26      Traceback (most recent call last) (1691):
12:34:26        File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
12:34:26          return self(*args)
12:34:26        File "C:\Program Files (x86)\EventGhost\plugins\ClimaDataCalculation\__init__.py", line 1625, in __call__
12:34:26          4
12:34:26      TypeError: CreateComboHtml() takes exactly 18 arguments (12 given)
Is that because I have to delete all databases and start all over again on the capture? I was expecting that, I just don't want to delete them before I know that's the thing. :wink:

Edit: After a bit of thinking I want to revise the first sentence: It looks dam close to perfect! :mrgreen:
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: ClimateDataCalculation

Post by krambriw »

:D

Your databases should be ok

I think it is enough that you open/re-save the configuration of your action for the CombinedReport (in worst case you will have to re-create it)

And one more I did forget: You can now edit the CreateComboHtml.py without need to restart EG, it is reloaded when you run it

Best regards, Walter
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: ClimateDataCalculation

Post by Mastiff »

Well, I'm a step ahead of you! :mrgreen: That was with a new combined report. But I did another restart of EG now, and this time I had no errors on startup. And then, when I created another new report it finally worked. And I'm satisfied! :mrgreen: This is exactly what I was looking for:

Image

So thank you very much for not giving up with all my nagging, we have arrived at what I needed and wanted! Next step is to put that into my smarthouse system as well as the cabin!
Attachments
Combined chart.jpg
Last edited by Mastiff on Wed Apr 08, 2015 12:15 pm, edited 2 times in total.
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: ClimateDataCalculation

Post by Mastiff »

Oh, in case you wonder: That "yttergangen", "entrance hall" or whatever you may call it in English (but you know what I mean, I think), is doubling as a washing room with a washer and dryer. So those spikes are not anomalies, they are simply when I have been running the dryer! Even if it's a new one with a heat pump system, it does make it pretty warm out there... :D
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: ClimateDataCalculation

Post by krambriw »

:D :D :D

It looks great !!!

For me was also valuable to use HighCharts in combination with python and an sql database, everyday you learn something new

BR
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: ClimateDataCalculation

Post by Mastiff »

I agree! Very nice! A couple of thing are kind of strange: It takes around 30 seconds to get from I see the heading "EventGhost Climate Data Report Graph" and to the graph actually is there. Is that something that happens between my pc and Highcharts' system, so it's the slow upstream connction from the cabin that's causing that?

And on the combined report I have three curves, as you can see. But I have not shown what's below the graph: Two empty spaces with only the selected period showing, no graph. Is that something on my system, or can it be a bug?
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: ClimateDataCalculation

Post by krambriw »

The performance will be depending on network bandwith.

If you would copy the report to a local HighCharts folder you would get a fast response. Another idea could be to use Google Drive (or another cloud service where you also put the HighCharts folder) as your report export path for your remote cabin server. Then you point a local webserver at home to the same cloud service path and use this for viewing reports (I have just configured this setup and it works really good for me)
But I have not shown what's below the graph
What are you missing? The name of the report?
Last edited by krambriw on Thu Apr 09, 2015 6:17 am, edited 1 time in total.
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: ClimateDataCalculation

Post by Mastiff »

I can try that Google Drive thing, I haven't really used it even if I have one. Maybe it can work. Thanks for that tip! Anyway, it wasn't what I was missing, but what I had extra. I have "ghost charts" with only the heading and no chart, and there should be no chart there. It actually seems to me that even if the three curves are collected in one chart something in the system thinks there should be three separate charts and makes three headings. Like in this attached screenshot:

Image
Attachments
Ghostcharts.jpg
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: ClimateDataCalculation

Post by krambriw »

See my corrected response above
Post Reply