python-homewizard-energy 10.0.0b1__tar.gz → 10.0.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 (16) hide show
  1. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/PKG-INFO +1 -1
  2. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/homewizard_energy/models.py +33 -18
  3. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/pyproject.toml +1 -1
  4. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/LICENSE +0 -0
  5. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/README.md +0 -0
  6. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/homewizard_energy/__init__.py +0 -0
  7. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/homewizard_energy/const.py +0 -0
  8. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/homewizard_energy/errors.py +0 -0
  9. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/homewizard_energy/homewizard_energy.py +0 -0
  10. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/homewizard_energy/py.typed +0 -0
  11. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/homewizard_energy/utils.py +0 -0
  12. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/homewizard_energy/v1/__init__.py +0 -0
  13. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/homewizard_energy/v1/const.py +0 -0
  14. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/homewizard_energy/v2/__init__.py +0 -0
  15. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/homewizard_energy/v2/cacert.py +0 -0
  16. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.0.1}/homewizard_energy/v2/const.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-homewizard-energy
3
- Version: 10.0.0b1
3
+ Version: 10.0.1
4
4
  Summary: Asynchronous Python client for the HomeWizard Energy
5
5
  License: Apache-2.0
6
6
  License-File: LICENSE
@@ -192,9 +192,9 @@ class Device(BaseModel):
192
192
  return None
193
193
 
194
194
  modes = [
195
- Batteries.Mode.ZERO,
196
- Batteries.Mode.TO_FULL,
197
195
  Batteries.Mode.STANDBY,
196
+ Batteries.Mode.TO_FULL,
197
+ Batteries.Mode.ZERO,
198
198
  ]
199
199
 
200
200
  if self.api_version >= AwesomeVersion("2.2.0"):
@@ -701,8 +701,8 @@ class Batteries(BaseModel):
701
701
  "deserialize": lambda x: Batteries.Mode.__members__.get(x.upper(), None)
702
702
  },
703
703
  )
704
- permissions: list[Permissions] = field(
705
- default_factory=list,
704
+ permissions: list[Permissions] | None = field(
705
+ default=None,
706
706
  metadata={
707
707
  "deserialize": lambda lst: [
708
708
  perm
@@ -710,6 +710,8 @@ class Batteries(BaseModel):
710
710
  if (perm := Batteries.Permissions.__members__.get(item.upper(), None))
711
711
  is not None
712
712
  ]
713
+ if lst is not None
714
+ else None
713
715
  },
714
716
  )
715
717
  power_w: float = field()
@@ -720,21 +722,34 @@ class Batteries(BaseModel):
720
722
 
721
723
  @classmethod
722
724
  def __post_deserialize__(cls, obj: Batteries) -> Batteries:
723
- """Set correct mode based on permissions after deserialization."""
725
+ """Set correct mode based on permissions after deserialization.
726
+ If permissions is missing and mode is ZERO, keep mode as ZERO for backwards compatibility.
727
+ If permissions is present (even if empty), apply the mapping logic.
728
+ """
724
729
  # Only adjust if mode is ZERO
725
- if obj.mode == cls.Mode.ZERO:
726
- perms = set(obj.permissions)
727
- if perms == {cls.Permissions.CHARGE_ALLOWED}:
728
- obj.mode = cls.Mode.ZERO_CHARGE_ONLY
729
- elif perms == {cls.Permissions.DISCHARGE_ALLOWED}:
730
- obj.mode = cls.Mode.ZERO_DISCHARGE_ONLY
731
- elif perms == {
732
- cls.Permissions.CHARGE_ALLOWED,
733
- cls.Permissions.DISCHARGE_ALLOWED,
734
- }:
735
- obj.mode = cls.Mode.ZERO
736
- elif perms == set():
737
- obj.mode = cls.Mode.STANDBY
730
+ if obj.mode != cls.Mode.ZERO:
731
+ return obj
732
+
733
+ # Detect if 'permissions' was present in the original data
734
+ # If using mashumaro, the original dict is not available here, so we infer:
735
+ # If permissions is None, treat as 'not provided'. If it's an empty list, treat as 'provided but empty'.
736
+ if obj.permissions is None:
737
+ # Permissions not provided, keep mode as ZERO (backwards compatibility)
738
+ return obj
739
+
740
+ perms = set(obj.permissions)
741
+ if perms == {cls.Permissions.CHARGE_ALLOWED}:
742
+ obj.mode = cls.Mode.ZERO_CHARGE_ONLY
743
+ elif perms == {cls.Permissions.DISCHARGE_ALLOWED}:
744
+ obj.mode = cls.Mode.ZERO_DISCHARGE_ONLY
745
+ elif perms == {
746
+ cls.Permissions.CHARGE_ALLOWED,
747
+ cls.Permissions.DISCHARGE_ALLOWED,
748
+ }:
749
+ obj.mode = cls.Mode.ZERO
750
+ elif perms == set():
751
+ obj.mode = cls.Mode.STANDBY
752
+
738
753
  return obj
739
754
 
740
755
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-homewizard-energy"
3
- version = "10.0.0-beta-1"
3
+ version = "10.0.1"
4
4
  description = "Asynchronous Python client for the HomeWizard Energy"
5
5
  authors = ["DCSBL"]
6
6
  maintainers = ["DCSBL"]