Weather Station Data

Probably this is the correct way:

Yep – theres an mqtt plugin for weewx.

I have actually found that data getting into WU via weewx is more reliable than data getting straight from the weather station into WU. I have no idea why that is, and havent bothered looking, but WU updates every 150 seconds as set in weewx, whereas when the weather station goes direct it could be every 5 minutes, or an hour – its all over the place.

I have about 10 mqtt sensors setup with data coming in from weewx, and the only thing i pull from WU direct is the wind “String” – ie calm etc

Via json template I succesfully read the weather sensor state - but this was not my goal…
My goal was to get data via MQTT - which I set it up and HA do get somekind welcome HELO from weather station…
But I do not know how to make sensor with MQTT protocol for weather station.
Can you give me some example, like for “outTemp” or some other, then I can create other sensor with no struggle.

json template is very good to discover me, which sensor do make (produce) some data…

Theres an MQTT configuration section in weewx.
This sets the base topic.

Lets say you set it to “weather_station”
in HA, setup a mqtt sensor to “weather_station/outTemp”

OK, I received data for weather/#, but I do not receive any other data…

My configuration in HA:

  - platform: mqtt
    name: "Vremenska postaja"
    state_topic: "weather/#"

  - platform: mqtt
    name: "Temperatura"
    state_topic: "weather/outTemp"
    value_template: '{{ value_json.value }}'
    unit_of_measurement: "°C"

Should I make some other setting in weewx so that I would receive desired value like “outTemp”?

1 Like

Should be in weewx some other configuration regarding MQTT?

        server_url = mqtt://XXX:[email protected]:1883/
        topic = weather
        unit_system = METRIC
        retain = True

So weewx publishes 2 different sets of data
Theres the giant JSON payload, which goes to the base topic

Each of those json key value pairs also gets sent to its own topic.

So your sensor for outTemp doesnt need the value_template line, its not needed – the actual raw data gets sent to weather/outTemp

Yea… but no data is received… With or withouth json value_template…
Just don’t working… Am stuck here…

Perhaps using MQTTLens you can see if the data is coming in?

I will try it…

OK, I figured out…
Help was this topic:!topic/weewx-user/ceFFcB9pikI
MQTT report:
Oct 20 10:44:37 raspberrypi weewx[32002]: restx: MQTT: data: {'rain24_in': '0.32', 'barometer_inHg': '31.099999405', 'outHumidity': '79.9999821513', 'interval_minute': '1.0', 'dewpoint_F': '27.1832189366', 'rain_in': '0.0', 'cloudbase_foot': '4459.42710406', 'heatindex_F': '32.6577165457', 'altimeter_inHg': '34.8504541967', 'dayRain_in': '0.32', 'windrun_mile': '0.000468325880368', 'inDewpoint': '31.0795245766', 'outTemp_F': '32.6577165457', 'windchill_F': '32.6577165457', 'windGustDir': '359.999892908', 'hourRain_in': '0.0', 'rainRate_inch_per_hour': '0.0', 'humidex': '32.6577165457', 'windGust_mph': '3.56973503379e-06', 'pressure_inHg': '31.099999405', 'inTemp_F': '63.0000118991', 'usUnits': '1.0', 'ET_in': '0.466552506793', 'appTemp': '28.4367381251', 'windSpeed_mph': '2.97477919542e-06', 'UV': '12.4826907711', 'dateTime': '1445345040.0', 'windDir': '359.999892908', 'inHumidity': '29.9999762018', 'radiation_Wpm2': '891.620769362'}

So my correct setting is:

  - platform: mqtt
    name: "Temperatura"
    state_topic: "weather/outTemp_C"
    unit_of_measurement: "°C"

  - platform: mqtt
    name: "UV"
    state_topic: "weather/UV"
    unit_of_measurement: "index"

So now if anybody need help I can write complete user guide how to make MQTT on weewx… + I can publish all source code which is needed…

Oh… and I have last goal to receive data more often (currently every 5 minutes).

Do anybody know how to produce reports or just MQTT every like 1 minute…

I would be interested in your code, facing the same challenge soon…

Yes… I will publish… but before…

Just before that I need to finish everything…

Now I must edit output… do you know how to make possible that I get allways data as X.XX and not as X.Xxxxxxx…

Re data — I believe weewx will publish every time it receives an update from the weather station – but dont quote me on that!

Mine seems to be randomly between 1 and 3 minutes.

I think you need to use a value template for that. Something like:

  - platform: mqtt
    name: "Temperatura"
    state_topic: "weather/outTemp_C"
    value_template: "{{ value_json.outTemp_C | round(2) }}"
    unit_of_measurement: "°C"

Just not sure about the value_json, since you just left it out ? But I think you are looking for the round(2). I can’t test i myself yet unfortunately.

Yea, I figured out…

When I will have everything ready I will publish complete code…

I don’t suppose anyone has used the data being returned by their weather station and managed to build something that determines whether or not its raining right now?

If you can get the total rain data value and store that every five minutes in an internal HA mqtt sensor topic, then test that value against the one five minutes later it should give you rain amount inside that window.
I have this in my setup to do daily rain based on the total cumulative value sent by my station, but I can’t see why in principal it couldn’t be done every few minutes…

  - platform: mqtt
    state_topic: 'ha/total_rain_prior'
    name: 'rain_total_prior'
    unit_of_measurement: 'mm'
    value_template: '{{ value_json.day_1 }}' 
  - platform: template
        value_template: '{%- if not (is_state("sensor.rain_register","unknown") or is_state("sensor.rain_total_prior","unknown") )-%}  {{ ((states.sensor.rain_register.state | float) - (states.sensor.rain_total_prior.state | float)) | max (0) | round(1) }} {%- endif -%}' ## ensure calc is no lower than zero!
        friendly_name: 'Rain from 9AM today'
        unit_of_measurement: 'mm'

Or just use the trend sensor