CharlesBlonde / libpurecoollink

Dyson Pure Cool link python library
http://libpurecoollink.readthedocs.io
Other
206 stars 53 forks source link

mqtt connection empty queue error #25

Open LauraFlem opened 5 years ago

LauraFlem commented 5 years ago

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!

exking commented 5 years ago

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

LauraFlem commented 5 years ago

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.

exking commented 5 years ago

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

LauraFlem commented 5 years ago

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.