Closed jpmens closed 8 years ago
Sorry, this is only half true: when I try and stop with CTL-C (#5) the LWT is then transmitted
devices/xxxxxxxx/$online false
However, $online true
isn't emitted at start.
Hmn, this is strange. For me this works as expected. Do you have any details here?
I will further look into the LWT thing, which I think is related to #5 as the thread is still running somehow.
I definitely don't see it.
1466332655: New connection from ::1 on port 1888.
1466332655: New client connected from ::1 as xxxxxxxx (c1, k10).
1466332655: Sending CONNACK to xxxxxxxx (0, 0)
1466332655: Received SUBSCRIBE from xxxxxxxx
1466332655: devices/xxxxxxxx/# (QoS 0)
1466332655: xxxxxxxx 0 devices/xxxxxxxx/#
1466332655: Sending SUBACK to xxxxxxxx
1466332655: Sending PUBLISH to xxxxxxxx (d0, q0, r1, m0, 'devices/xxxxxxxx/temperature/degrees', ... (4 bytes))
1466332655: Sending PUBLISH to xxxxxxxx (d0, q0, r1, m0, 'devices/xxxxxxxx/humidity/humidity', ... (4 bytes))
1466332655: Sending PUBLISH to xxxxxxxx (d0, q0, r1, m0, 'devices/xxxxxxxx/$uptime', ... (2 bytes))
1466332655: Sending PUBLISH to xxxxxxxx (d0, q0, r1, m0, 'devices/xxxxxxxx/$signal', ... (3 bytes))
1466332655: Sending PUBLISH to xxxxxxxx (d0, q0, r1, m0, 'devices/xxxxxxxx/$online', ... (5 bytes))
The 5 bytes of $online
are false
upon killing the process.
mqttSetup
isn't being invoked here ... I've added a couple of print
s, but I can't say why not ...
$ pip3 install paho-mqtt
$ python3 jp.py
devices/xxxxxxxx/$online true
devices/xxxxxxxx/$name xxxxxxxx
devices/xxxxxxxx/$fwname (null)
devices/xxxxxxxx/$fwversion (null)
devices/xxxxxxxx/$nodes (null)
devices/xxxxxxxx/$localip 127.0.0.1
devices/xxxxxxxx/$uptime 0
devices/xxxxxxxx/$signal 100
😄
I see things with Python3 that I haven't seen with 2.7.
mqttSetup gets invoked, when the mqtt-client calls the on_connect callback function. I have two systems running on Python 2.7 and paho-mqtt 1.2 that seem to work. May it be you are running on paho-mqtt 1.1?
If you enable the debugging mode on temperature_sensor.py logging.basicConfig(level=logging.DEBUG)
, you should see a message like DEBUG:homie.mqtt:connected: True
. If you don't see that mqttSetup will not be called.
For some completely incomprehensibe reason I was indeed. My apologies.
Just a reminder that LWT handling is currently missing.