Skip to content

Commit c44011a

Browse files
authored
Merge pull request #261 from webdjoe/bump-2.1.14
Bump 2.1.14
2 parents b1fbd9b + 529fb7f commit c44011a

File tree

6 files changed

+83
-23
lines changed

6 files changed

+83
-23
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ pyvesync.und
3535
mkdocs.yml
3636
requirements-docs.txt
3737
docs/
38-
site/
38+
site/
39+
overrides/

CONTRIBUTING.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Setting up the Development Environment
1+
# Contributing to the pyvesync Library
2+
3+
## Setting up the Development Environment
24

35
1. Git clone the repository
46

@@ -33,7 +35,7 @@ If the above steps were executed successfully, you should now have:
3335
Any change in the code will now be directly reflected and can be tested. To deactivate the python venv, simply
3436
run `deactivate`.
3537

36-
# Testing Python with Tox
38+
## Testing Python with Tox
3739

3840
Install tox, navigate to the pyvesync repository which contains the tox.ini file, and run tox as follows:
3941

@@ -48,12 +50,12 @@ tox -e lint # flake8 & pydocstrings
4850
tox -e mypy # type checkings
4951
```
5052

51-
Tests are run based off of the API calls recorded in the [api](src/tests/api) directory. Please read the [Test Readme](src/tests/README.md) for further details on the structure of the tests.
53+
Tests are run based off of the API calls recorded in the [api](src/tests/api) directory. Please read the [Test Readme](src/tests/README.md) for further details on the structure of the tests.
5254

5355

5456
# Ensure new devices are Integrated in Tests
5557

56-
If you integrate a new device, please read the [testing README](tests/README.md) to ensure that your device is tested.
58+
If you integrate a new device, please read the [testing README](src/tests/README.md) to ensure that your device is tested.
5759

5860
## Testing with pytest and Writing API to YAML
5961

@@ -85,4 +87,4 @@ If fixing an existing device where the API call was incorrect or the api has cha
8587
pytest --write_api --overwrite
8688

8789
tox -e testenv -- --write_api --overwrite
88-
```
90+
```

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name='pyvesync',
13-
version='2.1.13',
13+
version='2.1.14',
1414
description='pyvesync is a library to manage Etekcity\
1515
Devices, Cosori Air Fryers and Levoit Air \
1616
Purifiers run on the VeSync app.',

src/pyvesync/vesyncbulb.py

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Note:
1717
The bulb module is built from the `feature_dict` dictionary and used by the
1818
`vesync.object_factory` and tests to determine the class to instantiate for
19-
each bulb model.
19+
each bulb model. These classes should not be instantiated manually.
2020
2121
Examples:
2222
The following example shows the structure of the `feature_dict` dictionary:
@@ -48,6 +48,8 @@
4848

4949
NUMERIC_T = Optional[Union[int, float, str]]
5050

51+
# --8<-- [start:feature_dict]
52+
5153
feature_dict: dict = {
5254
'ESL100':
5355
{
@@ -75,10 +77,11 @@
7577
}
7678
}
7779

80+
# --8<-- [end:feature_dict]
7881

7982
bulb_modules: dict = {k: v['module'] for k, v in feature_dict.items()}
8083

81-
__all__: list = list(bulb_modules.values()) + ['bulb_modules']
84+
__all__: list = list(bulb_modules.values()) + ["bulb_modules", "VeSyncBulb"]
8285

8386

8487
def pct_to_kelvin(pct: float, max_k: int = 6500, min_k: int = 2700) -> float:
@@ -91,7 +94,8 @@ class VeSyncBulb(VeSyncBaseDevice):
9194
9295
Abstract base class to provide methods for controlling and
9396
getting details of VeSync bulbs. Inherits from
94-
[`VeSyncBaseDevice`][pyvesync.vesyncbasedevice.VeSyncBaseDevice].
97+
[`VeSyncBaseDevice`][pyvesync.vesyncbasedevice.VeSyncBaseDevice]. This class
98+
should not be used directly for devices, but rather subclassed for each.
9599
96100
Attributes:
97101
brightness (int): Brightness of bulb (0-100).
@@ -539,7 +543,26 @@ def display(self) -> None:
539543
print(f'{line[0]:.<30} {line[1]} {line[2]}')
540544

541545
def displayJSON(self) -> str:
542-
"""Return bulb device info in JSON format."""
546+
"""Return bulb device info in JSON format.
547+
548+
Returns:
549+
str: JSON formatted string of bulb details.
550+
551+
Example:
552+
```json
553+
{
554+
"deviceName": "Bulb",
555+
"deviceStatus": "on",
556+
"connectionStatus": "online",
557+
"Brightness": "100%",
558+
"WhiteTemperaturePct": "100%",
559+
"WhiteTemperatureKelvin": "6500K",
560+
"ColorHSV": "{"hue": 0, "saturation": 0, "value": 0}",
561+
"ColorRGB": "{"red": 0, "green": 0, "blue": 0}",
562+
"ColorMode": "hsv"
563+
}
564+
```
565+
"""
543566
sup = super().displayJSON()
544567
sup_val = json.loads(sup)
545568
if self.connection_status == 'online':
@@ -595,25 +618,24 @@ class VeSyncBulbESL100MC(VeSyncBulb):
595618
two named tuple attributes - `hsv` & `rgb`. See [pyvesync.helpers.Color][].
596619
597620
Notes:
598-
The `self.details` dictionary is structured as follows:
621+
The details dictionary contains the device information retreived by the
622+
`update()` method:
599623
```python
600-
>>> self.details
601-
{
602-
'brightness': 0,
603-
'colorMode': 'color',
604-
'red': 0,
605-
'green': 0,
606-
'blue': 0
624+
details = {
625+
'brightness': 50,
626+
'colorMode': 'rgb',
627+
'color' : Color(red=0, green=0, blue=0)
607628
}
608629
```
630+
See pyvesync.helpers.Color for more information on the Color dataclass.
609631
"""
610632

611633
def __init__(self, details: dict[str, str | list], manager: VeSync) -> None:
612634
"""Instantiate ESL100MC Multicolor Bulb.
613635
614636
Args:
615637
details (dict): Dictionary of bulb state details.
616-
manager (VeSync): Manager class used to make API calls
638+
manager (VeSync): Manager class used to make API calls.
617639
"""
618640
super().__init__(details, manager)
619641
self.details: dict = {}
@@ -811,7 +833,8 @@ def toggle(self, status: str) -> bool:
811833
class VeSyncBulbESL100(VeSyncBulb):
812834
"""Object to hold VeSync ESL100 light bulb.
813835
814-
This bulb only has the dimmable feature.
836+
This bulb only has the dimmable feature. Inherits from pyvesync.vesyncbulb.VeSyncBulb
837+
and pyvesync.vesyncbasedevice.VeSyncBaseDevice.
815838
816839
Attributes:
817840
details (dict): Dictionary of bulb state details.

src/pyvesync/vesyncswitch.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1-
"""Classes for VeSync Switch Devices."""
1+
"""Classes for VeSync Switch Devices.
2+
3+
This module provides classes for VeSync Switch Devices:
4+
5+
1. VeSyncSwitch: Abstract Base class for VeSync Switch Devices.
6+
2. VeSyncWallSwitch: Class for VeSync Wall Switch Devices ESWL01 and ESWL03.
7+
3. VeSyncDimmerSwitch: Class for VeSync Dimmer Switch Devices ESWD16.
8+
9+
10+
Attributes:
11+
feature_dict (dict): Dictionary of switch models and their supported features.
12+
Defines the class to use for each switch model and the list of features
13+
switch_modules (dict): Dictionary of switch models as keys and their associated
14+
classes as string values.
15+
16+
Note:
17+
The switch device is built from the `feature_dict` dictionary and used by the
18+
`vesync.object_factory` during initial call to pyvesync.vesync.update() and
19+
determines the class to instantiate for each switch model. These classes should
20+
not be instantiated manually.
21+
"""
222

323
import logging
424
import json
@@ -10,6 +30,8 @@
1030

1131
logger = logging.getLogger(__name__)
1232

33+
# --8<-- [start:feature_dict]
34+
1335
feature_dict: Dict[str, Dict[str, Union[list, str]]] = {
1436
'ESWL01': {
1537
'module': 'VeSyncWallSwitch',
@@ -25,14 +47,25 @@
2547
}
2648
}
2749

50+
# --8<-- [end:feature_dict]
51+
2852
switch_modules: dict = {k: v['module']
2953
for k, v in feature_dict.items()}
3054

3155
__all__: list = list(switch_modules.values()) + ['switch_modules']
3256

3357

3458
class VeSyncSwitch(VeSyncBaseDevice):
35-
"""Etekcity Switch Base Class."""
59+
"""Etekcity Switch Base Class.
60+
61+
Abstract Base Class for Etekcity Switch Devices, inherting from
62+
pyvesync.vesyncbasedevice.VeSyncBaseDevice. Should not be instantiated directly,
63+
subclassed by VeSyncWallSwitch and VeSyncDimmerSwitch.
64+
65+
Attributes:
66+
features (list): List of features supported by the switch device.
67+
details (dict): Dictionary of switch device details.
68+
"""
3669

3770
__metaclasss__ = ABCMeta
3871

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ ignore_errors = True
2626
deps =
2727
mypy
2828
types-requests
29+
allowlist_externals = mypy
2930
commands = mypy src/pyvesync

0 commit comments

Comments
 (0)