Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
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 Category(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[Category.unknown]:
"""Handle unknown device category."""

msg: str = f"{key} category is unknown"
LOG.warning(msg)
return Category.unknown
17 changes: 17 additions & 0 deletions src/pyatmo/modules/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from pyatmo.modules.device_types import (
DEVICE_CATEGORY_MAP,
ApplianceType,
Category,
DeviceCategory,
DeviceType,
)
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 CategoryMixin(EntityBase):
"""Mixin for category data."""

category: Category | None

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

super().__init__(home, module)
self.appliance_type: Category | None = module.get(
"category",
Category.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 @@ -23,6 +23,7 @@
BatteryMixin,
BoilerMixin,
Camera,
CategoryMixin,
CO2Mixin,
FirmwareMixin,
FloodlightMixin,
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, CategoryMixin, Module
):
"""Class to represent a Netatmo NACamDoorTag."""


Expand Down