python-homewizard-energy 8.0.0a6__tar.gz → 8.0.0b1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (15) hide show
  1. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/PKG-INFO +12 -7
  2. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/README.md +11 -6
  3. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/homewizard_energy/models.py +11 -0
  4. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/pyproject.toml +1 -1
  5. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/LICENSE +0 -0
  6. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/homewizard_energy/__init__.py +0 -0
  7. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/homewizard_energy/const.py +0 -0
  8. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/homewizard_energy/errors.py +0 -0
  9. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/homewizard_energy/homewizard_energy.py +0 -0
  10. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/homewizard_energy/py.typed +0 -0
  11. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/homewizard_energy/v1/__init__.py +0 -0
  12. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/homewizard_energy/v1/const.py +0 -0
  13. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/homewizard_energy/v2/__init__.py +0 -0
  14. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/homewizard_energy/v2/cacert.py +0 -0
  15. {python_homewizard_energy-8.0.0a6 → python_homewizard_energy-8.0.0b1}/homewizard_energy/v2/const.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-homewizard-energy
3
- Version: 8.0.0a6
3
+ Version: 8.0.0b1
4
4
  Summary: Asynchronous Python client for the HomeWizard Energy
5
5
  Home-page: https://github.com/homewizard/python-homewizard-energy
6
6
  License: Apache-2.0
@@ -44,6 +44,8 @@ python3 -m pip install python-homewizard-energy
44
44
  ```
45
45
 
46
46
  ## Example
47
+
48
+ ### API v1
47
49
  ```python
48
50
  import asyncio
49
51
  from homewizard_energy import HomeWizardEnergyV1V1
@@ -55,15 +57,18 @@ async def main():
55
57
 
56
58
  async with HomeWizardEnergyV1(host=IP_ADDRESS) as api:
57
59
 
58
- # Get device information, like firmware version
60
+ # Get device information, like firmware version
59
61
  print(await api.device())
60
62
 
61
- # Get measurements, like energy or water usage
62
- data = await api.data()
63
- print(data.total_energy_import_kwh)
63
+ # Get measurements, like energy or water usage
64
+ measurement = await api.measurement()
65
+ print(measurement.energy_import_kwh)
66
+
67
+ # Get all data and remap v1 data to new v2 structure
68
+ print(await api.combined())
64
69
 
65
- # Turn on the Energy Socket outlet
66
- await api.state_set(power_on=True)
70
+ # Turn on the Energy Socket outlet
71
+ await api.state(power_on=True)
67
72
 
68
73
 
69
74
  asyncio.run(main())
@@ -19,6 +19,8 @@ python3 -m pip install python-homewizard-energy
19
19
  ```
20
20
 
21
21
  ## Example
22
+
23
+ ### API v1
22
24
  ```python
23
25
  import asyncio
24
26
  from homewizard_energy import HomeWizardEnergyV1V1
@@ -30,15 +32,18 @@ async def main():
30
32
 
31
33
  async with HomeWizardEnergyV1(host=IP_ADDRESS) as api:
32
34
 
33
- # Get device information, like firmware version
35
+ # Get device information, like firmware version
34
36
  print(await api.device())
35
37
 
36
- # Get measurements, like energy or water usage
37
- data = await api.data()
38
- print(data.total_energy_import_kwh)
38
+ # Get measurements, like energy or water usage
39
+ measurement = await api.measurement()
40
+ print(measurement.energy_import_kwh)
41
+
42
+ # Get all data and remap v1 data to new v2 structure
43
+ print(await api.combined())
39
44
 
40
- # Turn on the Energy Socket outlet
41
- await api.state_set(power_on=True)
45
+ # Turn on the Energy Socket outlet
46
+ await api.state(power_on=True)
42
47
 
43
48
 
44
49
  asyncio.run(main())
@@ -432,6 +432,17 @@ class Measurement(BaseModel):
432
432
 
433
433
  return d
434
434
 
435
+ @classmethod
436
+ def __post_deserialize__(cls, obj: Measurement) -> Measurement:
437
+ """Post deserialize hook for Measurement object."""
438
+ _ = cls # Unused
439
+
440
+ # Some smart meters report a tariff other than 1, 2, 3 or 4, which is invalid
441
+ if obj.tariff not in (1, 2, 3, 4):
442
+ obj.tariff = None
443
+
444
+ return obj
445
+
435
446
 
436
447
  @dataclass(kw_only=True)
437
448
  class ExternalDevice(BaseModel):
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-homewizard-energy"
3
- version = "8.0.0-alpha-6"
3
+ version = "8.0.0-beta-1"
4
4
  description = "Asynchronous Python client for the HomeWizard Energy"
5
5
  authors = ["DCSBL"]
6
6
  maintainers = ["DCSBL"]