MQTT to WeewX

285 views
Skip to first unread message

Guido Groetie

unread,
Feb 20, 2022, 6:03:11 AM2/20/22
to weewx-user
I want to add a watertemperature sensor (DS18B01) with a NodeMCU ESP8266 board into weewx, it will be the first MQTT things i will do.

I got the following working:
Beside a RPI with WeewX I have another RPI with Domotizcz.
I got it running that the temp mearurements of the ESP Easy software is getting through Domoticz MQTT into Domoticz (topic: domoticz/in)

So I use the Domoticz RPI as a broker for WeewX.

In the ESP Easy webinterface I see in JSON:

So my fieldname should me temperature
Topic should be: domoticz/in


In WeewX I want the values of meaurements in extraTemp2 place in database. But I see no result in my neo-wx material skin...

Here is a piece of weewx.conf file:
[MQTTSubscribeService]
    # This section is for the MQTTSubscribe service.
    
    # Turn the service on and off.
    # Default is: true
    # Only used by the service.
    enable = true
    
    # The MQTT server.
    # Default is localhost.
    host = 192.168.1.71
    
    # The port to connect to.
    # Default is 1883.
    port = 1883
    
    # Maximum period in seconds allowed between communications with the broker.
    # Default is 60.
    keepalive = 60
    
    # username for broker authentication.
    # Default is None.
    username = admin
    
    # password for broker authentication.
    # Default is None.
    password = wh0racl3
    
    # The binding, loop or archive.
    # Default is: loop
    # Only used by the service.
    binding = loop
    
    # The message handler to use
    [[message_callback]]
        # The format of the MQTT payload.
        # Currently support: individual, json, keyword
        # Must be specified.
        type = json
    
    # The topics to subscribe to.
    [[topics]]
        # Units for MQTT payloads without unit value.
        # Valid values: US, METRIC, METRICWX
        # Default is: US
        unit_system = METRIC
        
        [[[topic/domoticz/in]]]
      [[[[temperature]]]]
            # The WeeWX name.
            # Default is the name from MQTT.
            name = extraTemp2

            # True if the incoming data should not be processed into WeeWX.
            # Valid values: True, False
            # Default is False
            ignore = False

            # True if the incoming data is cumulative.
            # Valid values: True, False
            # Default is False
            contains_total = False

            # The conversion type necessary for WeeWX compatibility
            # Valid values: bool, float, int, none
            # Default is float
            conversion_type = float

            # The units of the incoming data.
            # Useful if this field's units differ from the topic's unit_system's units.
            # Valid values: see, http://www.weewx.com/docs/customizing.htm#units
            # Default is not set
            units = degree_C 

I changed the topic name to something without an / an is now: openwatertemp

in logfile WeewX:
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) Version is 2.0.0
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) Log level: 0
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) Log debug setting: 0
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) Log console: False
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) Log file: None
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) message_callback_provider_name is user.MQTTSubscribe.MessageCallbackProvider
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) clientid is MQTTSubscribe-9039
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) client_session is True
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) host is 192.168.1.71
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) port is 1883
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) keepalive is 60
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) username is admin
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) password is set
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) Archive topic is None
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) binding is loop
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) Waiting for MQTT connection.
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) Connected with result code 0
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) Connected flags {'session present': 0}
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) Subscribing to topic/openwatertemp has a mid 1 and rc 0
Feb 20 11:58:55 weewx weewx[32438] INFO user.MQTTSubscribe: (Service) Subscribed to mid: 1 is size 1 has a QOS of 0

Does rc 0 means that is does not receiving data??

Can somebody help me??

morr...@gmail.com

unread,
Feb 20, 2022, 3:58:17 PM2/20/22
to weewx-user
Could you use mosquitto_sub to ensure the broker is publishing your data in the form you expect? Something like:

mosquitto_sub -h 192.168.1.71 -u admin -P wh0racl3 -t 'domoticz/in/#' -v

bell...@gmail.com

unread,
Feb 20, 2022, 4:49:11 PM2/20/22
to weewx-user
I think the problem is that you have a 'topic/' at the beginning of your topics. Try either [[[domoticz/in]]] or [[[openwatertemp]]], depending on what topic you are publishing to.
rich
Reply all
Reply to author
Forward
0 new messages