Dyson Link Action and Sensor

OK, so… Ive reinstalled and reconfigured. Not getting any errors as before and the modules load up and connect to dyson with my user/pass combination

However.
I decided to try my wifes account with the 2 purifiers and the 360 on it. It connected ok, but it was still looking for the device on the other account.

Is there somewhere in HA that stores previously detected devices? That seems to be the case
Can I get rid of those cached device ID’s?

Putting in support for two accounts is not really something people will need, so every time I switch accounts for testing, Im happy to clear down the cached entries

If there are no cached device ID’s, then im not sure what is happening and why it is picking up the previously detected devices (and failing)

Thanks

Hey Charles, i see you’ve been working hard. Too bad it didn’t make it in 0.46.
I will give your lastest version a test and see the improvements myself.

Keep up the good work!

I didn’t answer since a few days but I continued working on the component.

@SebasT Like you said, version 0.46 has just been released this Week end. It’s a shame but now I have 2 more weeks to add features/improve the component :slight_smile:
I just updated the frontend panel to add auto/night mode as new toggle and not anymore like a speed (event if for AUTO mode, both are working) : https://github.com/home-assistant/home-assistant-polymer/pull/300

it’s working quite well but I’m now unable to tell you how to test because many files has been updated (I had to update Fan parent entity) and the frontend has been updated too (another Git repo and I can’t explain how to build this part :confused: ). So I’m afraid you’ll have to wait for the next release (I hope, if it is accepted) to be able to use the latest version.

@elPaulio I don’t understand how it is possible for the component to look for devices from another account. To my knowledge there is no cache at all on this part. It is really strange. If I provide you a Python script to run, will you be able to provide me the outputs? The workflow will be the following:

  • Cloning a git repo and switch to a dedicated branch
  • Updating the script to set the Dyson account credentials
  • Running the script with Python 3.4+
  • Providing me the outputs after having removing sensible data (credentials). Maybe in private mode.

I would like to be able to understand the devices linked to the accounts and how the 360 robot is available. I’m planning to buy this robot but only in a few weeks.

sure can - no worries :slight_smile:

Congrats Charles! Great job!
I see the dyson component made it to 0.47.
It’s working great despite two errors in the log

Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/srv/hass/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 368, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/srv/hass/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 223, in async_add_entity
yield from entity.async_added_to_hass()
File “/usr/lib/python3.5/asyncio/coroutines.py”, line 206, in coro
res = func(*args, **kw)
File “/srv/hass/lib/python3.5/site-packages/homeassistant/components/sensor/dyson.py”, line 41, in async_added_to_hass
self._device.add_message_listener(self.on_message))
File “/srv/hass/lib/python3.5/site-packages/homeassistant/core.py”, line 210, in async_add_job
elif is_callback(target):
File “/srv/hass/lib/python3.5/site-packages/homeassistant/core.py”, line 78, in is_callback
return ‘_hass_callback’ in func.dict
AttributeError: ‘NoneType’ object has no attribute ‘dict

Hi @SebasT

Yes, it has been released in version 0.47 ! But… I haven’t had time to test it yet (I’m still using and old development version).
I have to test in order to check for the error. Reading the logs, it’s seems to be an error with the filter life sensor. At least the fan itself seems to be working fine and it is the most important.

Ah alright, I see.
Well still great job and filter life also seem to be working. Made an automation right away to notify me to replace the filter :sunglasses:

Here’s the second error

Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/srv/hass/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 368, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/srv/hass/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 223, in async_add_entity
yield from entity.async_added_to_hass()
File “/usr/lib/python3.5/asyncio/coroutines.py”, line 206, in coro
res = func(*args, **kw)
File “/srv/hass/lib/python3.5/site-packages/homeassistant/components/fan/dyson.py”, line 78, in async_added_to_hass
self._device.add_message_listener(self.on_message))
File “/srv/hass/lib/python3.5/site-packages/homeassistant/core.py”, line 210, in async_add_job
elif is_callback(target):
File “/srv/hass/lib/python3.5/site-packages/homeassistant/core.py”, line 78, in is_callback
return ‘_hass_callback’ in func.dict
AttributeError: ‘NoneType’ object has no attribute ‘dict

I fixed the issues for the logs (https://github.com/home-assistant/home-assistant/pull/8113).
But it seems there is another error for a least one user.

@SebasT Are you able to get it working ? And some other users ?

At this time, I can’t understand what can be the issue and I can’t explain this behavior …

After patching my code base as suggested here (github defect report), I am still not seeing my Dyson Cool Link Air Purifier initialized correctly.

I have the following configuration.yaml entries:

dyson:
  username: !secret dyson_username
  password: !secret dyson_password
  language: !secret dyson_language
  devices:
    - device_id: !secret dyson_device_id_1
      device_ip: !secret dyson_device_ip_1

I have enabled the following debug logging:

 homeassistant.components.dyson: debug
 homeassistant.components.sensor.dyson: debug
 homeassistant.components.fan.dyson: debug

and the logs generate the following output:

> 2017-06-19 16:48:24 INFO (SyncWorker_8) [homeassistant.components.dyson] Creating new Dyson component
> 2017-06-19 16:48:25 INFO (SyncWorker_8) [homeassistant.components.dyson] Connected to Dyson account
> 2017-06-19 16:48:26 INFO (SyncWorker_8) [homeassistant.components.dyson] Connected to device DysonDevice(XXX-XX-XXXXXXXX,True,Purifier Cool Tower,21.03.08,True,False,475,NetworkDevice(Purifier Cool Tower,192.168.5.9,1883))
> 2017-06-19 16:48:26 DEBUG (SyncWorker_8) [homeassistant.components.dyson] Starting sensor/fan components
> 2017-06-19 16:48:26 INFO (SyncWorker_4) [homeassistant.components.sensor.dyson] Creating new Dyson fans
> 2017-06-19 16:48:26 INFO (SyncWorker_0) [homeassistant.components.fan.dyson] Creating new Dyson fans
> 2017-06-19 16:48:26 INFO (SyncWorker_0) [homeassistant.components.fan.dyson] Creating device Purifier Cool Tower

which looks fine to me, however, I only see the following entities in the developer tools, which seem to indicate it’s not pulling data from the device:

fan.purifier_cool_tower off speed_list: AUTO,1,2,3,4,5,6,7,8,9,10
friendly_name: Purifier Cool Tower
supported_features: 3

sensor.purifier_cool_tower_filter_life unknown unit_of_measurement: hours
friendly_name: Purifier Cool Tower filter life

Hi @rwlove and thanks for the feedback.

The outputs seems fine and it exactly what it is supposed to be. Except that you should have except that you should have other kinds of messages like this one:

2017-06-20 07:42:57 DEBUG (Thread-2) [homeassistant.components.fan.dyson] Message received for fan device Salon : DysonState(OFF,OFF,OFF,0010,OFF,0882,0004,ON)

Who means your are receiving status update from the device. In your case your are not receiving any update and it’s not the expected behavior.

One test you can try: can you use the mobile app (iOS/Android) and update the configuration (change speed, turn oscillation ON/OFF, etc …). Do you see any messages in Home Assistant logs ? What mobile app are you using ? iOS ? Android ?

If not, it can mean 2 things:

  • I have not subscribe to the right MQTT topic => The messages are not seen
  • The MQTT messages haven’t the excepted format => The messages are discard

I’ll be able to provide you some unit tests to do if you agree in order to help me to troubleshoot this issue because this behavior was not expected at all.

Sorry for the inconvenience …

One other possible test: can you start Home Assistant without specifying the devices block ? Just:

dyson:
  username: !secret dyson_username
  password: !secret dyson_password
  language: !secret dyson_language

It should use discovery in this case (mDNS)

I tried changing the oscillation off and on as well as changing the power from auto to on and off through the Android Dyson app, but it didn’t update the HASS entities.

I’d be happy to try some unit tests.

I removed the devices block and I hit this exception:

2017-06-20 07:36:36 INFO (SyncWorker_2) [homeassistant.components.dyson] Creating new Dyson component
2017-06-20 07:36:36 ERROR (MainThread) [homeassistant.setup] Error during setup of component dyson
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/setup.py”, line 190, in _async_setup_component
component.setup, hass, processed_config)
File “/usr/local/lib/python3.6/asyncio/futures.py”, line 331, in iter
yield self # This tells Task to wait for completion.
File “/usr/local/lib/python3.6/asyncio/tasks.py”, line 244, in _wakeup
future.result()
File “/usr/local/lib/python3.6/asyncio/futures.py”, line 244, in result
raise self._exception
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/dyson.py”, line 46, in setup
from libpurecoollink.dyson import DysonAccount
File “/usr/local/lib/python3.6/site-packages/libpurecoollink/dyson.py”, line 18, in
from .zeroconf import ServiceBrowser, Zeroconf
File “/usr/local/lib/python3.6/site-packages/libpurecoollink/zeroconf.py”, line 40, in
from six.moves import xrange
ModuleNotFoundError: No module named ‘six.moves’; ‘six’ is not a package

I just restarted HASS and I did not get the same ‘six’ exception, however, it still looks like I’m not getting any updates from the device. I tried forcing an event by changing settings in the Android app, but still no updates to the HASS UI.

thanks @rwlove for all of this feedback. Unfortunately it just confirm the previous issue :confused:

The next step will be quite more complex but I hope it will help me to understand the issue. The goal is to test the underlying library and display some useful debugging information. I created a new branch with a test script. The following commands can be used on the Home Assistant device itself (SSH) but feel free to run it where you want if you feel comfortable with Git/Python/vi/…:

$ cd /tmp
$ git clone https://github.com/CharlesBlonde/libpurecoollink.git
$ cd libpurecoollink
$ git checkout troubleshooting
$ python3 -m venv /tmp/libpurecoollink/.venv
$ pip install -r requirements.txt # Can be quite long because it has to compile some crypto libraries
$ nano troubleshooting.py # Edit variables with your Dyson account and device IP address
$ python troubleshooting.py # Run the tests

The script will run for less than 2 minutes and I would like to have the outputs. It will contains quite sensitive data like Device ID. You can send me a private message if you prefer.

With this outputs, I hope I’ll be able ton understand what is happening.

Thanks again for your help !

Thanks to @rwlove help, we have been able to resolve the issue and no additional update is needed.

So to my knowledge, the first release of the component should be working with basic features:

  • Turn On/Off
  • Set Speed (Auto mode is considered as a Speed)
  • Turn On/Off oscillating

Regarding Night mode, it is implemented as an Home Assistant service dyson_set_night_mode with parameters:

  • entity_id: “home assistant entity id”
  • night_mode: true/false

This service is not in the documentation because I refactor this feature between the first PR and the merge and I totally forgot to update the documentation :confused:. But I will maybe refactor this service in next release so it can be an advantage for me: it will not be a breaking change if it’s not documented and nobody is using this feature :smile: . So you can use this service but be careful with next releases.

The next feature I want to implement:

  • Official night mode support
  • Sleep timer
  • Set air quality target for auto mode (Normal, High, Better)

New sensors:

  • Humidity (%)
  • Temperature
  • Dust (unknown metric, only an integer value)

All this feature must be available as an Home Assistant service but also in the UI so it will take a few time to be implemented. No expected date for the PR release (and neither for the Home Assistant release of course).

Dyson devices support other features but I don’t think I’ll implement them in Home Assistant:

  • Reset filter life timer (4000 hours).
  • Enable/Disable environmental sensor while the device is in standby
  • volatil organic compounds (I don’t know exactly what it means)

Do you think this feature must be implemented in Home Assistant ? For me this feature are not really important but I can be wrong.

@CharlesBlonde
I upgraded to 0.47.1 and the errors are gone. So once again Great job!

Thanks for progress so far @CharlesBlonde. I have access to a Dyson 360 Eye and can help with debugging and implementing that. just let me know how I can help.

Has anyone done any scripting that controls the oscillate attribute?

I have configured a Google Home to voice control the on and off of the fan but I’ve never changed an attribute state in a script before so I wouldn’t mind a hand if possible.

@michael.muir There is a service in order to turn on/off oscillating:

script:
  oscillate:
    - service: fan.oscillate
      data:
        entity_id: fan.living_room
        oscillating: true # or false