Publishing weather device information to an MQTT message broker for Home Assistant.

A script opens a change stream on a mongo collection that accumulates device broadcasts from 433mhz devices.

The Acurtite 5-in-1 broadcasts two message_types: wind direction and rain

    _id: ObjectId('6a7d29b491aefe4ab323c420'),
    time: '2026-08-12 22:19:32',
    model: 'Acurite-5n1',
    message_type: 49,
    id: 838,
    channel: 'A',
    sequence_num: 1,
    battery_ok: 1,
    wind_avg_km_h: 0,
    wind_dir_deg: 202.5,
    rain_in: 0.02,
    mic: 'CHECKSUM'
  }

temperature and humidity

  {
    _id: ObjectId('6a7d29cb91aefe4ab323c427'),
    time: '2026-08-12 22:19:50',
    model: 'Acurite-5n1',
    message_type: 56,
    id: 838,
    channel: 'A',
    sequence_num: 2,
    battery_ok: 1,
    wind_avg_km_h: 0,
    temperature_F: 69.8,
    humidity: 91,
    mic: 'CHECKSUM'
  }

Note: Wind speed is included in both broadcasts

Some light research suggests the inclusion in both is to provide more frequent measurements (resolution) for this sensor.

I haven’t determined how the weather display records sun exposure via solar panel yet. This might not even be a real feature and I’m just assuming too much.

Creating the devices

I’ll start with the temperature and humidity.

mqtt.publish('homeassistant/sensor/weatherT/config', '{"device_class":"temperature","state_topic":"homeassistant/sensor/weather/state","unit_of_measurement":"°F","state_class":"measurement","value_template":"{{ value_json.temperature_F}}","unique_id":"weatherT","device":{"identifiers":["weather"],"name":"Acurite 5-in-1"}}' ,0,properties=properties)

mqtt.publish('homeassistant/sensor/weatherH/config', '{"device_class":"humidity","state_topic":"homeassistant/sensor/weather/state","unit_of_measurement":"%","state_class":"measurement","value_template":"{{ value_json.humidity}}","unique_id":"weatherH","device":{"identifiers":["weather"],"name":"Acurite 5-in-1"}}' ,0,properties=properties)

I asked Gemini to provide the three missing sensors after providing the above examples. It hallucinated a bit, but here’s the corrected results:

# Wind Speed
mqtt.publish('homeassistant/sensor/weatherWS/config', '{"device_class":"wind_speed","state_topic":"homeassistant/sensor/weather/state","unit_of_measurement":"km/h","state_class":"measurement","value_template":"{{ value_json.wind_avg_km_h }}","unique_id":"weatherWS","device":{"identifiers":["weather"],"name":"Acurite 5-in-1"}}', 0, properties=properties)

# Wind Direction
mqtt.publish('homeassistant/sensor/weatherWD/config', '{"device_class":"wind_direction","state_topic":"homeassistant/sensor/weather/state","unit_of_measurement":"°","state_class":"measurement","value_template":"{{ value_json.wind_dir_deg }}","unique_id":"weatherWD","device":{"identifiers":["weather"],"name":"Acurite 5-in-1"}}', 0, properties=properties)

# Total Precipitation Accumulation
mqtt.publish('homeassistant/sensor/weatherPR/config', '{"device_class":"precipitation","state_topic":"homeassistant/sensor/weather/state","unit_of_measurement":"in","state_class":"total_increasing","value_template":"{{ value_json.rain_in }}","unique_id":"weatherPR","device":{"identifiers":["weather"],"name":"Acurite 5-in-1"}}', 0, properties=properties)

Publishing device data

    if(change['fullDocument']['id'] == 838):
      print('pushing weather station data')
      msg = mqtt.publish('homeassistant/sensor/weather/state',dumps(change['fullDocument']),0,properties=properties)

All of this is wrapped up in various services and scripts. Home Assistant is configured to listen to this MQTT broker that the mongomqtt.service is pushing select change streams entries to. I’ll document this whole pipeline in more detail some other time.