shenxn / libdyson

Python library for dyson devices
Apache License 2.0
62 stars 41 forks source link

Add zone support for Dyson 360 Heurist #10

Open pfrybar opened 3 years ago

pfrybar commented 3 years ago

This PR adds support for zones to the Dyson 360 Heurist - https://github.com/shenxn/libdyson/issues/8

Zones are defined in the Dyson Link app and (unfortunately) stored on Dyson servers. You need to call the Dyson API to get a PersistentMap. Then to tell the Heurist to clean a specific zone, you must pass in the id and last updated date of the map, along with the zone ids to be cleaned. This is made easier by the start_zones method which allows you to specify zones by name.

Example:

auth_info = {...}   # setup with proper auth config
heurist_cloud = DysonCloud360Heurist(account=account, serial='XXX-YY-ZZZZZZZZ')
map = heurist_cloud.get_persistent_maps()[0]

heurist = Dyson360Heurist(serial='XXX-YY-ZZZZZZZZ', credential='...')
heurist.connect('1.2.3.4')
heurist.start_zones(map, ['Bedroom', 'Hallway', 'Kitchen'])

I tested this with my Heurist and it works. To see if I could clean a zone without internet, I disabled my internet but left Wifi turned on and opened the Dyson Link app. I could start a full clean but everything related to Zones were disabled. I could not see, edit, or clean any zones. I snooped the MQTT messages to see if the map data is passed anywhere, but unfortunately it is not. This will make integration with HA more difficult.

codecov[bot] commented 3 years ago

Codecov Report

Merging #10 (7f8b838) into main (35d00dd) will decrease coverage by 1.12%. The diff coverage is 72.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #10      +/-   ##
==========================================
- Coverage   97.65%   96.53%   -1.13%     
==========================================
  Files          21       22       +1     
  Lines         940      981      +41     
==========================================
+ Hits          918      947      +29     
- Misses         22       34      +12     
Impacted Files Coverage Δ
libdyson/dyson_360_heurist.py 82.22% <33.33%> (-17.78%) :arrow_down:
libdyson/cloud/cloud_360_heurist.py 85.71% <85.71%> (ø)
libdyson/utils.py 48.14% <100.00%> (+4.14%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 35d00dd...7f8b838. Read the comment docs.