libpurecoollink icon indicating copy to clipboard operation
libpurecoollink copied to clipboard

mqtt connection empty queue error

Open LauraFlem opened this issue 5 years ago • 4 comments

I'm getting an error when I try to collect data from the environmental sensors, using the following code in a loop: devices = dyson_account.devices() connected = devices[0].connect("192.168.0.76") env_state=devices[0].environmental_state current_voc = env_state.volatile_organic_compounds devices[0].disconnect()

It works for 4 iterations of my loop and then crashes with the following error:

'File "dyson.py", line 39, in connected = devices[0].connect("192.168.0.76") File "/home/lfleming/anaconda3/lib/python3.6/site-packages/libpurecool/dyson_pure_cool_link.py", line 148, in connect return self._mqtt_connect() File "/home/lfleming/anaconda3/lib/python3.6/site-packages/libpurecool/dyson_pure_cool_link.py", line 159, in _mqtt_connect self._connected = self._connection_queue.get(timeout=10) File "/home/lfleming/anaconda3/lib/python3.6/queue.py", line 172, in get raise Empty queue.Empty'

If anyone has come across this issue or has any ideas how to fix it please let me know!

LauraFlem avatar Apr 18 '19 23:04 LauraFlem

Not sure why would you use loops? Just subscribe to the message. device.add_message_listener(on_message_listener_procedure)

exking avatar Apr 19 '19 16:04 exking

HI there! Thanks for the reply! I'm not really familiar with how to implement message listeners, ive tried to below but I amn't get any values returned:

def update_state(message): env_state=fan.environmental_state current_pm25 = env_state.particulate_matter_25 print(current_pm25)

devices = dyson_account.devices() \n fan = devices[0] \n connected = fan.connect("192.168.0.76") \n fan.add_message_listener(update_state)

Im trying to access the sensor data to feed its values into controller I have designed for a project, so any advice on how to collect this data would be greatly appreciated.

LauraFlem avatar Apr 20 '19 11:04 LauraFlem

Take a look at my project https://github.com/exking/udi-dyson-poly/blob/master/dyson-poly.py DysonPureFan is an example

exking avatar Apr 20 '19 19:04 exking

Hi there! Thank you so much for showing me your project! Would you by any chance have an example of how to use that class to send the commands or call for information? Sorry just trying to figure out how each step works.

LauraFlem avatar Apr 21 '19 12:04 LauraFlem