Skip to content

Commit

Permalink
Fix Hass 2024.1 error: RecursionError #1285
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Jan 4, 2024
1 parent ab1af1a commit 85f77fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/sonoff/core/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type:
bases = cls.__mro__[-len(XSwitch.__mro__) :: -1]
bases = {k: v for b in bases for k, v in b.__dict__.items()}
return type(cls.__name__, DEVICE_CLASS[base], {**bases, **kwargs})
return type(cls.__name__, (cls,), {**cls.__dict__, **kwargs})
return type(cls.__name__, (cls,), kwargs)


Switch1 = spec(XSwitches, channel=0, uid="1")
Expand Down
11 changes: 10 additions & 1 deletion tests/test_backward.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
UnitOfPower,
UnitOfTemperature,
)
from homeassistant.helpers.entity import Entity

from . import init


def test_2021_9_0():
Expand Down Expand Up @@ -51,4 +54,10 @@ def test_2023_1_0():


def test_2024_1_cached_properties():
pass
_, entities = init({"extra": {"uiid": 5}})
sensor: SensorEntity = next(e for e in entities if e.uid == "energy")
assert sensor.device_class == SensorDeviceClass.ENERGY

_, entities = init({"extra": {"uiid": 1256}})
sensor: Entity = next(e for e in entities)
assert sensor.should_poll is False

0 comments on commit 85f77fe

Please sign in to comment.