how to extend the week.json, that it collect data of 30 days?

86 views
Skip to first unread message

Astrid

unread,
Nov 21, 2021, 8:40:26 AM11/21/21
to weewx-user
Hello!

How can I change the configuration of weewx (v 4.5.1) that
in the file week.json the data of 30 days will be collected?

Thanx.

Regards, Astrid

gjr80

unread,
Nov 21, 2021, 2:46:48 PM11/21/21
to weewx-user
Impossible to say without knowing how you are generating week.json; is this a report you have written or an extension you have installed? Either way we need some details.

Gary

Astrid

unread,
Nov 22, 2021, 1:37:48 AM11/22/21
to weewx-user
Hello!

Sorry, I forgot to write, that I mean week.json, which  is from your
pretty highcharts.

Regards, Astrid

gjr80

unread,
Nov 23, 2021, 12:45:08 AM11/23/21
to weewx-user
So you mean the weewx-highcharts extension? If so that extension was never designed to provide non-aggregate monthly data files. This was for a couple of reasons. Firstly file size, a week of non-aggregated observations results in a data file of around 700kB, a month would blow this out to around 3MB. Secondly, and probably more important, was the generation time. At the time of writing and on the hardware (RPi) I had at the time the generation time was quite long compared to my five minute archive period. Consequently I chose to implement a week json data file with non-aggregate data and a year json data file that held daily max/min/sum (as appropriate) and the search list extensions involved are hard coded accordingly.

That being said RPs are now more powerful so a monthly non-aggregate data file may be usable. You would need to edit the HighchartsWeek() search list extension source code in user/highchartssearchlist.py, around line 378 change:

_start_dt = _ts_dt - datetime.timedelta(days=7)

to:

_start_dt = _ts_dt - datetime.timedelta(days=30)

Not essential but you might also want to change the name of the template in skins/Highcharts/json from week.json.tmpl to month.json.tmpl or something else to avoid confusion. I believe there is no need to change the content.

That gets you a month json data file but then you need Highcharts to render the data. The javascript file plot.js may need some changes. Certainly if you change the json data file name from week.json you will need to change all occurrences of week.json in plot.js (perhaps this is cause enough to leave the json data file name as week.json). I think Highcharts will automatically set the plot scales etc but maybe not. I had a quick look at plot.js and saw no other obvious issues.

I'm sorry but I don't have the time just now to be able to rewrite the extension for you.

Astrid

unread,
Nov 23, 2021, 9:13:24 AM11/23/21
to weewx-user
Hello!

Thanx. It works. :)
Without any further change at x-axis and so on in plots.js.
I will take a look, to time behaviour. If not, I will change back to 7.
And I will take a look to your weewx-averages too.

Regards, Astrid

Reply all
Reply to author
Forward
0 new messages