python-hilo 2025.12.5__tar.gz → 2026.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.
Files changed (21) hide show
  1. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/PKG-INFO +1 -1
  2. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/const.py +1 -1
  3. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/event.py +15 -3
  4. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyproject.toml +1 -1
  5. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/LICENSE +0 -0
  6. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/README.md +0 -0
  7. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/__init__.py +0 -0
  8. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/api.py +0 -0
  9. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/device/__init__.py +0 -0
  10. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/device/climate.py +0 -0
  11. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/device/graphql_value_mapper.py +0 -0
  12. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/device/light.py +0 -0
  13. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/device/sensor.py +0 -0
  14. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/device/switch.py +0 -0
  15. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/devices.py +0 -0
  16. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/exceptions.py +0 -0
  17. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/graphql.py +0 -0
  18. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/oauth2helper.py +0 -0
  19. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/util/__init__.py +0 -0
  20. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/util/state.py +0 -0
  21. {python_hilo-2025.12.5 → python_hilo-2026.1.1}/pyhilo/websocket.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-hilo
3
- Version: 2025.12.5
3
+ Version: 2026.1.1
4
4
  Summary: A Python3, async interface to the Hilo API
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -7,7 +7,7 @@ import aiohttp
7
7
  LOG: Final = logging.getLogger(__package__)
8
8
  DEFAULT_STATE_FILE: Final = "hilo_state.yaml"
9
9
  REQUEST_RETRY: Final = 9
10
- PYHILO_VERSION: Final = "2025.12.05"
10
+ PYHILO_VERSION: Final = "2026.1.01"
11
11
  # TODO: Find a way to keep previous line in sync with pyproject.toml automatically
12
12
 
13
13
  CONTENT_TYPE_FORM: Final = "application/x-www-form-urlencoded"
@@ -1,4 +1,5 @@
1
- """Event object """
1
+ """Event object"""
2
+
2
3
  from datetime import datetime, timedelta, timezone
3
4
  import logging
4
5
  import re
@@ -26,7 +27,7 @@ class Event:
26
27
 
27
28
  def __init__(self, **event: dict[str, Any]):
28
29
  """Initialize."""
29
- self._convert_phases(cast(dict[str, Any], event.get("phases")))
30
+ self._convert_phases(cast(dict[str, Any], event.get("phases", {})))
30
31
  params: dict[str, Any] = event.get("parameters") or {}
31
32
  devices: list[dict[str, Any]] = params.get("devices", [])
32
33
  consumption: dict[str, Any] = event.get("consumption", {})
@@ -34,7 +35,7 @@ class Event:
34
35
  used_wH: int = consumption.get("currentWh", 0) or 0
35
36
  self.participating: bool = cast(bool, event.get("isParticipating", False))
36
37
  self.configurable: bool = cast(bool, event.get("isConfigurable", False))
37
- self.period: str = cast(str, event.get("period", ""))
38
+ self.period: str = (cast(str, event.get("period", "")) or "").lower()
38
39
  self.event_id: int = cast(int, event["id"])
39
40
  self.total_devices: int = len(devices)
40
41
  self.opt_out_devices: int = len([x for x in devices if x["optOut"]])
@@ -44,6 +45,7 @@ class Event:
44
45
  self.allowed_kWh: float = round(allowed_wH / 1000, 2)
45
46
  self.used_kWh: float = round(used_wH / 1000, 2)
46
47
  self.used_percentage: float = 0
48
+ self.reward = cast(float, event.get("reward", 0.0))
47
49
  self.last_update = datetime.now(timezone.utc).astimezone()
48
50
  if allowed_wH > 0:
49
51
  self.used_percentage = round(used_wH / allowed_wH * 100, 2)
@@ -63,6 +65,7 @@ class Event:
63
65
  "used_kWh",
64
66
  "used_percentage",
65
67
  "last_update",
68
+ "reward",
66
69
  ]
67
70
 
68
71
  def update_wh(self, used_wH: float) -> None:
@@ -70,12 +73,21 @@ class Event:
70
73
  LOG.debug("Updating Wh: %s", used_wH)
71
74
  self.used_kWh = round(used_wH / 1000, 2)
72
75
  self.last_update = datetime.now(timezone.utc).astimezone()
76
+ self._recalculate_percentage()
73
77
 
74
78
  def update_allowed_wh(self, allowed_wH: float) -> None:
75
79
  """This function is used to update the allowed_kWh attribute during a Hilo Challenge Event"""
76
80
  LOG.debug("Updating allowed Wh: %s", allowed_wH)
77
81
  self.allowed_kWh = round(allowed_wH / 1000, 2)
78
82
  self.last_update = datetime.now(timezone.utc).astimezone()
83
+ self._recalculate_percentage()
84
+
85
+ def _recalculate_percentage(self) -> None:
86
+ """Recalculate used percentage based on current values"""
87
+ if self.allowed_kWh > 0:
88
+ self.used_percentage = round(self.used_kWh / self.allowed_kWh * 100, 2)
89
+ else:
90
+ self.used_percentage = 0
79
91
 
80
92
  def should_check_for_allowed_wh(self) -> bool:
81
93
  """This function is used to authorize subscribing to a specific event in Hilo to receive the allowed_kWh
@@ -40,7 +40,7 @@ exclude = ".venv/.*"
40
40
 
41
41
  [tool.poetry]
42
42
  name = "python-hilo"
43
- version = "2025.12.5"
43
+ version = "2026.1.1"
44
44
  description = "A Python3, async interface to the Hilo API"
45
45
  readme = "README.md"
46
46
  authors = ["David Vallee Delisle <me@dvd.dev>"]
File without changes