WeeWX, MQTT and how to import Data

Ladies, Gents,

i´m not a newbee, but 52 y old and not a skilled mqtt pro.
system: raspi 3b+ with 120gb ssd: hass core 0.112.2 OS 4.10 mosquitto broker
weewx on another raspi.

currently i´m asking the weewx server via mqtt broker for new weather data. log:

1594996516: New connection from 192.168.0.15 on port 1883.
1594996516: New client connected from 192.168.0.15 as weewx_36f5aed1 (p2, c1, k60, u’xxxxxxx’).
1594996517: Client weewx_36f5aed1 disconnected.
1594996593: Saving in-memory database to /data/mosquitto.db.
1594996816: New connection from 192.168.0.15 on port 1883.
[INFO] found xxxxxxx on local database
1594996817: New client connected from 192.168.0.15 as weewx_2c1ea416 (p2, c1, k60, u’xxxxxxx’).
1594996818: Client weewx_2c1ea416 disconnected.
1594997119: New connection from 192.168.0.15 on port 1883.
[INFO] found xxxxxxx on local database
1594997120: New client connected from 192.168.0.15 as weewx_d92fbd1c (p2, c1, k60, u’xxxxxxx’).
1594997121: Client weewx_d92fbd1c disconnected.

so far, so good, but where are the data? how can i integrate the data into hass.io?
i´ve checked with the mqtt explorer, if there are the data and voila
mqtt

ok, but how to subscribe the wx-variables and how can i integrate them?

any help is very appreciated,
greez michl

Use the MQTT sensor.

1 Like

Great! Thank you @Burningstone!

temp

Is there a way to reduce the number of decimals?

You can round the result in the value_template part of the sensor. Can you show your current working code please?

1 Like

this is the part from configuration.yaml

mqtt sensor

sensor:
- platform: mqtt
name: “OutTemperature1”
state_topic: “weather/outTemp_C”
unit_of_measurement: ‘°C’

Please read this topic, especially point 11 regarding the correct formatting of code in the forum.

You can use a value_template to round your value.

Try this:

sensor:
  - platform: mqtt
    name: “OutTemperature1”
    state_topic: “weather/outTemp_C”
    unit_of_measurement: ‘°C’
    value_template: "{{ (value | round(2)) | float }}"

I’m not sure if the last float filter is needed, you can probably remove it, can’t test at the moment.

2 Likes

Thank you @Burningstone for help and hints regarding correct formatting.
and no problem, i´ll play around and will inform if this thing works.

works like a charme.
thp-display

i had to adapt the quotation marks and reduced to 1 decimal, now this is working fine:

sensor:
    - platform: mqtt
      name: "OutTemperature_101"
      state_topic: "weather/outTemp_C"
      unit_of_measurement: '°C'
      value_template: "{{ (value | round(1)) | float }}"

Thx for helping a silversurfer :wink:

Just posting this here to make it easier for others.

The weewx mqtt addon is really basic, hope someone will build a discoverable addon soon :slight_smile:

Enjoy!

sensor:
  - platform: mqtt
    name: weather_station_outtemp_c
    unique_id: uniqueid__weather_outtemp_c
    icon: mdi:thermometer
    state_topic: "weather/outTemp_C"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "°C"

  - platform: mqtt
    name: weather_station_intemp_c
    unique_id: uniqueid__weather_intemp_c
    icon: mdi:thermometer
    state_topic: "weather/inTemp_C"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "°C"

  - platform: mqtt
    name: weather_station_dewpoint_c
    unique_id: uniqueid__weather_dewpoint_c
    icon: mdi:thermometer
    state_topic: "weather/dewpoint_C"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "°C"

  - platform: mqtt
    name: weather_station_indewpoint_c
    unique_id: uniqueid__weather_indewpoint_c
    icon: mdi:thermometer
    state_topic: "weather/inDewpoint_C"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "°C"

  - platform: mqtt
    name: weather_station_windchill_c
    unique_id: uniqueid__weather_windchill_c
    icon: mdi:thermometer
    state_topic: "weather/windchill_C"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "°C"

  - platform: mqtt
    name: weather_station_apptemp_c
    unique_id: uniqueid__weather_apptemp_c
    icon: mdi:thermometer
    state_topic: "weather/appTemp_C"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "°C"

  - platform: mqtt
    name: weather_station_heatindex_c
    unique_id: uniqueid__weather_geatindex_c
    icon: mdi:thermometer
    state_topic: "weather/heatindex_C"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "°C"

  - platform: mqtt
    name: weather_station_humidex_c
    unique_id: uniqueid__weather_humindex_c
    icon: mdi:thermometer
    state_topic: "weather/humidex_C"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "°C"

  #############################################################################

  - platform: mqtt
    name: weather_station_outhumidity
    unique_id: uniqueid__weather_outhumidity
    icon: mdi:water-percent
    state_topic: "weather/outHumidity"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "%"

  - platform: mqtt
    name: weather_station_inhumidity
    unique_id: uniqueid__weather_inhumidity
    icon: mdi:water-percent
    state_topic: "weather/inHumidity"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "%"

  - platform: mqtt
    name: weather_station_altimeter_mbar
    unique_id: uniqueid__weather_altimeter_mbar
    icon: mdi:gauge
    state_topic: "weather/altimeter_mbar"
    value_template: "{{ value | round(0) }}"
    unit_of_measurement: "mBar"

  - platform: mqtt
    name: weather_station_pressure_mbar
    unique_id: uniqueid__weather_pressure_mbar
    icon: mdi:gauge
    state_topic: "weather/pressure_mbar"
    value_template: "{{ value | round(0) }}"
    unit_of_measurement: "mBar"

  - platform: mqtt
    name: weather_station_barometer_mbar
    unique_id: uniqueid__weather_barometer_mbar
    icon: mdi:gauge
    state_topic: "weather/barometer_mbar"
    value_template: "{{ value | round(0) }}"
    unit_of_measurement: "mBar"

  #############################################################################

  - platform: mqtt
    name: weather_station_windspeed_kph
    unique_id: uniqueid__weather_windspeed_kph
    icon: mdi:weather-windy
    state_topic: "weather/windSpeed_kph"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "km/h"

  - platform: mqtt
    name: weather_station_windgust_kph
    unique_id: uniqueid__weather_windgust_kph
    icon: mdi:weather-windy-variant
    state_topic: "weather/windGust_kph"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "km/h"

  - platform: mqtt
    name: weather_station_winddir
    unique_id: uniqueid__weather_winddir
    icon: mdi:wind-turbine
    state_topic: "weather/windDir"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "°"

  - platform: mqtt
    name: weather_station_gustdir
    unique_id: uniqueid__weather_gustdir
    icon: mdi:wind-turbine
    state_topic: "weather/gustDir"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "°"

  - platform: mqtt
    name: weather_station_rainrate_cm_per_hour
    unique_id: uniqueid__weather_rainrate_cm_per_hour
    icon: mdi:umbrella-outline
    state_topic: "weather/rainRate_cm_per_hour"
    value_template: "{{ (value | float * 100) | round(0) }}"
    unit_of_measurement: "mm/h"

  - platform: mqtt
    name: weather_station_rain_cm
    unique_id: uniqueid__weather_rain_cm
    icon: mdi:umbrella
    state_topic: "weather/rain_cm"
    value_template: "{{ (value | float * 100) | round(0) }}"
    unit_of_measurement: "mm"

  - platform: mqtt
    name: weather_station_rain24_cm
    unique_id: uniqueid__weather_rain24_cm
    icon: mdi:umbrella
    state_topic: "weather/rain24_cm"
    value_template: "{{ (value | float * 100) | round(0) }}"
    unit_of_measurement: "mm"

  - platform: mqtt
    name: weather_station_hourrain_cm
    unique_id: uniqueid__weather_hourrain_cm
    icon: mdi:umbrella
    state_topic: "weather/hourRain_cm"
    value_template: "{{ (value | float * 100) | round(0) }}"
    unit_of_measurement: "mm/h"

  - platform: mqtt
    name: weather_station_dayrain_cm
    unique_id: uniqueid__weather_dayrain_cm
    icon: mdi:umbrella
    state_topic: "weather/dayRain_cm"
    value_template: "{{ (value | float * 100) | round(0) }}"
    unit_of_measurement: "mm/d"

  #############################################################################

  - platform: mqtt
    name: weather_station_radiation_wpm2
    unique_id: uniqueid__weather_radiation_wpm2
    icon: mdi:radioactive
    state_topic: "weather/radiation_Wpm2"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "watts/m²"

  - platform: mqtt
    name: weather_station_maxsolarrad_wpm2
    unique_id: uniqueid__weather_maxsolarrad_wpm2
    icon: mdi:radioactive
    state_topic: "weather/maxSolarRad_Wpm2"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: "watts/m²"

  - platform: mqtt
    name: weather_station_cloudbase_meter
    unique_id: uniqueid__weather_cloudbase_meter
    state_topic: "weather/cloudbase_meter"
    value_template: "{{ value | round(0) }}"
    unit_of_measurement: "m"

  - platform: mqtt
    name: weather_station_uv
    unique_id: uniqueid__weather_uv
    icon: mdi:sunglasses
    state_topic: "weather/UV"
    value_template: "{{ value | round(1) }}"
    unit_of_measurement: ""

  #############################################################################

  - platform: mqtt
    name: weather_station_weewx_update_datetime
    unique_id: uniqueid__weather_datetime
    icon: mdi:calendar-clock
    state_topic: "weather/dateTime"
    value_template: "{{ value | int | timestamp_local() }}"
    device_class: timestamp

  #############################################################################

homeassistant:
  customize:
    sensor.weather_station_outtemp_c:
      friendly_name: "Ventus W830 Temperatur"
    sensor.weather_station_intemp_c:
      friendly_name: "Ventus W830 Temperatur (innen)"
    sensor.weather_station_dewpoint_c:
      friendly_name: "Ventus W830 Taupunkt"
    sensor.weather_station_indewpoint_c:
      friendly_name: "Ventus W830 Taupunkt (innen)"
    sensor.weather_station_windchill_c:
      friendly_name: "Ventus W830 Windkühle"
    sensor.weather_station_apptemp_c:
      friendly_name: "Ventus W830 gefühlte Temperatur"
    sensor.weather_station_heatindex_c:
      friendly_name: "Ventus W830 Hitzeindex"
    sensor.weather_station_humidex_c:
      friendly_name: "Ventus W830 Luftfeuchte-Index"
    sensor.weather_station_outhumidity:
      friendly_name: "Ventus W830 Luftfeuchte"
    sensor.weather_station_inhumidity:
      friendly_name: "Ventus W830 Luftfeuchte (innen)"
    sensor.weather_station_altimeter_mbar:
      friendly_name: "Ventus W830 Luftdruck (Altimeter, QNH)"
    sensor.weather_station_pressure_mbar:
      friendly_name: "Ventus W830 Luftdruck (Absolut, QFE)"
    sensor.weather_station_barometer_mbar:
      friendly_name: "Ventus W830 Luftdruck (Meeresspiegel, Temperatur, QFF)"
    sensor.weather_station_windspeed_kph:
      friendly_name: "Ventus W830 Windgeschwindigkeit"
    sensor.weather_station_windgust_kph:
      friendly_name: "Ventus W830 Böengeschwindigkeit"
    sensor.weather_station_winddir:
      friendly_name: "Ventus W830 Windrichtung"
    sensor.weather_station_gustdir:
      friendly_name: "Ventus W830 Böenrichtung"
    sensor.weather_station_rainrate_cm_per_hour:
      friendly_name: "Ventus W830 Regenrate"
    sensor.weather_station_rain_cm:
      friendly_name: "Ventus W830 Regen"
    sensor.weather_station_rain24_cm:
      friendly_name: "Ventus W830 Regen (24h)"
    sensor.weather_station_hourrain_cm:
      friendly_name: "Ventus W830 Regen (Stunde)"
    sensor.weather_station_dayrain_cm:
      friendly_name: "Ventus W830 Regen (Tag)"
    sensor.weather_station_radiation_wpm2:
      friendly_name: "Ventus W830 Sonnenstrahlung"
    sensor.weather_station_maxsolarrad_wpm2:
      friendly_name: "Ventus W830 Sonnenstrahlung Maximum"
    sensor.weather_station_cloudbase_meter:
      friendly_name: "Ventus W830 Wolkenuntergrenze"
    sensor.weather_station_uv:
      friendly_name: "Ventus W830 UV-Index"
    sensor.weather_station_weewx_update_datetime:
      friendly_name: "Ventus W830 Letzte Aktualisierung"