Highchart Air Quality

503 views
Skip to first unread message

purc...@maladomini.com

unread,
Jul 1, 2021, 8:01:23 AM7/1/21
to weewx...@googlegroups.com

I am using Weewx with the Belchertwon skin and I have an Ecowitt PM2_5 sensor to read air particulates. Does anyone know of a graph we can add to the charts.conf to convert the PM2_5 reading to an actual Air Quality reading?

 

I have found a lot of sites that allow me to convert the reading on their site. But I was hoping someone had made a high chart graph for the Belchertown skin I could add that would give me an Air Quality reading people could see.

 

A chart that does this with the data in the weewx database.

 

https://www.airnow.gov/aqi/aqi-calculator/

 

Thanks!

steeple ian

unread,
Jul 1, 2021, 3:02:42 PM7/1/21
to weewx...@googlegroups.com
weewx-aqi. You will find it on GitHub

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/041d01d76e70%24cc9924e0%2465cb6ea0%24%40maladomini.com.
Message has been deleted

Tim Tuck

unread,
Jul 5, 2021, 2:40:06 AM7/5/21
to weewx...@googlegroups.com
Hi Mitchell,

I've done what you want on mine, see bottom left of the page at ->
http://metoffice.skybase.net/

In weewx.conf I have...

# Options for extension 'aqi'
[AqiService]
    [[standard]]
        data_binding = aqi_binding
        standard = user.aqi.us.NowCast
    [[air_sensor]]
        data_binding = wx_binding
        usUnits = usUnits
        dateTime = dateTime
        pm2_5 = pm2_5

In /etc/weewx/skins/Belchertown/graphs.conf

I have this...

     [[chart7]]
                title = PM 2.5
              [[[pm2_5]]]
                type = area
                aggregate_interval = 300
                aggregate_type = avg
                 name = PM 2.5
                 color = "#ffc83f"
                  y_label = "ug/m3"
                  yAxis_min = 0
                  yAxis_softMax = 300

Have a good read of the AQI plugin instructions and hopefully these
stanza's from my config will help.

Hope this helps.

regards

Tim



Graham Eddy

unread,
Jul 5, 2021, 4:26:55 AM7/5/21
to weewx...@googlegroups.com
if all you want is to convert PM2.5 using the US EPA AQI tables i.e. not get variants or labels, see weewx extension http://geddy.id.au/downloads/weewx-aqixtypes-0.0.2.tar.gz
(haven’t got around to putting lots of stuff up on github yet)

configure in weewx.conf by adding
[Engine]
xtypes_services = ..., user.aqixtypes.US_EPA
and map the PM2.5 inputs (instant or 24hr avg or both) to outputs e.g.
[AQIXTypes]
    [[map]]
        aqi_pm2_51_24h_avg = pm2_51_24h_avg
        aqi_pm2_52_24h_avg = pm2_52_24h_avg
        aqi_pm2_51_instant = pm2_5
        aqi_pm2_52_instant = pm2_52
and optionally force the xtypes to be generated into archive packets by
[StdWXCalculate]
    [[Calculations]]
aqi_pm2_51_24h_avg = software, archive
        aqi_pm2_52_24h_avg = software, archive
        aqi_pm2_51_instant = software, archive
        aqi_pm2_52_instant = software, archive

i am not familiar with the belchertown skin

On 4 Jul 2021, at 2:29 am, Mitchell Tuckness <purc...@maladomini.com> wrote:

Ah, thanks! 

I don't suppose you have settings or a guide to get it to work with the Ecowitt PM2.5 sensor instead of the Purple Air one? I am doing some searches, so far not much luck and coding isn't my thing.


purc...@maladomini.com

unread,
Jul 6, 2021, 8:59:01 PM7/6/21
to weewx...@googlegroups.com

On this install, do I use the wee_extension –install command, or uncompress it into a folder somewhere?

 

Thanks!

--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/Pq9ZwFkyDvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/8BC5E64F-EB5D-49F2-8D6C-75766BF7D725%40gmail.com.

Graham Eddy

unread,
Jul 6, 2021, 10:25:44 PM7/6/21
to weewx...@googlegroups.com
standard wee_extension —install

Mitchell Tuckness

unread,
Jul 8, 2021, 7:49:34 AM7/8/21
to weewx-user
Is this section a service or in one of the hooks? This is what I am trying to get, but tied to my sensor.

I was able to get the chart up and running, but I wanted to have something like this where yours is, but tied to my sensor.

Screenshot 2021-07-08 054603.png

Here is my site:

Tim Tuck

unread,
Jul 8, 2021, 8:01:13 PM7/8/21
to weewx...@googlegroups.com
Hi Mitchell,

Its in the 1st hook.

This is in the
/etc/weewx/skins/Belchertown/index_hook_after_station_info.inc file.

<head>
<meta http-equiv="refresh" content="540">
</head>
<table>
  <tr>
#if $current.UV.raw <= 2.4
    <td class="stats_data" style="background-color:
limegreen;text-align:center"><H4>The current UV index $current.UV, is
Low</td>
  #else if $current.UV.raw >= 2.5 and $current.UV.raw <= 5.4
    <td class="stats_data" style="background-color:
yellow;text-align:center"><H4>The current UV index $current.UV, is
Moderate</td>
  #else if $current.UV.raw >= 5.5 and $current.UV.raw <= 7.4
    <td class="stats_data" style="background-color:
orange;text-align:center"><H4>The current UV index $current.UV, is High</td>
  #else if $current.UV.raw >= 7.5 and $current.UV.raw <= 10.4
    <td class="stats_data" style="background-color:
red;text-align:center"><H4>The current UV index $current.UV, is Very
High</td>
  #else if $current.UV.raw > 10.5
    <td class="stats_data" style="background-color:
violet;text-align:center"><H4>The current UV index $current.UV, is
Extreme</td>
#end if

#if $current.pm2_5.raw <= 20
    <td class="stats_data" style="background-color:
#31add3;text-align:center"><H4> The real time AQI of,
$current.pm2_5.raw  is Very Good</td>
  #else if $current.pm2_5.raw >= 21 and $current.pm2_5.raw <= 41
    <td class="stats_data" style="background-color:
#99b964;text-align:center"><H4>The real time AQI of, $current.pm2_5.raw
is Good</td>
  #else if $current.pm2_5.raw >= 42 and $current.pm2_5.raw <= 61
    <td class="stats_data" style="background-color:
#fed337;text-align:center"><H4>The real time AQI of, $current.pm2_5.raw
is Fair</td>
  #else if $current.pm2_5.raw >= 62 and $current.pm2_5.raw <= 92
    <td class="stats_data" style="background-color:
#ec793a;text-align:center"><H4>The real time AQI of, $current.pm2_5.raw
is Poor</td>
  #else if $current.pm2_5.raw > 93 and $current.pm2_5.raw <= 123
    <td class="stats_data" style="background-color:
#782e49;text-align:center;color:yellow"><H4>The real time AQI,
$current.pm2_5.raw is Very Poor</td>
  #else if $current.pm2_5.raw >= 124
    <td class="stats_data" style="background-color:
#d1472d;text-align:center;color:yellow"><H4>The real time AQI of,
$current.pm2_5.raw is Hazardous</td>
#end if

<td style="text-align: center; background-color:
#$aqi($current($data_binding='aqi_binding').aqi_pm2_5_category).color;" >
    <H4>  The 24hr AQI is
$current($data_binding='aqi_binding').aqi_pm2_5 which is
$aqi($current($data_binding='aqi_binding').aqi_pm2_5_category).category.

</td>

  </tr>
</table>

regards

Tim

Mitchell Tuckness

unread,
Jul 8, 2021, 8:33:23 PM7/8/21
to weewx-user
Thank you Tim. I must be missing something. I installed the weewx-aqixtypes-0.0.2.tar.gz. 

Then I added the statement in the weewx.conf (at the end of the config file):

# Options for extension 'aqi'
[AqiService]
    [[standard]]
        data_binding = aqi_binding
        standard = user.aqi.us.NowCast
    [[air_sensor]]
        data_binding = wx_binding
        usUnits = usUnits
        dateTime = dateTime
        pm2_5 = pm2_5

Then I added the rest to the index_hook_after_forecast.inc file (since I have the camera in the station_info hook):

Graham Eddy

unread,
Jul 8, 2021, 10:58:22 PM7/8/21
to weewx...@googlegroups.com
weewx-aqixtypes-0.0.2.tar.gz is not the purpleair aqi extension. it works differently and is configured differently (much simpler)

Tim Tuck

unread,
Jul 9, 2021, 3:30:07 AM7/9/21
to weewx...@googlegroups.com
Hi Mitchell,

OK, there is more than 1 AQI plugin :)

the one I use is this...

https://github.com/jonathankoren/weewx-aqi/

Its easy to get confused between the various additions available.

If you want to use the one I am using you can download it thus...

wget https://github.com/jonathankoren/weewx-aqi/archive/v1.3.tar.gz

regards

Tim

purc...@maladomini.com

unread,
Jul 9, 2021, 7:49:39 PM7/9/21
to weewx...@googlegroups.com

OK, thanks.

I did install that one. I just have to see if I can figure out the fields I need to change. I was hoping we might have the same equipment, and I could just copy your configs, and it would work. But I see some errors I will have to try and figure out if I can 😊


-----Original Message-----
From: weewx...@googlegroups.com <weewx...@googlegroups.com> On Behalf Of Tim Tuck
Sent: Friday, July 9, 2021 1:30 AM
To: weewx...@googlegroups.com
Subject: Re: [weewx-user] Highchart Air Quality

--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/Pq9ZwFkyDvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/ec4cfb21-178c-a40f-f7f4-4a7b3a0f2da1%40skybase.net.

Tim Tuck

unread,
Jul 10, 2021, 2:00:49 AM7/10/21
to weewx...@googlegroups.com
Hi Mitchell,

All my kit is Ecowitt, the PM2.5 sensor is a WH41 if that helps :)

cheers

Tim

purc...@maladomini.com

unread,
Jul 10, 2021, 7:10:35 AM7/10/21
to weewx...@googlegroups.com
Yeah, so is mine. It is weird I can't just copy your pasted codes and have it work. Did you post everything by chance?

I am getting these errors:

Jul 10 05:09:37 weewx-pi weewx[15724] CRITICAL __main__: **** File "/home/weewx/bin/weewx/engine.py", line 93, in __init__
Jul 10 05:09:37 weewx-pi weewx[15724] CRITICAL __main__: **** self.loadServices(config_dict)
Jul 10 05:09:37 weewx-pi weewx[15724] CRITICAL __main__: **** File "/home/weewx/bin/weewx/engine.py", line 161, in loadServices
Jul 10 05:09:37 weewx-pi weewx[15724] CRITICAL __main__: **** obj = weeutil.weeutil.get_object(svc)(self, config_dict)
Jul 10 05:09:37 weewx-pi weewx[15724] CRITICAL __main__: **** File "/home/weewx/bin/user/aqi/service.py", line 97, in __init__
Jul 10 05:09:37 weewx-pi weewx[15724] CRITICAL __main__: **** standard_config_dict = config_dict['AqiService']['standard']
Jul 10 05:09:37 weewx-pi weewx[15724] CRITICAL __main__: **** File "/usr/lib/python3/dist-packages/configobj.py", line 554, in __getitem__
Jul 10 05:09:37 weewx-pi weewx[15724] CRITICAL __main__: **** val = dict.__getitem__(self, key)
Jul 10 05:09:37 weewx-pi weewx[15724] CRITICAL __main__: **** KeyError: 'AqiService'
Jul 10 05:09:37 weewx-pi weewx[15724] CRITICAL __main__: **** Exiting.

-----Original Message-----
From: weewx...@googlegroups.com <weewx...@googlegroups.com> On Behalf Of Tim Tuck
Sent: Saturday, July 10, 2021 12:01 AM
To: weewx...@googlegroups.com
Subject: Re: [weewx-user] Highchart Air Quality

--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/Pq9ZwFkyDvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/fdba639b-274d-6711-9ed8-bd0ee27e6637%40skybase.net.

gjr80

unread,
Jul 10, 2021, 10:02:06 PM7/10/21
to weewx-user
You have a service that WeeWX is trying to load and the service expects to find a [AqiService] top level stanza in weewx.conf but the stanza does not exist. This could be due a number of reasons; it could be differing case (case matters here), a typo, incorrect hierarchy (it may be present as [[AqiService]]) etc. You need to look carefully at weewx.conf. If you used an extension installer it may have been installed/configured correctly to start with but subsequent edits/changes to weewx.conf may have broken it. This is easily done if installing/uninstalling/configuring a number of services, particularly if manually editing weewx.conf.

Gary

purc...@maladomini.com

unread,
Jul 11, 2021, 5:55:36 PM7/11/21
to weewx...@googlegroups.com

Hi Gary, It did put one in, at the bottom of the weewx.conf

 

I commented out the three for the purple and the pm10.

 

# Options for extension 'aqi'

[AqiService]

    [[standard]]

        data_binding = aqi_binding

        standard = user.aqi.us.NowCast

    [[air_sensor]]

        data_binding = wx_binding

        usUnits = usUnits

        dateTime = dateTime

        pm2_5 = pm2_5

#        temp = purple_temperature

#        pressure = purple_pressure

#        pm10_0 = pm10_0_atm

 

From: weewx...@googlegroups.com <weewx...@googlegroups.com> On Behalf Of gjr80
Sent: Saturday, July 10, 2021 8:02 PM
To: weewx-user <weewx...@googlegroups.com>
Subject: Re: [weewx-user] Highchart Air Quality

 

You have a service that WeeWX is trying to load and the service expects to find a [AqiService] top level stanza in weewx.conf but the stanza does not exist. This could be due a number of reasons; it could be differing case (case matters here), a typo, incorrect hierarchy (it may be present as [[AqiService]]) etc. You need to look carefully at weewx.conf. If you used an extension installer it may have been installed/configured correctly to start with but subsequent edits/changes to weewx.conf may have broken it. This is easily done if installing/uninstalling/configuring a number of services, particularly if manually editing weewx.conf.

--

You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/Pq9ZwFkyDvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.

gjr80

unread,
Jul 11, 2021, 6:08:03 PM7/11/21
to weewx-user
If that is the case then it's one of two things; either there is some malformation in your config file or WeeWX is using a different config file to what you are looking at. I suggest two things. First, run wee_debug and post the output here (it includes a sanitised copy of the weewx.conf that WeeWX will use). Second, restart WeeWX and post a log extract showing the entire WeeWX startup, this will confirm what config file is being used.

One note, if posting wee_debug output check the output first for any sensitive info such as user names, passwords, api keys etc; wee_debug is pretty good at obfuscating such info but it is not perfect.

Gary

purc...@maladomini.com

unread,
Jul 12, 2021, 7:16:40 PM7/12/21
to weewx...@googlegroups.com

I attached the debug and the boot capture, and removed everything that looked sensitive. I left the data in the index_hook_after_forecast.inc

 that I got from Tim (which is not working).

 

Thanks,

 

Mitchell

weewx.debug
weewx-boot.txt

vince

unread,
Jul 12, 2021, 11:24:54 PM7/12/21
to weewx-user

Cheetah is notoriously hard to debug.

FWIW, if it's me I take all the if-then-else and table stuff out (at least initially) and try the simplest .tmpl file that you can possibly cook up, printing out the two .raw elements verbatim into a simple text format.  Something like the following:

<ul>
<li>UV = $current.UV.raw</li>
<li> pm2_5 = $current.pm2_5.raw</li>
</ul>

 Once that works, add the complexity/slickness stuff like tables and meta refresh and formatting etc.....

Graham Eddy

unread,
Jul 13, 2021, 12:37:58 AM7/13/21
to weewx...@googlegroups.com
i like to put “#if False” at the top and “#end if” at the bottom, and progressively move the ‘def’s closer together

gjr80

unread,
Jul 13, 2021, 3:34:12 AM7/13/21
to weewx-user
Well the config file in the wee_debug report appears fine, this is backed up by the startup log extract which shows your service loading fine now. I don't know what changed but it appears WeeWX is happy to start now. I woudl give it the benfit of the doubt.

I'm not a Belchertown or an AQI service user so afraid I can't help with those, probably best for others that use Belchertown and the the service concerned to help.

Gary

Mitchell Tuckness

unread,
Jul 18, 2021, 9:32:10 AM7/18/21
to weewx-user

OK thanks. I don't know HTML and all that well enough to troubleshoot that stuff. I appreciate the help getting the AQI plugin working, even though it reads it from another source.

Ron Sell

unread,
Aug 24, 2021, 2:52:12 PM8/24/21
to weewx...@googlegroups.com
hi there,

Do you have any tips for adding this?
image.png

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Tim Tuck

unread,
Sep 3, 2021, 1:35:24 AM9/3/21
to weewx...@googlegroups.com
On 25/8/21 4:51 am, Ron Sell wrote:
hi there,

Do you have any tips for adding this?
image.png

Hi Ron,

That part is rendered by  /etc/weewx/skins/Belchertown/index_hook_after_station_info.inc 

The code for that is...

<head>
<meta http-equiv="refresh" content="540">
</head>
<table>
  <tr>
#if $current.UV.raw <= 2.4
    <td class="stats_data" style="background-color: limegreen;text-align:center"><H4>The current UV index $current.UV, is Low</td>
  #else if $current.UV.raw >= 2.5 and $current.UV.raw <= 5.4
    <td class="stats_data" style="background-color: yellow;text-align:center"><H4>The current UV index $current.UV, is Moderate</td>
  #else if $current.UV.raw >= 5.5 and $current.UV.raw <= 7.4
    <td class="stats_data" style="background-color: orange;text-align:center"><H4>The current UV index $current.UV, is High</td>
  #else if $current.UV.raw >= 7.5 and $current.UV.raw <= 10.4
    <td class="stats_data" style="background-color: red;text-align:center"><H4>The current UV index $current.UV, is Very High</td>
  #else if $current.UV.raw > 10.5
    <td class="stats_data" style="background-color: violet;text-align:center"><H4>The current UV index $current.UV, is Extreme</td>
#end if

#if $current.pm2_5.raw <= 20
    <td class="stats_data" style="background-color: #31add3;text-align:center"><H4> The real time AQI of, $current.pm2_5.raw  is Very Good</td>
  #else if $current.pm2_5.raw >= 21 and $current.pm2_5.raw <= 41
    <td class="stats_data" style="background-color: #99b964;text-align:center"><H4>The real time AQI of, $current.pm2_5.raw is Good</td>
  #else if $current.pm2_5.raw >= 42 and $current.pm2_5.raw <= 61
    <td class="stats_data" style="background-color: #fed337;text-align:center"><H4>The real time AQI of, $current.pm2_5.raw is Fair</td>
  #else if $current.pm2_5.raw >= 62 and $current.pm2_5.raw <= 92
    <td class="stats_data" style="background-color: #ec793a;text-align:center"><H4>The real time AQI of, $current.pm2_5.raw is Poor</td>
  #else if $current.pm2_5.raw > 93 and $current.pm2_5.raw <= 123
    <td class="stats_data" style="background-color: #782e49;text-align:center;color:yellow"><H4>The real time AQI, $current.pm2_5.raw is Very Poor</td>
  #else if $current.pm2_5.raw >= 124
    <td class="stats_data" style="background-color: #d1472d;text-align:center;color:yellow"><H4>The real time AQI of, $current.pm2_5.raw is Hazardous</td
>
#end if

<td style="text-align: center; background-color: #$aqi($current($data_binding='aqi_binding').aqi_pm2_5_category).color;" >
    <H4>  The 24hr AQI is $current($data_binding='aqi_binding').aqi_pm2_5 which is $aqi($current($data_binding='aqi_binding').aqi_pm2_5_category).categor
y. 

</td>

  </tr>
</table>

regards

Tim

vince

unread,
Sep 3, 2021, 10:30:48 AM9/3/21
to weewx-user
That's really great stuff and a great example of cheetah magic !!!!

Reply all
Reply to author
Forward
0 new messages