Skip to content

Commit

Permalink
Add missing device classes and fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
cgtobi authored and jabesq committed Oct 10, 2023
1 parent b417728 commit 1e7702c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/pyatmo/modules/bticino.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ class BNCX(Module):

class BNEU(Module):
"""BTicino external unit."""


class BNCS(Module):
"""BTicino camera."""
32 changes: 32 additions & 0 deletions src/pyatmo/modules/device_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class DeviceType(str, Enum):
# temporarily disable locally-disabled and locally-enabled
# pylint: disable=C0103

# Unknown
UNKNOWN = "UNKNOWN"

# Climate/Energy
NAPlug = "NAPlug" # Smart thermostat gateway
NATherm1 = "NATherm1" # Smart thermostat
Expand Down Expand Up @@ -80,6 +83,15 @@ class DeviceType(str, Enum):
BNDL = "BNDL" # door lock
BNEU = "BNEU" # external unit
BNSL = "BNSL" # staircase light
BNCS = "BNCS" # Controlled Socket
BNXM = "BNXM" # X meter
BNMS = "BNMS" # motorized shade
BNAS = "BNAS" # automatic shutter
BNAB = "BNAB" # automatic blind
BNMH = "BNMH" # automatic blind
BNTH = "BNTH" # thermostat
BNFC = "BNFC" # fan coil
BNTR = "BNTR" # radiator

# Bubbendorf shutters
NBG = "NBG" # gateway
Expand All @@ -95,6 +107,9 @@ class DeviceType(str, Enum):
EBU = "EBU" # EBU gas meter
Z3L = "Z3L" # Zigbee 3 Light

# Magellan
NLDP = "NLDP" # Pocket Remote

# pylint: enable=C0103


Expand Down Expand Up @@ -158,6 +173,16 @@ class DeviceCategory(str, Enum):
DeviceType.NLUO: DeviceCategory.dimmer,
DeviceType.NLUI: DeviceCategory.switch,
DeviceType.NLUF: DeviceCategory.dimmer,
DeviceType.NLPS: DeviceCategory.meter,
DeviceType.NLD: DeviceCategory.switch,
DeviceType.NLDD: DeviceCategory.switch,
DeviceType.NLPT: DeviceCategory.switch,
DeviceType.BNMS: DeviceCategory.shutter,
DeviceType.BNAS: DeviceCategory.shutter,
DeviceType.BNAB: DeviceCategory.shutter,
DeviceType.BNTH: DeviceCategory.climate,
DeviceType.BNFC: DeviceCategory.climate,
DeviceType.BNTR: DeviceCategory.climate,
}


Expand Down Expand Up @@ -219,6 +244,13 @@ class DeviceCategory(str, Enum):
DeviceType.BNEU: ("BTicino", "External Unit"),
DeviceType.BNDL: ("BTicino", "Door Lock"),
DeviceType.BNSL: ("BTicino", "Staircase Light"),
DeviceType.BNMS: ("BTicino", "Motorized Shade"),
DeviceType.BNAS: ("BTicino", "Automatic Shutter"),
DeviceType.BNAB: ("BTicino", "Automatic Blind"),
DeviceType.BNMH: ("BTicino", "MyHome server 1"),
DeviceType.BNTH: ("BTicino", "Thermostat"),
DeviceType.BNFC: ("BTicino", "Fan coil"),
DeviceType.BNTR: ("BTicino", "Module towel rail"),
# Bubbendorf shutters
DeviceType.NBG: ("Bubbendorf", "Gateway"),
DeviceType.NBR: ("Bubbendorf", "Roller Shutter"),
Expand Down
8 changes: 7 additions & 1 deletion src/pyatmo/modules/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,13 @@ def __init__(self, home: Home, module: ModuleT) -> None:
"""Initialize a Netatmo module instance."""

super().__init__(module)
self.device_type = DeviceType(module["type"])

try:
self.device_type = DeviceType(module["type"])
except ValueError:
LOG.error("Unknown device type %s", module["type"])
self.device_type = DeviceType.UNKNOWN

self.home = home
self.room_id = module.get("room_id")
self.reachable = module.get("reachable")
Expand Down

0 comments on commit 1e7702c

Please sign in to comment.