Oh, make sure you connect as a different client if you use that monitoring
script. Otherwise it will take all the traffic from weewx!

On Mon, Feb 20, 2017 at 6:44 PM, Bill Morrow <morro...@gmail.com> wrote:

> Frederic, these two lines you have highlighted
>         self.username = stn_dict.get('username', 'XXX')
>         self.password = stn_dict.get('password', 'password')
> should pick up the username and password from the python "dictionary
> <https://learnpythonthehardway.org/book/ex39.html>" that is populated
> when weewx reads your weewx.conf file on startup.
>
> Do you get any sort of error message, either from weewx or Mosquitto? In
> weewx.conf, you can set
>
>> # Set to 1 for extra debug info, otherwise comment it out or set to zero.
>> debug = 1
>
> and it will log much more information about what it is doing.
>
> Try adding this line right after the two highlighted
>         self.username = stn_dict.get('username', 'XXX')
>         self.password = stn_dict.get('password', 'password')
>         logdbg("Set username to %s and password to %s" % (self.username,
> self.password))
>
> In Mosquitto, you have to explicitly set logging to go to syslog,
> otherwise it is only to stdout. Also, I recall having problems with the
> wrong version of the MQTT protocol when I started. I might have had to
> build a newer version of Mosquitto manually, instead of using the one which
> came with the running version of the OS.
>
> I'm attaching a small python script which should watch everything going
> through your Mosquitto broker.
>
> On Mon, Feb 20, 2017 at 5:24 PM, wysiwyg <fst...@gmail.com> wrote:
>
>> Bill,
>>
>> I have some troubles to make the driver work.
>> While look at the code, I have the feeling that the username / password
>> from weewx.conf are not used ?
>>
>> I tried something, but seems not working better.
>>
>> here is my test (it's based on other lines of the driver, I try to do
>> something similar, but as I said, I know nothing about python)
>>
>>
>>  def __init__(self, **stn_dict):
>>         # where to find the data file
>>         self.host = stn_dict.get('host', 'localhost')
>>         self.topic = stn_dict.get('topic', 'weather')
>>         self.username = stn_dict.get('username', 'XXX')
>>         self.password = stn_dict.get('password', 'password')
>>         # how often to poll the weather data file, seconds
>>         self.poll_interval = float(stn_dict.get('poll_interval', 5.0))
>>         # mapping from variable names to weewx names
>>         self.label_map = stn_dict.get('label_map', {})
>>
>>
>>         loginf("host is %s" % self.host)
>>         loginf("topic is %s" % self.topic)
>>         loginf("polling interval is %s" % self.poll_interval)
>>         loginf('label map is %s' % self.label_map)
>>
>>
>>         self.payload = "Empty"
>>         #self.payloadList = [payload]
>>         self.client = mqtt.Client(client_id="XXX", protocol=mqtt.MQTTv31)
>>
>>
>>         #self.client.on_connect = self.on_connect
>>         self.client.on_message = self.on_message
>>
>>
>>         self.client.username_pw_set(self.username, self.password)
>>         self.client.connect(self.host, 1883, 60)
>>         self.client.subscribe(self.topic, qos=1)
>>
>>
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "weewx-user" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/weewx-user/zhl4I7oRtt8/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> weewx-user+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to