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.

1 Like

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: