etheralm / libpurecool

Python library for dyson devices.
Other
68 stars 30 forks source link

Error "invalid literal for int() with base 10: 'INIT'" in Home Assistant #35

Open cjmjmartens opened 3 years ago

cjmjmartens commented 3 years ago

In Home Assistant, I get the following error often: unhandled exception for the Dyson integration:

Source: /usr/src/homeassistant/homeassistant/bootstrap.py:310 First occurred: 21:10:31 (1 occurrences) Last logged: 21:10:31

Uncaught thread exception Traceback (most recent call last): File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/local/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3452, in _thread_main self.loop_forever(retry_first_connection=True) File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1779, in loop_forever rc = self.loop(timeout, max_packets) File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1181, in loop rc = self.loop_read(max_packets) File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1572, in loop_read rc = self._packet_read() File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 2310, in _packet_read rc = self._packet_handle() File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 2936, in _packet_handle return self._handle_publish() File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3216, in _handle_publish self._handle_on_message(message) File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3444, in _handle_on_message self.on_message(self, self._userdata, message) File "/usr/local/lib/python3.8/site-packages/libpurecool/dyson_pure_cool_link.py", line 106, in on_message device_msg = DysonEnvironmentalSensorState(payload) File "/usr/local/lib/python3.8/site-packages/libpurecool/dyson_pure_state.py", line 122, in init self._dust = int(self.__get_field_value(data, 'pact')) ValueError: invalid literal for int() with base 10: 'INIT'

Raamkonijn commented 3 years ago

I've had the same problem with libpurecool + HP02. I'm not experienced with python/git, but i've managed to make it work on Ubuntu 20.04 + Python 3.8.5.

git clone https://github.com/bfayers/libpurecool.git
cd libpurecool/
git checkout fix_auth

Now edit the file ./libpurecool/libpurecool/dyson_pure_state.py line 117/118:

self._volatil_compounds = 0 if volatil_copounds == 'INIT' else int(
            volatil_copounds)

to

self._volatil_compounds = 0 if volatil_copounds == 'INIT' else str(
            volatil_copounds)

and edit line 122: self._dust = int(self.__get_field_value(data, 'pact')) to self._dust = str(self.__get_field_value(data, 'pact'))

and install sudo python3 setup.py install

I don't know how Home Assistent works, but you could try to edit /usr/local/lib/python3.8/site-packages/libpurecool/dyson_pure_state.py and make the same changes I did.