webdjoe / pyvesync

pyvesync is a python library to manage Etekcity & Levoit smart devices
MIT License
168 stars 77 forks source link

add support for levoit superior 6000S humidifier #216

Closed tkamenick closed 4 months ago

tkamenick commented 7 months ago

Adds support for the Levoit superior 6000S as requested in #214. I own one of these humidifiers and manually tested that all the write apis work. Here's an example of the display method:

Device Name:.................. Humidifier
Model: ....................... LEH-S601S-WUS
Subdevice No: ................ None
Status: ...................... on
Online: ...................... online
Type: ........................ wifi-air
CID: ......................... REDACTED
UUID: ........................ REDACTED
Temperature................... 662
Humidity: .................... 46 percent
Target Humidity............... 50 percent
Mode: ........................ manual
Mist Virtual Level: .......... 1
Mist Level: .................. 1
Water Lacks: ................. False
Water Tank Lifted: ........... False
Display On: .................. True
Filter Life................... 93 percent
Drying Mode Enabled........... True
Drying Mode State............. off
Drying Mode Level............. low
Drying Mode Time Remaining.... 7200 seconds

Happy to update this as requested to get merged. I did a decent amount of copypasta here, for which I apologize in advance.

tkamenick commented 6 months ago

@webdjoe: are you able to take a look at this PR? Thanks!

webdjoe commented 6 months ago

@tkamenick This looks ready to go. I've been refactoring for using the configmodule for device types. Can you test this branch out with VeSync(....debug=True) And post the output?

Schonhoffer commented 5 months ago

@webdjoe Are you saying that you want to base the PR to add 6000S on top of your refactor branch? It looks like you're moving the humid_features into a new file src/pyvesync/vsfanspecs.py ?

akerl commented 5 months ago

I tested this out today via https://github.com/akerl/custom_vesync and it seems like I'm getting two different errors:

Jan 22 16:34:39 hass docker[547982]: 2024-01-22 16:34:39.324 ERROR (MainThread) [homeassistant.components.humidifier] Error while setting up vesync platform for humidifier
Jan 22 16:34:39 hass docker[547982]: Traceback (most recent call last):
Jan 22 16:34:39 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 368, in _async_setup_platform
Jan 22 16:34:39 hass docker[547982]:     await asyncio.gather(*pending)
Jan 22 16:34:39 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
Jan 22 16:34:39 hass docker[547982]:     await asyncio.gather(*tasks)
Jan 22 16:34:39 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
Jan 22 16:34:39 hass docker[547982]:     await entity.add_to_platform_finish()
Jan 22 16:34:39 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1282, in add_to_platform_finish
Jan 22 16:34:39 hass docker[547982]:     self.async_write_ha_state()
Jan 22 16:34:39 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 945, in async_write_ha_state
Jan 22 16:34:39 hass docker[547982]:     self._async_write_ha_state()
Jan 22 16:34:39 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1066, in _async_write_ha_state
Jan 22 16:34:39 hass docker[547982]:     state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
Jan 22 16:34:39 hass docker[547982]:                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jan 22 16:34:39 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1003, in __async_calculate_state
Jan 22 16:34:39 hass docker[547982]:     state = self._stringify_state(available)
Jan 22 16:34:39 hass docker[547982]:             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jan 22 16:34:39 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 951, in _stringify_state
Jan 22 16:34:39 hass docker[547982]:     if (state := self.state) is None:
Jan 22 16:34:39 hass docker[547982]:                  ^^^^^^^^^^
Jan 22 16:34:39 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1557, in state
Jan 22 16:34:39 hass docker[547982]:     if (is_on := self.is_on) is None:
Jan 22 16:34:39 hass docker[547982]:                  ^^^^^^^^^^
Jan 22 16:34:39 hass docker[547982]:   File "/config/custom_components/vesync/humidifier.py", line 140, in is_on
Jan 22 16:34:39 hass docker[547982]:     return self.smarthumidifier.enabled  # device_status is always on
Jan 22 16:34:39 hass docker[547982]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jan 22 16:34:39 hass docker[547982]: AttributeError: 'VeSyncSuperior6000S' object has no attribute 'enabled'

And also:

Jan 22 16:35:08 hass docker[547982]: 2024-01-22 16:35:08.691 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Jan 22 16:35:08 hass docker[547982]: Traceback (most recent call last):
Jan 22 16:35:08 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 243, in _handle_refresh_interval
Jan 22 16:35:08 hass docker[547982]:     await self._async_refresh(log_failures=True, scheduled=True)
Jan 22 16:35:08 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 399, in _async_refresh
Jan 22 16:35:08 hass docker[547982]:     self.async_update_listeners()
Jan 22 16:35:08 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 182, in async_update_listeners
Jan 22 16:35:08 hass docker[547982]:     update_callback()
Jan 22 16:35:08 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 945, in async_write_ha_state
Jan 22 16:35:08 hass docker[547982]:     self._async_write_ha_state()
Jan 22 16:35:08 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1066, in _async_write_ha_state
Jan 22 16:35:08 hass docker[547982]:     state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
Jan 22 16:35:08 hass docker[547982]:                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jan 22 16:35:08 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1003, in __async_calculate_state
Jan 22 16:35:08 hass docker[547982]:     state = self._stringify_state(available)
Jan 22 16:35:08 hass docker[547982]:             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jan 22 16:35:08 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 951, in _stringify_state
Jan 22 16:35:08 hass docker[547982]:     if (state := self.state) is None:
Jan 22 16:35:08 hass docker[547982]:                  ^^^^^^^^^^
Jan 22 16:35:08 hass docker[547982]:   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1557, in state
Jan 22 16:35:08 hass docker[547982]:     if (is_on := self.is_on) is None:
Jan 22 16:35:08 hass docker[547982]:                  ^^^^^^^^^^
Jan 22 16:35:08 hass docker[547982]:   File "/config/custom_components/vesync/switch.py", line 208, in is_on
Jan 22 16:35:08 hass docker[547982]:     return self.device.config["automatic_stop"]
Jan 22 16:35:08 hass docker[547982]:            ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
Jan 22 16:35:08 hass docker[547982]: KeyError: 'automatic_stop'