python-homewizard-energy 8.3.2__tar.gz → 9.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 (16) hide show
  1. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/PKG-INFO +8 -4
  2. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/README.md +5 -1
  3. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/homewizard_energy/homewizard_energy.py +4 -0
  4. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/homewizard_energy/models.py +31 -1
  5. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/homewizard_energy/v1/__init__.py +12 -0
  6. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/homewizard_energy/v2/__init__.py +9 -0
  7. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/pyproject.toml +8 -8
  8. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/LICENSE +0 -0
  9. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/homewizard_energy/__init__.py +0 -0
  10. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/homewizard_energy/const.py +0 -0
  11. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/homewizard_energy/errors.py +0 -0
  12. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/homewizard_energy/py.typed +0 -0
  13. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/homewizard_energy/utils.py +0 -0
  14. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/homewizard_energy/v1/const.py +0 -0
  15. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/homewizard_energy/v2/cacert.py +0 -0
  16. {python_homewizard_energy-8.3.2 → python_homewizard_energy-9.0.0b1}/homewizard_energy/v2/const.py +0 -0
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: python-homewizard-energy
3
- Version: 8.3.2
3
+ Version: 9.0.0b1
4
4
  Summary: Asynchronous Python client for the HomeWizard Energy
5
- Home-page: https://github.com/homewizard/python-homewizard-energy
6
5
  License: Apache-2.0
7
6
  Author: DCSBL
8
7
  Maintainer: DCSBL
@@ -21,6 +20,7 @@ Requires-Dist: orjson (>=3.10,<4.0)
21
20
  Project-URL: Bug Tracker, https://github.com/homewizard/python-homewizard-energy/issues
22
21
  Project-URL: Changelog, https://github.com/homewizard/python-homewizard-energy/releases
23
22
  Project-URL: Documentation, https://github.com/homewizard/python-homewizard-energy
23
+ Project-URL: Homepage, https://github.com/homewizard/python-homewizard-energy
24
24
  Project-URL: Repository, https://github.com/homewizard/python-homewizard-energy
25
25
  Description-Content-Type: text/markdown
26
26
 
@@ -49,7 +49,7 @@ python3 -m pip install python-homewizard-energy
49
49
  ### API v1
50
50
  ```python
51
51
  import asyncio
52
- from homewizard_energy import HomeWizardEnergyV1V1
52
+ from homewizard_energy import HomeWizardEnergyV1
53
53
 
54
54
  IP_ADDRESS = "192.168.1.123"
55
55
 
@@ -65,6 +65,10 @@ async def main():
65
65
  measurement = await api.measurement()
66
66
  print(measurement.energy_import_kwh)
67
67
 
68
+ # Example of getting raw telegram data
69
+ telegram = await api.telegram()
70
+ print(telegram) # Raw P1 meter data
71
+
68
72
  # Get all data and remap v1 data to new v2 structure
69
73
  print(await api.combined())
70
74
 
@@ -23,7 +23,7 @@ python3 -m pip install python-homewizard-energy
23
23
  ### API v1
24
24
  ```python
25
25
  import asyncio
26
- from homewizard_energy import HomeWizardEnergyV1V1
26
+ from homewizard_energy import HomeWizardEnergyV1
27
27
 
28
28
  IP_ADDRESS = "192.168.1.123"
29
29
 
@@ -39,6 +39,10 @@ async def main():
39
39
  measurement = await api.measurement()
40
40
  print(measurement.energy_import_kwh)
41
41
 
42
+ # Example of getting raw telegram data
43
+ telegram = await api.telegram()
44
+ print(telegram) # Raw P1 meter data
45
+
42
46
  # Get all data and remap v1 data to new v2 structure
43
47
  print(await api.combined())
44
48
 
@@ -82,6 +82,10 @@ class HomeWizardEnergy:
82
82
  """Get the current measurement."""
83
83
  raise NotImplementedError
84
84
 
85
+ async def telegram(self) -> str:
86
+ """Get the latest telegram."""
87
+ raise NotImplementedError
88
+
85
89
  async def system(
86
90
  self,
87
91
  cloud_enabled: bool | None = None,
@@ -97,6 +97,32 @@ class CombinedModels:
97
97
  self.system = System()
98
98
  self.system.status_led_brightness_pct = (self.state.brightness / 255) * 100
99
99
 
100
+ if self.device.product_type != Model.P1_METER and self.measurement is not None:
101
+ # Remove duplicate 't1' tariff from non-tariff meters
102
+ if (
103
+ self.measurement.energy_import_kwh is not None
104
+ and self.measurement.energy_import_kwh
105
+ == self.measurement.energy_import_t1_kwh
106
+ ):
107
+ self.measurement.energy_import_t1_kwh = None
108
+ if (
109
+ self.measurement.energy_export_kwh is not None
110
+ and self.measurement.energy_export_kwh
111
+ == self.measurement.energy_export_t1_kwh
112
+ ):
113
+ self.measurement.energy_export_t1_kwh = None
114
+
115
+ # Remove duplicate 'power_l1' from 1-phase meters
116
+ # If l2 or l3 is present, keep 'power_l1'
117
+ if (
118
+ self.measurement.power_w is not None
119
+ and self.measurement.power_l2_w is None
120
+ and self.measurement.power_l3_w is None
121
+ and (self.measurement.power_w == self.measurement.power_l1_w)
122
+ ):
123
+ # Remove duplicate 'power_l1_w' when it matches 'power_w' and l2 or l3 is present
124
+ self.measurement.power_l1_w = None
125
+
100
126
 
101
127
  def get_verification_hostname(model: str, serial_number: str) -> str:
102
128
  """Helper method to convert device model and serial to identifier
@@ -142,7 +168,7 @@ class Device(BaseModel):
142
168
 
143
169
  def supports_reboot(self) -> bool:
144
170
  """Return if the device supports reboot."""
145
- return self.api_version.major >= 2
171
+ return self.api_version.major >= 2 and self.product_type != Model.BATTERY
146
172
 
147
173
  def supports_identify(self) -> bool:
148
174
  """Return if the device supports identify."""
@@ -153,6 +179,10 @@ class Device(BaseModel):
153
179
  Model.ENERGY_METER_EASTRON_SDM630,
154
180
  )
155
181
 
182
+ def supports_telegram(self) -> bool:
183
+ """Return if the device supports telegram."""
184
+ return self.product_type == Model.P1_METER
185
+
156
186
 
157
187
  @dataclass(kw_only=True)
158
188
  class Measurement(BaseModel):
@@ -56,6 +56,18 @@ class HomeWizardEnergyV1(HomeWizardEnergy):
56
56
  _, response = await self._request("api/v1/data")
57
57
  return Measurement.from_json(response)
58
58
 
59
+ @optional_method
60
+ async def telegram(self) -> str:
61
+ """Return the most recent, valid telegram that was given by the device.
62
+ The telegram is not processed in any other form.
63
+ If you need parsed data, use the measurement method.
64
+ """
65
+ if self._device is not None and self._device.supports_telegram() is False:
66
+ raise UnsupportedError("Telegram is not supported")
67
+
68
+ _, telegram = await self._request("api/v1/telegram")
69
+ return telegram
70
+
59
71
  @optional_method
60
72
  async def system(
61
73
  self,
@@ -95,6 +95,15 @@ class HomeWizardEnergyV2(HomeWizardEnergy):
95
95
 
96
96
  return measurement
97
97
 
98
+ @authorized_method
99
+ async def telegram(self) -> str:
100
+ """Return the most recent, valid telegram that was given by the device.
101
+ The telegram is not processed in any other form.
102
+ If you need parsed data, use the measurement method.
103
+ """
104
+ _, telegram = await self._request("/api/telegram")
105
+ return telegram
106
+
98
107
  @authorized_method
99
108
  async def system(
100
109
  self,
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-homewizard-energy"
3
- version = "8.3.2"
3
+ version = "9.0.0-beta-1"
4
4
  description = "Asynchronous Python client for the HomeWizard Energy"
5
5
  authors = ["DCSBL"]
6
6
  maintainers = ["DCSBL"]
@@ -29,12 +29,12 @@ awesomeversion = "^24.6.0"
29
29
  aresponses = "^3.0.0"
30
30
  flake8 = "^4.0.1"
31
31
  flake8-docstrings = "^1.7.0"
32
- isort = "^5.13.2"
33
- pre-commit = "^4.0.1"
32
+ isort = "^6.0.1"
33
+ pre-commit = "^4.1.0"
34
34
  pre-commit-hooks = "^5.0.0"
35
- pylint = "^3.3.3"
35
+ pylint = "^3.3.4"
36
36
  pytest = "^8.3.3"
37
- pytest-asyncio = "^0.25.0"
37
+ pytest-asyncio = "^0.25.3"
38
38
  pytest-cov = "^6.0.0"
39
39
  yamllint = "^1.35.1"
40
40
  pyupgrade = "^3.19.0"
@@ -46,12 +46,12 @@ flake8-builtins = "^2.5.0"
46
46
  flake8-comprehensions = "^3.15.0"
47
47
  flake8-eradicate = "^1.2.1"
48
48
  flake8-markdown = "^0.3.0"
49
- ruff = "0.8.4"
49
+ ruff = "0.9.4"
50
50
  darglint = "^1.8.1"
51
51
  safety = "^3.2.10"
52
52
  codespell = "^2.3.0"
53
- bandit = "^1.7.9"
54
- syrupy = "^4.7.2"
53
+ bandit = "^1.8.3"
54
+ syrupy = "^4.8.2"
55
55
 
56
56
  [tool.poetry.urls]
57
57
  "Bug Tracker" = "https://github.com/homewizard/python-homewizard-energy/issues"