Let's make this one short.
We're still pumping data from legacy sensors into Home Assistant. This time it's data from the two weather stations here. The long-employed LaCrosse WS2308. Jeez this thing has to be over ten years old by now. And a newer Acurite 5n1 station.Both systems use the 433MHz spectrum to send data from their outside sensors to their base stations. Both 433MHz protocols are recognized and decoded by the "rtl_433" open source software.
Rtl_433 can output the intercepted data as JSON payloads which, in turn, can be pumped right into our MQTT (mosquitto) broker.
Those JSON payloads aren't immediately edible by Home Assistant.
Or, if they are, they require an expertise in programming Home Assistant, that I don't have. So, I've stuck something in the middle.
Something easy.
Something that subscribes to the RTL JSON payloads and republishes out new JSON payloads in the MQTT Device Discovery Format that Home Assistant understands.
A lesson learned from the previous success was to treat each sensor separately. The Acurite 5n1 sends over: temperature, humidity, wind speed, wind direction and rain totals.
That's five separate sensors, five different MQTT Device Discovery Configuration Messages.
MQTT Data Payloads
The Acurite 5n1 sends this sensor data across two different JSON payloads via rtl_433. We break out the data to five sensors. It's similar for the WS2308 station (which is labeled as WS2310 by rtl_433). The sensor data for four sensors are scattered across three MQTT messages.
Here's the rtl_433 output for the WS2308 (aka WS2310) station:
{"time" : "2022-10-18T13:47:05", "protocol" : 34, "model" : "LaCrosse-WS2310", "id" : 28, "humidity" : 35, "mod" : "ASK", "freq" : 434.020, "rssi" : -6.215, "snr" : 31.158, "noise" : -37.373}
{"time" : "2022-10-18T13:47:05", "protocol" : 34, "model" : "LaCrosse-WS2310", "id" : 28, "wind_avg_m_s" : 0.000, "wind_dir_deg" : 22.500, "mod" : "ASK", "freq" : 434.019, "rssi" : -6.265, "snr" : 31.108, "noise" : -37.373}
{"time" : "2022-10-18T13:47:06", "protocol" : 34, "model" : "LaCrosse-WS2310", "id" : 28, "temperature_F" : 65.480, "mod" : "ASK", "freq" : 434.020, "rssi" : -6.238, "snr" : 29.886, "noise" : -36.124}
MQTT Device Discovery Configuration Messages
And here's a code snippet to create the configuration MQTT topic and message.
For each station, create the configuration messages for each sensor in that station.
Forward Station Data to Home Assistant
With the configuration messages created and sent to Home Assistant, now just forward the data packets from the weather stations to the new topics specificed in the configuration messages:
Topic:
home/LaCrosse-WS2310-28/temperature
Payload:
{"time" : "2022-10-18T14:53:17", "protocol" : 34, "model" : "LaCrosse-WS2310", "id" : 28, "temperature_F" : 66.200, "mod" : "ASK", "freq" : 434.020, "rssi" : -6.537, "snr" : 29.587, "noise" : -36.124}
And don't forget the state message.
Topic:
home/LaCrosse-WS2310-28/state
Payload:
{"state":"online"}