Skip to content

Commit

Permalink
Merge pull request #94 from kitprice/master
Browse files Browse the repository at this point in the history
Fix support for Core 300S
  • Loading branch information
webdjoe authored Oct 29, 2021
2 parents 52bb2a9 + 32f255f commit a157537
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 66 deletions.
66 changes: 33 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pyvesync is a library to manage VeSync compatible [smart home devices](#supporte
- [Tunable Smart Light Bulb Methods and Properties](#tunable-smart-light-bulb-methods-and-properties)
- [Dimmable Switch Methods and Properties](#dimmable-switch-methods-and-properties)
- [Levoit Humidifier 300S Methods and Properties](#levoit-humidifier-300s-methods-and-properties)
- [Levoit Purifier Core200S/300S Methods and Properties](#levoit-purifier-core200s300s-methods-and-properties)
- [Levoit Purifier Core400S Methods and Properties](#levoit-purifier-core400s-methods-and-properties)
- [Levoit Purifier Core200S Methods and Properties](#levoit-purifier-core200s-methods-and-properties)
- [Levoit Purifier Core300S/400S Methods and Properties](#levoit-purifier-core300s400s-methods-and-properties)
- [JSON Output API](#json-output-api)
- [JSON Output for All Devices](#json-output-for-all-devices)
- [JSON Output for Outlets](#json-output-for-outlets)
Expand Down Expand Up @@ -269,65 +269,65 @@ VeSyncHumid300S.config = {

`VeSyncHumid300S.set_mist_level(4)` Set mist output 1 - 9

### Levoit Purifier Core200S/300S Methods and Properties
### Levoit Purifier Core200S Methods and Properties

`VeSyncAir200S300S.change_fan_speed(2)` 1|2|3 or call without argument to increment by one
`VeSyncAir200S.change_fan_speed(2)` 1|2|3 or call without argument to increment by one

`VeSyncAir200S300S.child_lock_on()` Enable child lock
`VeSyncAir200S.child_lock_on()` Enable child lock

`VeSyncAir200S300S.child_lock_off()` Disable child lock
`VeSyncAir200S.child_lock_off()` Disable child lock

`VeSyncAir200S300S.turn_on_display()` Turn display on
`VeSyncAir200S.turn_on_display()` Turn display on

`VeSyncAir200S300S.turn_off_display()` Turn display off
`VeSyncAir200S.turn_off_display()` Turn display off

`VeSyncAir200S300S.sleep_mode()` - Change mode to sleep
`VeSyncAir200S.sleep_mode()` - Change mode to sleep

`VeSyncAir200S300S.manual_mode()` - Change mode to manual
`VeSyncAir200S.manual_mode()` - Change mode to manual

`VeSyncAir200S300S.set_night_light('on'|'dim'|'off')` - Set night light brightness
`VeSyncAir200S.set_night_light('on'|'dim'|'off')` - Set night light brightness

`VeSyncAir200S300S.fan_level()` - Return the level of the fan (1-3)
`VeSyncAir200S.fan_level()` - Return the level of the fan (1-3)

`VeSyncAir200S300S.filter_life()` - Return the percentage of filter life remaining
`VeSyncAir200S.filter_life()` - Return the percentage of filter life remaining

`VeSyncAir200S300S.display_state()` - Return the state of the display (True=On/False=off)
`VeSyncAir200S.display_state()` - Return the state of the display (True=On/False=off)

`VeSyncAir200S300S.child_lock()` - Return the state of the child lock (True=On/False=off)
`VeSyncAir200S.child_lock()` - Return the state of the child lock (True=On/False=off)

`VeSyncAir200S300S.night_light()` - Return the state of the night light (on/dim/off)
`VeSyncAir200S.night_light()` - Return the state of the night light (on/dim/off)

### Levoit Purifier Core400S Methods and Properties
### Levoit Purifier Core300S/400S Methods and Properties

`VeSyncAir400S.change_fan_speed(2)` 1|2|3|4 or call without argument to increment by one
`VeSyncAir300S400S.change_fan_speed(2)` 1|2|3|4 or call without argument to increment by one

`VeSyncAir400S.child_lock_on()` Enable child lock
`VeSyncAir300S400S.child_lock_on()` Enable child lock

`VeSyncAir400S.child_lock_off()` Disable child lock
`VeSyncAir300S400S.child_lock_off()` Disable child lock

`VeSyncAir400S.turn_on_display()` Turn display on
`VeSyncAir300S400S.turn_on_display()` Turn display on

`VeSyncAir400S.turn_off_display()` Turn display off
`VeSyncAir300S400S.turn_off_display()` Turn display off

`VeSyncAir400S.sleep_mode()` - Change mode to sleep
`VeSyncAir300S400S.sleep_mode()` - Change mode to sleep

`VeSyncAir400S.manual_mode()` - Change mode to manual
`VeSyncAir300S400S.manual_mode()` - Change mode to manual

`VeSyncAir400S.auto_mode()` - Change mode to auto
`VeSyncAir300S400S.auto_mode()` - Change mode to auto

`VeSyncAir400S.set_night_light('on'|'dim'|'off')` - Set night light brightness
`VeSyncAir300S400S.set_night_light('on'|'dim'|'off')` - Set night light brightness

`VeSyncAir400S.fan_level()` - Return the level of the fan (1-4)
`VeSyncAir300S400S.fan_level()` - Return the level of the fan (1-4)

`VeSyncAir400S.filter_life()` - Return the percentage of filter life remaining
`VeSyncAir300S400S.filter_life()` - Return the percentage of filter life remaining

`VeSyncAir400S.air_quality()` - Return the air quality (PM 2.5 - ug/m3)
`VeSyncAir300S400S.air_quality()` - Return the air quality (PM 2.5 - ug/m3)

`VeSyncAir400S.display_state()` - Return the state of the display (True=On/False=off)
`VeSyncAir300S400S.display_state()` - Return the state of the display (True=On/False=off)

`VeSyncAir400S.child_lock()` - Return the state of the child lock (True=On/False=off)
`VeSyncAir300S400S.child_lock()` - Return the state of the child lock (True=On/False=off)

`VeSyncAir400S.night_light()` - Return the state of the night light (on/dim/off)
`VeSyncAir300S400S.night_light()` - Return the state of the night light (on/dim/off)

### JSON Output API

Expand Down Expand Up @@ -443,7 +443,7 @@ This output only applies to dimmable switch. The standard switch has the defaul
}
```

#### JSON Output for Core400S Purifier
#### JSON Output for 400S Purifier

```python
{
Expand Down
2 changes: 1 addition & 1 deletion src/pyvesync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
VeSyncOutdoorPlug,
)
from .vesyncswitch import VeSyncWallSwitch, VeSyncDimmerSwitch
from .vesyncfan import VeSyncAir131, VeSyncAir200S300S, VeSyncAir400S
from .vesyncfan import VeSyncAir131, VeSyncAir200S, VeSyncAir300S400S
from .vesyncbulb import VeSyncBulbESL100
import logging

Expand Down
10 changes: 5 additions & 5 deletions src/pyvesync/vesync.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from pyvesync.vesyncfan import (
VeSyncAir131,
VeSyncHumid300S,
VeSyncAir200S300S,
VeSyncAir400S,
VeSyncAir200S,
VeSyncAir300S400S,
)
from pyvesync.vesyncoutlet import (
VeSyncOutlet7A,
Expand Down Expand Up @@ -45,9 +45,9 @@
'ESL100CW': VeSyncBulbESL100CW,
'ESWD16': VeSyncDimmerSwitch,
'Classic300S': VeSyncHumid300S,
'Core200S': VeSyncAir200S300S,
'Core300S': VeSyncAir200S300S,
'Core400S': VeSyncAir400S,
'Core200S': VeSyncAir200S,
'Core300S': VeSyncAir300S400S,
'Core400S': VeSyncAir300S400S,
}

_DEVICE_TYPES_DICT: Dict[str, List[str]] = dict(
Expand Down
54 changes: 27 additions & 27 deletions src/pyvesync/vesyncfan.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
logger = logging.getLogger(__name__)


class VeSyncAir200S300S(VeSyncBaseDevice):
"""Core200S/300S Purifier Class."""
class VeSyncAir200S(VeSyncBaseDevice):
"""Core200S Purifier Class."""

def __init__(self, details, manager):
"""Initilize Core200S/300S Purifier class."""
"""Initilize Core200S Purifier class."""
super().__init__(details, manager)
self.enabled = True
self.details: Dict[str, Union[str, int, float, bool]] = {
Expand All @@ -32,7 +32,7 @@ def __init__(self, details, manager):
}

def __build_api_dict(self, method: str) -> Tuple[Dict, Dict]:
"""Build Core200S/300S api call header and body.
"""Build Core200S api call header and body.
Available methods are: 'getPurifierStatus', 'setSwitch',
'setNightLight', 'setLevel', 'setDisplay'
Expand All @@ -55,7 +55,7 @@ def __build_api_dict(self, method: str) -> Tuple[Dict, Dict]:
return head, body

def build_purifier_dict(self, dev_dict: Dict):
"""Build Core200S/300S purifier status dictionary."""
"""Build Core200S purifier status dictionary."""
self.enabled = dev_dict.get('enabled')
if self.enabled:
self.device_status = 'on'
Expand All @@ -72,13 +72,13 @@ def build_purifier_dict(self, dev_dict: Dict):
False)

def build_config_dict(self, conf_dict):
"""Build configuration dict for Core200S/300S purifier."""
"""Build configuration dict for Core200S purifier."""
self.config['display'] = conf_dict.get('display', False)
self.config['display_forever'] = conf_dict.get('display_forever',
False)

def get_details(self) -> None:
"""Build Core200S/300S Purifier details dictionary."""
"""Build Core200S Purifier details dictionary."""
head = Helpers.bypass_header()
body = Helpers.bypass_body_v2(self.manager)
body['cid'] = self.cid
Expand Down Expand Up @@ -113,7 +113,7 @@ def get_details(self) -> None:
logger.debug('Error in purifier response')

def update(self):
"""Update Core200S/300S Purifier details."""
"""Update Core200S Purifier details."""
self.get_details()

@property
Expand Down Expand Up @@ -172,28 +172,28 @@ def toggle_switch(self, toggle: bool) -> bool:

if Helpers.code_check(r):
return True
logger.debug("Error toggling Core200S/300S purifier - %s",
logger.debug("Error toggling Core200S purifier - %s",
self.device_name)
return False

def turn_on(self) -> bool:
"""Turn Core200S/300S Purifier on."""
"""Turn Core200S Purifier on."""
return self.toggle_switch(True)

def turn_off(self):
"""Turn Core200S/300S Purifier off."""
"""Turn Core200S Purifier off."""
return self.toggle_switch(False)

def child_lock_on(self) -> bool:
"""Turn Core200S/300S child lock on."""
"""Turn Core200S child lock on."""
return self.set_child_lock(True)

def child_lock_off(self) -> bool:
"""Turn Core200S/300S child lock off."""
"""Turn Core200S child lock off."""
return self.set_child_lock(False)

def set_child_lock(self, mode: bool) -> bool:
"""Set Core200S/300S child lock."""
"""Set Core200S child lock."""
if mode not in (True, False):
logger.debug('Invalid mode passed to set_child_lock - %s', mode)
return False
Expand Down Expand Up @@ -243,7 +243,7 @@ def set_display(self, mode: bool) -> bool:

if Helpers.code_check(r):
return True
logger.debug("Error toggling Core200S/300S display - %s",
logger.debug("Error toggling Core200S display - %s",
self.device_name)
return False

Expand Down Expand Up @@ -406,11 +406,11 @@ def displayJSON(self) -> str:
return json.dumps(sup_val)


class VeSyncAir400S(VeSyncBaseDevice):
"""Core400S Purifier Class."""
class VeSyncAir300S400S(VeSyncBaseDevice):
"""Core300S/400S Purifier Class."""

def __init__(self, details, manager):
"""Initilize Core400S Purifier class."""
"""Initilize Core300S/400S Purifier class."""
super().__init__(details, manager)
self.enabled = True
self.details: Dict[str, Union[str, int, float, bool]] = {
Expand All @@ -428,7 +428,7 @@ def __init__(self, details, manager):
}

def __build_api_dict(self, method: str) -> Tuple[Dict, Dict]:
"""Build Core400S api call header and body.
"""Build Core300S/400S api call header and body.
Available methods are: 'getPurifierStatus', 'setSwitch',
'setNightLight', 'setLevel', 'setDisplay'
Expand All @@ -451,7 +451,7 @@ def __build_api_dict(self, method: str) -> Tuple[Dict, Dict]:
return head, body

def build_purifier_dict(self, dev_dict: Dict):
"""Build Core400S purifier status dictionary."""
"""Build Core300S/400S purifier status dictionary."""
self.enabled = dev_dict.get('enabled')
if self.enabled:
self.device_status = 'on'
Expand All @@ -475,7 +475,7 @@ def build_config_dict(self, conf_dict):
False)

def get_details(self) -> None:
"""Build Core400S Purifier details dictionary."""
"""Build Core300S/400S Purifier details dictionary."""
head = Helpers.bypass_header()
body = Helpers.bypass_body_v2(self.manager)
body['cid'] = self.cid
Expand Down Expand Up @@ -511,7 +511,7 @@ def get_details(self) -> None:
logger.debug('Error in purifier response')

def update(self):
"""Update Core400S Purifier details."""
"""Update Core300S/400S Purifier details."""
self.get_details()

@property
Expand Down Expand Up @@ -583,23 +583,23 @@ def toggle_switch(self, toggle: bool) -> bool:
return False

def turn_on(self) -> bool:
"""Turn Core400S Purifier on."""
"""Turn Core300S/400S Purifier on."""
return self.toggle_switch(True)

def turn_off(self):
"""Turn Core400S Purifier off."""
"""Turn Core300S/400S Purifier off."""
return self.toggle_switch(False)

def child_lock_on(self) -> bool:
"""Turn Core400S child lock on."""
"""Turn Core300S/400S child lock on."""
return self.set_child_lock(True)

def child_lock_off(self) -> bool:
"""Turn Core400S child lock off."""
"""Turn Core300S/400S child lock off."""
return self.set_child_lock(False)

def set_child_lock(self, mode: bool) -> bool:
"""Set Core400S child lock."""
"""Set Core300S/400S child lock."""
if mode not in (True, False):
logger.debug('Invalid mode passed to set_child_lock - %s', mode)
return False
Expand Down

0 comments on commit a157537

Please sign in to comment.