home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.31k stars 30.62k forks source link

dyson.py unable to handle "OFF" humidity state #8569

Closed TheBrickster closed 7 years ago

TheBrickster commented 7 years ago

Home Assistant release (hass --version): 0.49.0

Python release (python3 --version): Python 3.5.2

Component/platform: Dyson

Description of problem: dyson.py script is expecting a numeric value for the "humidity sensor" reading, however when provided with "OFF" the script crashes and HASS does not load.

Expected: It is expected that the dyson.py script can cope with the status provided by the humidity sensor and allow HASS to load without issue.

Problem-relevant configuration.yaml entries and steps to reproduce:

dyson:
  username: XXX
  password: XXX
  language: GB
  devices:
    - device_id: PE9-UK-XXXXXXXX
      device_ip: 192.168.86.32

Traceback (if applicable):

Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/ollie/.homeassistant/deps/paho/mqtt/client.py", line 2606, in _thread_main
    self.loop_forever(retry_first_connection=True)
  File "/Users/ollie/.homeassistant/deps/paho/mqtt/client.py", line 1470, in loop_forever
    rc = self.loop(timeout, max_packets)
  File "/Users/ollie/.homeassistant/deps/paho/mqtt/client.py", line 995, in loop
    rc = self.loop_read(max_packets)
  File "/Users/ollie/.homeassistant/deps/paho/mqtt/client.py", line 1273, in loop_read
    rc = self._packet_read()
  File "/Users/ollie/.homeassistant/deps/paho/mqtt/client.py", line 1838, in _packet_read
    rc = self._packet_handle()
  File "/Users/ollie/.homeassistant/deps/paho/mqtt/client.py", line 2285, in _packet_handle
    return self._handle_publish()
  File "/Users/ollie/.homeassistant/deps/paho/mqtt/client.py", line 2456, in _handle_publish
    self._handle_on_message(message)
  File "/Users/ollie/.homeassistant/deps/paho/mqtt/client.py", line 2603, in _handle_on_message
    self.on_message(self, self._userdata, message)
  File "/Users/ollie/.homeassistant/deps/libpurecoollink/dyson.py", line 267, in on_message
    device_msg = DysonEnvironmentalSensorState(payload)
  File "/Users/ollie/.homeassistant/deps/libpurecoollink/dyson.py", line 679, in __init__
    self._humidity = int(self.__get_field_value(data, 'hact'))
ValueError: invalid literal for int() with base 10: 'OFF'

Additional info: Discussed on https://community.home-assistant.io/t/dyson-link-action-and-sensor/10145/65

The fix was to edit the file /components/dyson.py

and update the line

REQUIREMENTS = ['libpurecoollink==0.2.0']

With

REQUIREMENTS = ['libpurecoollink==0.3.0']

bachya commented 7 years ago

Based on there being a fix that you've identified, are you comfortable making the change and submitting a PR?

CharlesBlonde commented 7 years ago

I confirm the issue and I'll submit a PR soon.

One possible other workaround is to enable continuous monitoringon the Dyson devices (not tested yet, can not confirm).

TheBrickster commented 7 years ago

Hi Charles, I am unable to comment on the HA forum - apparently a 3 post limit for newbies...

I've turned on continuous monitoring, and after a short while the dashboard reflected that the humidity detected is 49% (the same as reported in my app).

Also, to check that it was a viable workaround, I left continuous monitoring switched on, and reverted the setting back to

REQUIREMENTS = ['libpurecoollink==0.2.0']

I was able to start HASS without any issues.

However, for my purposes, I will switch it back to 0.3.0 so I don't need to leave continuous monitoring switched on.

CharlesBlonde commented 7 years ago

Sorry for the delay, I just submit a PR to fix this issue if devices are configured with standby monitoring disable.