Weather Station Data

So ive finally bit the bullet and upgraded my old RF weather station to one thats wifi enabled. Its up and running and working great.

Next step ? Feed WU data into HA. Except you cant get an API key anymore. It sends you off to the weather channels corporate website. Yeah, thats not going to happen.
It also seems that based on WU forums, WU just isnt working at the moment. (I cant get my station to push data up)

My weather station also integrates with weathercloud, and WeatherObservations. Weathercloud seem to have an API.
Has anyone written anything before i re-invent the wheel ?

TIA
-D

Scratch that. Weathercloud API is only for uploading data, not exporting or accessing it.

Iā€™m interested in this question as well.
Iā€™d like to get a weather station, hook it up to a community service and also integrate with HA.
The best bang/buck Iā€™ve found is the Ambient Weather WS-2902A.
Anyone successful in linking a weather station to HA?

yep I have a vantage vue that links into Weather underground and then in HA, works perfectly

Iā€™ve been researching further and I think my current best bet is acurite weather station(01536 or 02064) ($100ishUS) and weewx over USB. weewx can interface with Wunderground(if anyone still wants to, considering their new pay to play stance) and using MQTT you can link to HA.
weewx will interface with alot of different weather stations over USB/serial/IP (http://weewx.com/docs/hardware.htm)

1 Like

You can upload data to openweathermap and then use the hass openweathermap component.

A direct weewx component would be good - seems a bit pointless to upload the data then download it again.

I finally managed to figure out the serial port communication protocol of my old Davis Weather Monitor II. I hacked together a little program in python to get the real time weather conditions from the station. Now, I am looking for a way to integrate that into Home Assistant, I realize that uploading to WeatherUnderground is no longer the best option.
Can someone point me in the right direction? I already checked the documentation for Hass architecture, and I am going through the Development 101 section right now. What I am wondering is if there is any step by step tutorial with an example, or a component I could use and/or adjust my python script to work with a component that already exist.
I hope I am making senseā€¦

If you can get the data via script then you can just publish the data using mqtt. there is a command line utility called mosquitto_pub (mosquito-clients package i think) that lets you publish to an mqtt server that Home Assistant can read from. The only difficult part is writing the json formatting and configuring an mqtt sensor in hass.

I figured i should probably update this.
So i ended up using weewx, and spoofing the DNS for the WU endpoint, and got the data into HA that way. Weewx then forwards the data onto WU, so mobile apps etc still work.

I found a few good docs which helped me get weewx up and running, it was relatively easy once i got my head around the requirements, and worked out the relevant settings.

One super annonying thing ā€¦ the weather station supplies any length measurements (eg rain) in CM, rather than MM. Is there an easy way to convert these on the fly in HA ? I am so used to looking at rain in terms of mm that cm is just confusing!

Thanks!

1 Like

Use a template sensor and multiply by 10.

gosh, thats so obvious! I didnt even think of that.

I finally got the time to work on getting my weather station data from weeWX to Home Assistant. I didnā€™t want to mess up with MQTT so I created a json template for the skin that I am using, seasons (which is the default skin in the last release). Since my weewx is running in a Debian machine, installed using apt, I created the file: /etc/weewx/skins/Seasons/daily.json.tmpl with the following template:

#encoding UTF-8
{"title":"Current Values","location":"$station.location","time":"$current.dateTime","lat":"$station.latitude[0]Ā° $station.latitude[1]' $station.latitude[2]","lon":"$station.longitude[0]Ā° $station.longitude[1]' $station.longitude[2]","alt":"$station.altitude","hardware":"$station.hardware","uptime":"$station.uptime","serverUptime":"$station.os_uptime","weewxVersion":"$station.version","current": {"outTemp":"$current.outTemp.formatted","windchill":"$current.windchill.formatted","heatIndex":"$current.heatindex.formatted","dewpoint":"$current.dewpoint.formatted","humidity":"$current.outHumidity.formatted","insideHumidity":"$current.inHumidity.formatted","barometer":"$current.barometer.formatted","barometerTrendDelta":"$trend.time_delta.hour.format("%.0f")","barometerTrendData":"$trend.barometer.formatted","windSpeed":"$current.windSpeed.formatted","windDir":"$current.windDir.formatted","windDirText":"$current.windDir.ordinal_compass","windGust":"$current.windGust.formatted","windGustDir":"$current.windGustDir.formatted","rainRate":"$current.rainRate.formatted","insideTemp":"$current.inTemp.formatted"}}

Then I edited the file /etc/weewx/skins/Seasons/skin.conf. Look for the following blocks:

[CheetahGenerator]
    ....
    [[ToDate]]
        ....
        [[[RSS]]]
            template = rss.xml.tmpl

Right after that last line add:

[[[json]]]
    template = daily.json.tmpl

If you canā€™t wait for the next report interval, use wee_reports to force the generation of the reports. Now you can access the json file through your browser: http://IP-ADDRESS/weewx/daily.json
That data in that template is what my Station collects, if yours collects different information you will need to edit the template: http://www.weewx.com/docs/customizing.htm#customizing_templates

Now, in home assistant I create a RESTful sensor with all the values as a dictionary attribute ā€˜currentā€™ like this:

- platform: rest
  resource: http://weewx.server.ip.address/weewx/daily.json
  name: Weather Station
  json_attributes:
    - current
  value_template: '{{ value_json.hardware }}'

And for each data I create a template sensor like this:

- platform: template
  sensors:
    outside_temperature:
      friendly_name: Outside Temperature
      entity_id:
        - sensor.weather_station
      value_template: "{{ states.sensor.weather_station.attributes.current['outTemp'] }}"
      unit_of_measurement: 'Ā°F'

And that should be all you need to get weeWX data into Home Assistant.

8 Likes

Seems like Iā€™m close to getting this to work. I have the json.daily working for the weather station, but when I add a template sensor like the Outside Temperature I get the following error:

Error loading /config/configuration.yaml: ā€˜utf-8ā€™ codec canā€™t decode byte 0xb0 in position 170: invalid start byte

Any ideas for a fix?

@eriberg, can you post that section of your configuration.yaml?

1 Like

sensor:

Weather prediction

  • platform: yr

  • platform: rest
    resource: http://192.168.0.19/weewx/daily.json
    name: Weather Station
    json_attributes:

    • current
      value_template: ā€˜{{ value_json.hardware }}ā€™
  • platform: template
    sensors:
    outside_temperature:
    friendly_name: Outside Temperature
    entity_id:
    - sensor.weather_station
    value_template: ā€œ{{ states.sensor.weather_station.attributes.current[ā€˜outTempā€™] }}ā€
    unit_of_measurement: ā€˜Ā°Fā€™

Iā€™ve narrowed it down to the degrees symbol before the F. When I take that out, it works. My install is on Raspbian, so maybe I need a dependency? I just copied the sensor info from above.

1 Like

So, it sounds like this same issue: Unable to read file with Ā° symbol if not in configuration.yaml

Got it fixed. Thanks for your work on this.

Great infoā€¦

Can you create detailed user guide for ā€˜dumbsā€™ like meā€¦

What neededā€¦
Code sharingā€¦ etcā€¦

Thank youā€¦

Hi kslb.
At a high to medium level;

On an rpi (or some other sort of server running ubuntu/debian)
install dnsmasq (apt-get install dnsmasq)
This will give you your own local DNS server, which you have full control over.
dnsmasq is a simple lightweight DNS server, which uses entries in the local hosts file. Edit the hosts file (/etc/hosts) and add in and entry like this, substituting 192.168.1.xx for the IP address of your rpi/server

192.168.1.xx rtupdate.wunderground.com

You then need to change the DNS server being sent by your router, or whatever is doing DHCP, to send the address of your rpi/server instead. Thats very router specific, and some routers, particularly if supplied by your ISP might not let you.

Install weewx as per this document:
http://www.weewx.com/docs/debian.htm

You then need to configure weewx to get the data for your exact weather station. Ive omitted this part, mostly because i cant remember it, but theres heaps of info online RE this

You then need to setup your config for weewx
in /etc/weewx/weewx.conf
if you want to still send data to Wunderground, setup the [[Wunderground]] section, adding your station ID and credentials.

for MQTT, configure the [[MQTT]] section. Below are my examples of both

[[Wunderground]]
    # This section is for configuring posts to the Weather Underground.

    # If you wish to do this, set the option 'enable' to true,
    # and specify a station (e.g., 'KORHOODR3') and password.
    enable = true
    station = <omitted>
    # To guard against parsing errors, put your password in quotes:
    password = <omitted>

    # Set the following to True to have weewx use the WU "Rapidfire"
    # protocol. Not all hardware can support it. See the User's Guide.
    rapidfire = False

[[MQTT]]
    server_url = mqtt://<omitted>:1883
    topic = weather
    unit_system = METRIC
    retain = True

Hope that helps!

I managed to use DNAT and to use data as ā€œObserverā€ weather station device in weewx software in my old Raspberry Pi 3ā€¦
Currently Iā€™m still publishing data to WUnderground via weewx because HA is still getting data from WU API serviceā€¦

Now there is the latest quest how to create MQTT protocol to transfer data on-the-go when new data arives to weewx (every 16 seconds) and automaticly transfer (publish) this to MQTT to HAā€¦ Currently data is changed on weewx page every 5 minutes (it can stay this, but on HA I would like real time data because of my automation regarding UV sensor etcā€¦)

In that step I will need helpā€¦

Which plugin if any to use in weewx for MQTT protocol?

How to make automation on weewx to transfer data or this can be handeled via HA HTTP or MQTT request?