[UPDATED] Weewx Weather Driver With External Forecasting

community_driver

#1

For people with a Personal Weather Station (PWS) that is capable of sending its data to a local source.

A while ago a discussion was started to work out a way to get data presented from a PWS via software called 'Weewx ' into Hubitat for use with apps like RM and the Hubitat dashboard.

Weewx is free software that you host on your own server (I use a Raspberry Pi) to take the readings from a PWS and present them in a readable format so we can use this driver to bring the data into Hubitat.
It is also capable of sending the same data to WU and others and is highly configurable.
I use it to FTP my data to a webpage on the 'net.

I have created a driver that will regularly poll the weewx server on a configurable schedule to collect the data.
One thing missing from the Weewx software is forecasting.
To help with this, the driver can also collect data from Apixu for forecasting.
(You will need to sign up to Apixu and get an API key)

The driver has options whether to use Apixu or not and has other options that are mostly self-explanitory
One thing to note:
If you are using this data with SmartTiles or the Hubitat dashboard then you must turn 'Display Data Units' OFF as the dashboards add their own units.

This is the output from the driver (shown with data units)

And this is how mine is configured:

Weewx and apixu present data which is both Imperial & Metric
Whichever way you have configured your weewx server , the driver will automatically present the data as you want it (it will sense the incoming format and convert if necessary to your selections)

Any missing data from your PWS (such as 'internal temperature' if you don't have the internal unit) will just show: 'No Station Data'

There is lots of help documentation for Weewx and you should be able to configure it quite easily.
To get weewx to present the data into json format and additional file is required but if you need any help then please ask.

For those of you that want to use a raspberry Pi for the weewx server then I have created an almost fully configured Pi image file if you would like to try it. (You just need to change the password and a few station related bits after burning the .img file)
PM me for a download link as it's not on github

Many thanks to @homeauto2112 for all his patient help with debugging and testing of this driver
Additional debugging help provided by @bptworld

OK.. Here is the link to the driver.

Hopefully, someone may find it useful :slight_smile:

I have released a version of 'Weather Switch' to work exclusively with this driver

Parent/Child here:

I have also uploaded a new 'daily.json.tmpl' with additional setting for use with this driver


Update 28/01/2019
Added 'WeatherDisplay' feature
(See post 140)


Update 24/12/2018
Using daily.json.tmpl

Scott (@sgrayban) has created an installer for the skin to generate the correct daily.json.tmpl
You can find the files and instructions here:


Update 16/08/2018
I have added support for daily Min/Max temperatures
NOTE: This requires additions to your daily.json.tmpl
(I have also uploaded a new version of this)


Update 08/08/2018
I have added the ability to select forecast source for people who still have a working WU API


Update: 12/06/2018
I have now made a new addition to this driver.
A new button and command: 'Poll Inside'

This command will push 'Internal' data (inside temperature & inside humidity) as 'standard' Humidity & Temperature
This is so Rule Machine (which cannot see the custom attributes: inside_temp & inside_humidity) can use the internal data in rules.

To use this feature, I would suggest creating a custom command in RM ("PollInside")which is called before running the rest of your rule to use the inside data

'Poll Station Now' will return the standard attributes back to normal


Andy


End of Service for the Weather Underground API
[UPDATED] - Message Central - Make your home speak
Is there a community repository for Drivers and Apps?
Weather Underground
Apixu.com worldwide weather data with outside lux. No PWS or server setup
Community Device Drivers (FKA Compatible Devices Wiki)
[RELEASE] Weather-Display With External Forecast Driver
LaCrosse Sensors
What PWS does everyone use?
SharpTools.io Dashboard and Rule Engine
#2

Can't seem to read my json file from within this driver...

My daily.json:
weatherweewx-01

The driver page:

Error in log:


#3

Ah!
I forgot to mention...

I have added 'rainSum' so you need to edit a config file...

You need to edit daily.json.tmpl and add a little bit in..

Just before the almanac section.

Have a look at your file and compare it to this screenshot

image

You probably don't have the 'sinceMidnight' section

Andy


#4

This is what my output looks like when I browse to http://10.1.20.127:800/weewx/daily.json

{
  "title":"Current Values",
  "location":"South Hetton",
  "time":"11/06/18 16:35:00",
  "lat":"54° 47.88' N",
  "lon":"001° 24.41' W",
  "alt":"328 feet",
  "hardware":"observer",
  "uptime":"2 days, 7 hours, 18 minutes",
  "serverUptime":"2 days, 6 hours, 50 minutes",
  "weewxVersion":"3.8.0",
  "stats": {
    "current": {
      "outTemp":"17.5°C",
      "windchill":"17.5°C",
      "heatIndex":"17.5°C",
      "dewpoint":"12.2°C",
      "humidity":"71%",
      "insideHumidity":"59%",
      "barometer":"1000.0 mbar",
      "barometerTrendDelta":"3 hours",
      "barometerTrendData":"0.0 mbar",
      "windSpeed":"1 mph",
      "windDir":"183°",
      "windDirText":"S",
      "windGust":"5 mph",
      "windGustDir":"   N/A",
      "rainRate":"0.0 mm/hr",
      "UV":"3.5",
      "ET":"0.0 mm",
      "solarRadiation":"490 W/m²",
      "insideTemp":"20.8°C"

    },
   "sinceMidnight": {
      "rainSum":"0.0 mm",
}
},
  "almanac":{
    "sun":{
      "startCivilTwilight":"03:30:34",
      "sunrise":"04:28:17",
      "transit":"13:05:15",
      "sunset":"21:42:39",
      "endCivilTwilight":"22:40:36",
      "azimuth":"252.3°",
      "altitude":"40.1°",
      "rightAscension":"79.8°",
      "declination":"23.1°",
      "equinox":"23/09/18 02:54:09",
      "solstice":"21/06/18 11:07:23"
    },
    "moon":{
      "rise":"03:34:17",
      "transit":"10:52:17",
      "set":"18:27:06",
      "azimuth":"271.7°",
      "altitude":"14.1°",
      "rightAscension":"49.1°",
      "declination":"12.4°",
      "fullMoon":"28/06/18 05:52:57",
      "newMoon":"13/06/18 20:43:13",
      "phase":"Waning crescent",
      "fullness":"7%"
    }
  }
}

#5

hmmm, added in the 'sinceMidnight' section and getting the same error. Tried to compare your json output file with mine and everything else seems to be there, although they look a little different. Do you have a drop in replacement 'daily.json.tmpl' file I could try?

Thanks


#6

I'm just making one now...


#7

Ok.. so I can't attach a txt file
I have uploaded a txt file to the same github location...

daily.json.tmpl.txt

Try this

Andy


#8

One thing to note..
I have my weewx set to part metric so the units will be different if you have yours set to imperial
The driver should work that out and use the correct units though

Andy


#9

If that doesn't work can you please turn the full logging on and do me a screenshot.

Both @homeauto2112 and I use the same PWS and the driver worked fine.
Maybe your PWS puts out something different


#10

Got the same error...full logging below

thanks


#11

Does ‘insideHumidity’ show ‘no station data’?

The driver is trying to do a calculation on an input that doesn’t exist.


#12

insideHumidity is showing 'N/A'. Here is my json output:

{

  "title":"Current Values",

  "location":"Dracut, MA",

  "time":"06/11/2018 12:30:00 PM",

  "lat":"42° 40.08' N",

  "lon":"071° 19.50' W",

  "alt":"89 feet",

  "hardware":"AcuRite 01024",

  "uptime":"6 days, 17 hours, 6 minutes",

  "serverUptime":"6 days, 17 hours, 6 minutes",

  "weewxVersion":"3.8.0",

  "stats": {

    "current": {

      "outTemp":"70.0°F",

      "windchill":"70.0°F",

      "heatIndex":"70.0°F",

      "dewpoint":"42.8°F",

      "humidity":"38%",

      "insideHumidity":"   N/A",

      "barometer":"30.148 inHg",

      "barometerTrendDelta":"3 hours",

      "barometerTrendData":"0.020 inHg",

      "windSpeed":"7 mph",

      "windDir":"190°",

      "windDirText":"S",

      "windGust":"11 mph",

      "windGustDir":"   N/A",

      "rainRate":"0.00 in/hr",





      "insideTemp":"71.4°F"



    },

   "sinceMidnight": {

      "rainSum":"0.00 in",

}

},



  "almanac":{


    "sun":{

      "sunrise":"05:06:52 AM",

      "sunset":"08:23:08 PM",

    },

    "moon":{

      "phase":"Waning crescent",

      "fullness":"7%"

    }


  }

}

#13

Ah!
I think I have it...
I don’t think your pws sends data for solarradiation?
(Unless I missed it)


#14

Nope, it does not


#15

That’s the issue.
I assumed they all did (stupid on my part)

Ok.. I will have to add some more error checking code to each ‘item’ to cover if any station does not produce a value.

As a temporay work around (if you are comfortable with the code) you can comment out a few lines to confirm that this is the problem.

Just comment out (put // in front of the line) the following lines

458 - 464 inclusive
And

467 - 472 inclusive

If you could comment out those lines it will stop checking for solarradiation

Andy


#16

Commenting out the lines worked. I'm getting the data in now. Look forward to the next update.

Thanks


#17

Great!
I thought that might be the problem.
Thanks for your help with the diagnosis
It might take me a while to recode everything but at least the work around confirms the problem.

Andy


#18

New Version 1.7.0 - Uploaded to GitHub - 1st post updated

This now has additional error checking so if a PWS does not send all the data the driver can continue without error

I have also made a new addition to this driver.
A new button and command: 'Poll Inside'

This command will push 'Internal' data (inside temperature & inside humidity) as 'standard' Humidity & Temperature
This is so Rule Machine (which cannot see the custom attributes: inside_temp & inside_humidity) can use the internal data in rules.

To use this feature, I would suggest creating a custom command in RM ("PollInside")which is called before running the rest of your rule to use the inside data

'Poll Station Now' will return the standard attributes back to normal

Andy


#19

New error!

sorry.


#20

Thanks Byran
I'll look into it (probably a stupid typo) but it seemed to work ok on mine