python-homewizard-energy 6.0.0b1__tar.gz → 6.1.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-homewizard-energy
3
- Version: 6.0.0b1
3
+ Version: 6.1.1
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
@@ -53,10 +53,15 @@ async def main():
53
53
 
54
54
  async with HomeWizardEnergy(host=IP_ADDRESS) as api:
55
55
 
56
- print(await api.device()) # Get device information, like firmware version
57
- print(await api.data()) # Get measurements, like power or water usage
56
+ # Get device information, like firmware version
57
+ print(await api.device())
58
58
 
59
- await api.state_set(power_on=True) # Turn on the Energy Socket outlet
59
+ # Get measurements, like energy or water usage
60
+ data = await api.data()
61
+ print(data.total_energy_import_kwh)
62
+
63
+ # Turn on the Energy Socket outlet
64
+ await api.state_set(power_on=True)
60
65
 
61
66
 
62
67
  asyncio.run(main())
@@ -30,10 +30,15 @@ async def main():
30
30
 
31
31
  async with HomeWizardEnergy(host=IP_ADDRESS) as api:
32
32
 
33
- print(await api.device()) # Get device information, like firmware version
34
- print(await api.data()) # Get measurements, like power or water usage
33
+ # Get device information, like firmware version
34
+ print(await api.device())
35
35
 
36
- await api.state_set(power_on=True) # Turn on the Energy Socket outlet
36
+ # Get measurements, like energy or water usage
37
+ data = await api.data()
38
+ print(data.total_energy_import_kwh)
39
+
40
+ # Turn on the Energy Socket outlet
41
+ await api.state_set(power_on=True)
37
42
 
38
43
 
39
44
  asyncio.run(main())
@@ -1,5 +1,6 @@
1
1
  """HomeWizard Energy API library."""
2
2
 
3
+ from .brand import Product
3
4
  from .errors import DisabledError, InvalidStateError, RequestError, UnsupportedError
4
5
  from .homewizard_energy import HomeWizardEnergy
5
6
  from .models import Data, Device, ExternalDevice, State, System
@@ -15,4 +16,5 @@ __all__ = [
15
16
  "ExternalDevice",
16
17
  "State",
17
18
  "System",
19
+ "Product",
18
20
  ]
@@ -0,0 +1,95 @@
1
+ """Brand specific information for HomeWizard Energy."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class Product:
10
+ """Represent a product."""
11
+
12
+ model: str
13
+ name: str | None
14
+ url: str | None
15
+ description: str | None
16
+
17
+ def __str__(self):
18
+ """Return a string representation of the product."""
19
+ return f"HomeWizard {self.name} - {self.model}"
20
+
21
+ def __hash__(self):
22
+ """Hash a product for unit-test snapshots."""
23
+ return hash((self.model, self.name, self.url, self.description))
24
+
25
+ def __eq__(self, other):
26
+ """Compare two products."""
27
+ if isinstance(other, Product):
28
+ return (
29
+ self.model == other.model
30
+ and self.name == other.name
31
+ and self.url == other.url
32
+ and self.description == other.description
33
+ )
34
+ return False
35
+
36
+
37
+ PRODUCTS = {
38
+ Product(
39
+ "HWE-P1",
40
+ "Wi-Fi P1 Meter",
41
+ "https://www.homewizard.com/p1-meter/",
42
+ "The HomeWizard P1 Meter gives you detailed insight in your electricity-, gas consumption and solar surplus.",
43
+ ),
44
+ Product(
45
+ "HWE-SKT",
46
+ "Wi-Fi Energy Socket",
47
+ "https://www.homewizard.com/energy-socket/",
48
+ "Measure and switch every device.",
49
+ ),
50
+ Product(
51
+ "HWE-WTR",
52
+ "Wi-Fi Watermeter",
53
+ "https://www.homewizard.com/watermeter/",
54
+ "Real-time water consumption insights",
55
+ ),
56
+ Product(
57
+ "HWE-KWH1",
58
+ "Wi-Fi kWh Meter 1-phase",
59
+ "https://www.homewizard.com/kwh-meter/",
60
+ "Measure solar panels, car chargers and more.",
61
+ ),
62
+ Product(
63
+ "HWE-KWH3",
64
+ "Wi-Fi kWh Meter 3-phase",
65
+ "https://www.homewizard.com/kwh-meter/",
66
+ "Measure solar panels, car chargers and more.",
67
+ ),
68
+ Product(
69
+ "SDM230-wifi",
70
+ "Wi-Fi kWh Meter 1-phase",
71
+ "https://www.homewizard.com/kwh-meter/",
72
+ "Measure solar panels, car chargers and more.",
73
+ ),
74
+ Product(
75
+ "SDM630-wifi",
76
+ "Wi-Fi kWh Meter 3-phase",
77
+ "https://www.homewizard.com/kwh-meter/",
78
+ "Measure solar panels, car chargers and more.",
79
+ ),
80
+ }
81
+
82
+
83
+ def from_type(product_type: str, _: str | None = None) -> Product | None:
84
+ """Return a Product object from a type.
85
+
86
+ :param type: The type of the product.
87
+ :param locale: The locale to use for the description. Currently ignored. Should be an ISO 639-1 language code.
88
+ """
89
+
90
+ # pylint: disable=unused-argument
91
+
92
+ for product in PRODUCTS:
93
+ if product.model == product_type:
94
+ return product
95
+ return None
@@ -8,11 +8,14 @@ from datetime import datetime
8
8
  from enum import Enum
9
9
  from typing import Any
10
10
 
11
+ from .brand import Product, from_type
12
+
11
13
 
12
14
  @dataclass
13
15
  class Device:
14
16
  """Represent Device config."""
15
17
 
18
+ product: Product | None
16
19
  product_name: str | None
17
20
  product_type: str | None
18
21
  serial: str | None
@@ -30,6 +33,7 @@ class Device:
30
33
  A Device object.
31
34
  """
32
35
  return Device(
36
+ product=from_type(data.get("product_type")),
33
37
  product_name=data.get("product_name"),
34
38
  product_type=data.get("product_type"),
35
39
  serial=data.get("serial"),
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-homewizard-energy"
3
- version = "6.0.0-beta-1"
3
+ version = "6.1.1"
4
4
  description = "Asynchronous Python client for the HomeWizard Energy"
5
5
  authors = ["DCSBL"]
6
6
  maintainers = ["DCSBL"]
@@ -23,30 +23,30 @@ async-timeout = "^4.0.3"
23
23
  [tool.poetry.dev-dependencies]
24
24
  aresponses = "^3.0.0"
25
25
  black = "^24.4"
26
- blacken-docs = "^1.16.0"
26
+ blacken-docs = "^1.18.0"
27
27
  flake8 = "^4.0.1"
28
28
  flake8-docstrings = "^1.7.0"
29
29
  isort = "^5.13.2"
30
- pre-commit = "^3.6.0"
31
- pre-commit-hooks = "^4.5.0"
30
+ pre-commit = "^3.7.1"
31
+ pre-commit-hooks = "^4.6.0"
32
32
  pylint = "^3.1.0"
33
33
  pytest = "^7.4.4"
34
- pytest-asyncio = "^0.23.6"
35
- pytest-cov = "^4.1.0"
36
- yamllint = "^1.33.0"
37
- pyupgrade = "^3.15.2"
34
+ pytest-asyncio = "^0.23.7"
35
+ pytest-cov = "^5.0.0"
36
+ yamllint = "^1.35.1"
37
+ pyupgrade = "^3.16.0"
38
38
  flake8-simplify = "^0.21.0"
39
39
  vulture = "^2.11"
40
40
  flake8-bandit = "^3.0.0"
41
41
  flake8-bugbear = "^23.3.12"
42
- flake8-builtins = "^2.2.0"
43
- flake8-comprehensions = "^3.14.0"
42
+ flake8-builtins = "^2.5.0"
43
+ flake8-comprehensions = "^3.15.0"
44
44
  flake8-eradicate = "^1.2.1"
45
45
  flake8-markdown = "^0.3.0"
46
46
  darglint = "^1.8.1"
47
47
  safety = "^3.0.1"
48
- codespell = "^2.2.6"
49
- bandit = "^1.7.7"
48
+ codespell = "^2.3.0"
49
+ bandit = "^1.7.9"
50
50
  syrupy = "^4.6.0"
51
51
 
52
52
  [tool.poetry.urls]