Using weewx-vitalstats & graphing data from data-services

46 views
Skip to first unread message

michael

unread,
Apr 27, 2021, 5:51:55 AM4/27/21
to weewx-user
Hi all,

I've seen a wealth of information about customizing weewx, but something still hasn't clicked. 

Using this service as an example: https://github.com/g-eddy/weewx-vitalstats. How can I get the data from that into something graphable by the Belchertown skin? Is it necessary to add a database column if I want these graphed over time? Can they be shown as current values somehow without needing to store them? (and then I presume I would not be able to graph them)

Adding the graph like this results in a error "weewx.UnknownType: cpu_temp"

    [[chart3]]
        title = CPU Temp
        type = spline
        [[[cpu_temp]]]

I've created my own services for a couple of raspberry pi sensors, but I just store info in database names that already exist eg "event.packet['pressure'] = 0.02953 * float(pressure)" and the data is then easily used in a Belchertown graph..

Hoping someone can point me in the right direction on this.

Thanks!


Graham Eddy

unread,
Apr 27, 2021, 7:15:25 AM4/27/21
to weewx...@googlegroups.com
Using this service as an example: https://github.com/g-eddy/weewx-vitalstats. How can I get the data from that into something graphable by the Belchertown skin?

you will be creating new data_types(s). i don’t know belchertown; use its method to add new items to template files

Is it necessary to add a database column if I want these graphed over time?

yes, that is how weewx works: graphed over time → stored as column in database

Can they be shown as current values somehow without needing to store them? (and then I presume I would not be able to graph them)

again yes. $current refers to the current (archive) data packet, just as it is being put into the database (that is, the data_types in the packet that have columns get stored). if you put $current.outTemp in a template, that is taking from the packet, no column required

Adding the graph like this results in a error "weewx.UnknownType: cpu_temp”

this is a new data_type so weewx as yet knows nothing about it. creating a column for it only persists it in database, it doesn’t tell weewx what it is (e.g. what units does it use)

I've created my own services for a couple of raspberry pi sensors, but I just store info in database names that already exist eg "event.packet['pressure'] = 0.02953 * float(pressure)" and the data is then easily used in a Belchertown graph..

quite valid thing to do - you are hijacking weewx’s knowledge of existing data_types to use for your own variables

the Customisation Manual goes into this in great detail; you will get your answer there.
a partial answer is to say you need to add a definition to your bin/user/extensions.py, such as
weewx.units.obs_group_dict['cpu_temp'] = 'group_temperature'
which tells weewx that ‘cpu_temp’ is a temperature thingy so degree_C and degree_F are the kind of units to use for it

michael

unread,
Apr 28, 2021, 2:53:58 AM4/28/21
to weewx-user
An answer right from the source! Thanks for sharing your work.

Ok so my understanding wasn't too far off, albeit a little murky. I can read the from $current no problem, and then following the guide to add "electricity" in the customization guide, I added the database column "cpu_temp" and "cpu_load" -- data is stored in it with no further changes. Your code already has the requisite obs_units added. In order to graph meaningful results I had to add "count = %.2f" to [[[[StringFormats]]]] in weewx.conf - now it works great.

My Belchertown skin graph config looks like this, for anyone interested

[[cpu]]
    title = CPU
    [[[cpu_temp]]]
        zIndex = 2
        name = CPU Temperature
        color = red
    [[[cpu_load]]]
        name = CPU Load
        yAxis = 1

Thanks again for your work, and the clarification!

Reply all
Reply to author
Forward
0 new messages