WeeWX data receiving through MQTT

Hello there,
I am using my own weather station and instead of pulling the data through accuweather, I want to pull them from my WeeWX MQTT server. However, I am struggling to get the data from it.
What I have done:
I have created a MQTT Broker, which seems to be correct, as it shows Online:

UID: mqtt:broker:3d1084e2d9
label: MQTT Broker WeeWX
thingTypeUID: mqtt:broker
  lwtQos: 0
  publickeypin: true
  clientid: cc5d4355-a628-4f7d-970e-def2344b7d27
  keepAlive: 60
  secure: false
  certificatepin: true
  password: *****
  qos: 0
  reconnectTime: 60000
  port: 1883
  lwtRetain: true
  enableDiscovery: true
  username: pi
  - id: weather_outTemp_C
    channelTypeUID: mqtt:publishTrigger
    label: weather/outTemp_C
    description: ""
      stateTopic: weather/outTemp_C

Regarding the WeeWX MQTT Manual https://github.com/weewx/weewx/wiki/mqtt#how-to-verify I have created a channel:

I can’t create the link to the channel, as there is no profile available for the selected item:

Then I have created MQTT Thing, which is using MQTT broker upper:

UID: mqtt:topic:3d1084e2d9:4a34779f9e
label: WeeWX MQTT Thing
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:3d1084e2d9
  - id: weather_outTemp_C
    channelTypeUID: mqtt:number
    label: weewx/outTemp_C
    description: ""
      stateTopic: weather/outTemp_C

The channel under it is not getting any data and has always status NULL.

What should I do to make it work? I can see that the WeeWX MQTT server is running and publishing all the data, also the weewx/outTemp_C topic

Error Log:

2022-01-06 10:59:05.759 [WARN ] [nal.transport.MiIoAsyncCommunication] - Error while polling/sending message for 1676577472
java.lang.IllegalArgumentException: 32 > 3
	at java.util.Arrays.copyOfRange(Arrays.java:4029) ~[?:?]
	at org.openhab.binding.miio.internal.Message.<init>(Message.java:55) ~[bundleFile:?]
	at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendData(MiIoAsyncCommunication.java:392) ~[bundleFile:?]
	at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendCommand(MiIoAsyncCommunication.java:311) ~[bundleFile:?]
	at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.sendMiIoSendCommand(MiIoAsyncCommunication.java:176) ~[bundleFile:?]
	at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication$MessageSenderThread.run(MiIoAsyncCommunication.java:278) [bundleFile:?]

Thank you,
Michal, Slovakia

Can you show us what the value is of this topic?

Also, don’t add Channels to your Broker Thing. That Thing is only to connect to your MQTT broker. To extract information from MQTT topics you need to use a Generic MQTT Thing, as you have done in the second part of your post.

This looks unrelated. Do you also have a Miio binding active?

1 Like

You’ve created a channel directly on the broker, which is almost always not what you really want.

You would normally create a generic topic Thing representing your weather station, then several channels, each representing temp, humidity etc.

That is because you have created an event (trigger) type channel, and you really want a state type channel to link to Items.

Keep your broker, but start over by creating a “child” generic topic Thing

1 Like

Yes, Miio is active. Strange, maybe another bug?

OK, MQTT broker channel is deleted.

This is the output on WeeWX server:

pi@WeeWX:~ $ mosquitto_sub -h localhost -t weather/#
{"dateTime": "1641499011.0", "pressure_mbar": "983.3393935571426", "barometer_mbar": "1019.0319247510687", "outHumidity": "73.0", "inHumidity": "58.0", "outTemp_C": "-1.0000000000000004", "inTemp_C": "23.388888888888886", "windSpeed_kph": "7.885785600000001", "windGust_kph": "11.104473600000002", "windDir": "303.0", "radiation_Wpm2": "0.0", "dewpoint_C": "-5.222222222222221", "windchill_C": "-3.888888888888889", "UV": "0.0", "altimeter_mbar": "1022.0195956475643", "heatindex_C": "-1.0000000000000004", "inDewpoint_C": "14.646245572302721", "rainRate_cm_per_hour": "0.0", "maxSolarRad_Wpm2": "0.0", "cloudbase_meter": "850.0294850139111", "humidex_C": "-1.0000000000000004", "appTemp_C": "-5.166131999147361", "rain_cm": "0.0", "hourRain_cm": "0.0", "rain24_cm": "0.0", "dayRain_cm": "0.0", "usUnits": "16.0"}
{"dateTime": "1641498960.0", "pressure_mbar": "983.3393935571426", "barometer_mbar": "1019.0319247510687", "outHumidity": "72.0", "inHumidity": "58.0", "outTemp_C": "-0.8888888888888897", "inTemp_C": "23.5", "windSpeed_kph": "5.4717696", "windGust_kph": "5.4717696", "windDir": "333.99999999999994", "radiation_Wpm2": "0.0", "dewpoint_C": "-5.277777777777778", "windchill_C": "-2.7777777777777777", "UV": "0.0", "altimeter_mbar": "1022.0195956475643", "heatindex_C": "-0.8888888888888897", "inDewpoint_C": "14.750038608674455", "rainRate_cm_per_hour": "0.0", "maxSolarRad_Wpm2": "0.0", "cloudbase_meter": "873.1664480254032", "humidex_C": "-0.8888888888888897", "appTemp_C": "-4.593341246866427", "rain_cm": "0.0", "hourRain_cm": "0.0", "rain24_cm": "0.0", "dayRain_cm": "0.0", "usUnits": "16.0", "windGustDir": "334.0", "interval_minute": "1.0", "time": "1641498784.0", "pm10_0_microgram_per_meter_cubed": "7.15", "pm2_5_microgram_per_meter_cubed": "1.7", "extraTemp1_C": "-1.5700000000000003", "BME280_pressure": "98305.88", "extraHumid1": "67.78", "signal1": "-87.0", "ET_cm": "2.141740149935718e-05", "windrun_km": "0.09119616", "signal8": "16.5"}

So the topic should be only weather/# and I need to parse the output somehow I guess?

Great, thanks for pointing it. There was weewx.conf parameter wrong.
Under [[MQTT]] stanza the parameter aggregation = aggregate instead should be aggregation = individual
Is there a kind of autodiscover option, or do I need to add the channels one-by-one?

If whatever is sending the data to the MQTT broker supports the Homie or HomeAssistant MQTT standard then you can autodiscover with openHAB. If not, then you’ll have to configure the Channels manually!

1 Like