Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/pyatmo/modules/base_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from pyatmo.const import GPS_COORDINATES_COUNT, MAX_HISTORY_TIME_FRAME, RawData
from pyatmo.event import EventTypes
from pyatmo.modules.device_types import ApplianceType, DeviceType
from pyatmo.modules.device_types import ApplianceType, DeviceType, DoorTagCategory

if TYPE_CHECKING:
from collections.abc import Callable, Iterator
Expand All @@ -35,6 +35,7 @@
"place": lambda x, _: Place(x.get("place")),
"target_position__step": lambda x, _: x.get("target_position:step"),
"appliance_type": lambda x, y: ApplianceType(x.get("appliance_type", y)),
"doortag_category": lambda x, y: DoorTagCategory(x.get("doortag_category", y)),
}


Expand Down
22 changes: 22 additions & 0 deletions src/pyatmo/modules/device_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,25 @@ def _missing_(cls, key: object) -> Literal[ApplianceType.unknown]:
msg: str = f"{key} appliance type is unknown"
LOG.warning(msg)
return ApplianceType.unknown


class DoorTagCategory(str, Enum):
"""Class to represent category of a module. This is only for Home + Security/NACamDoorTag."""

# temporarily disable locally-disabled and locally-enabled

door = "door"
furniture = "furniture"
garage = "garage"
gate = "gate"
other = "other"
window = "window"
unknown = "unknown"

@classmethod
def _missing_(cls, key: object) -> Literal[DoorTagCategory.unknown]:
"""Handle unknown device category."""

msg: str = f"{key} category is unknown"
LOG.warning(msg)
return DoorTagCategory.unknown
17 changes: 17 additions & 0 deletions src/pyatmo/modules/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ApplianceType,
DeviceCategory,
DeviceType,
DoorTagCategory,
)

if TYPE_CHECKING:
Expand All @@ -35,6 +36,7 @@
"battery_state",
"battery_level",
"battery_percent",
"category",
"date_min_temp",
"date_max_temp",
"name",
Expand Down Expand Up @@ -316,6 +318,21 @@ def __init__(self, home: Home, module: ModuleT) -> None:
)


class DoorTagCategoryMixin(EntityBase):
"""Mixin for category data."""

doortag_category: DoorTagCategory | None

def __init__(self, home: Home, module: ModuleT) -> None:
"""Initialize category mixin."""

super().__init__(home, module)
self.doortag_category: DoorTagCategory | None = module.get(
"category",
DoorTagCategory.unknown,
)


class PowerMixin(EntityBase):
"""Mixin for power data."""

Expand Down
5 changes: 4 additions & 1 deletion src/pyatmo/modules/netatmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
BoilerMixin,
Camera,
CO2Mixin,
DoorTagCategoryMixin,
FirmwareMixin,
FloodlightMixin,
HealthIndexMixin,
Expand Down Expand Up @@ -146,7 +147,9 @@ class NHC(
"""Class to represent a Netatmo NHC."""


class NACamDoorTag(StatusMixin, FirmwareMixin, BatteryMixin, RfMixin, Module):
class NACamDoorTag(
StatusMixin, FirmwareMixin, BatteryMixin, RfMixin, DoorTagCategoryMixin, Module
):
"""Class to represent a Netatmo NACamDoorTag."""


Expand Down