Skip to content

Commit ab34f49

Browse files
committed
Fix Switch
1 parent 55c9d1a commit ab34f49

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

custom_components/sector/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ async def get_id(self, serial: str) -> str:
238238
"""Get id for switch."""
239239
for switch in self._switches:
240240
if switch["SerialNo"] == serial:
241-
return switch["id"]
241+
return switch["Id"]
242242

243243
async def get_autolock(self, serial: str) -> str:
244244
"""Check if autolock is enabled."""

custom_components/sector/switch.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@ async def async_setup_entry(
3535
switchlist: list = []
3636
for switch in switches:
3737
name = await sector_hub.get_name(switch, "switch")
38-
identification = await sector_hub.get_id(switch)
3938
description = SwitchEntityDescription(
4039
key=switch, name=name, device_class=DEVICE_CLASS_OUTLET
4140
)
42-
switchlist.append(
43-
SectorAlarmSwitch(sector_hub, coordinator, description, identification)
44-
)
41+
switchlist.append(SectorAlarmSwitch(sector_hub, coordinator, description))
4542

4643
if switchlist:
4744
async_add_entities(switchlist)
@@ -50,7 +47,12 @@ async def async_setup_entry(
5047
class SectorAlarmSwitch(CoordinatorEntity, SwitchEntity):
5148
"""Sector Switch."""
5249

53-
def __init__(self, hub, coordinator, description, identification) -> None:
50+
def __init__(
51+
self,
52+
hub: SectorAlarmHub,
53+
coordinator: DataUpdateCoordinator,
54+
description: SwitchEntityDescription,
55+
) -> None:
5456
"""Initialize Switch."""
5557
self._hub = hub
5658
super().__init__(coordinator)
@@ -59,7 +61,7 @@ def __init__(self, hub, coordinator, description, identification) -> None:
5961
self._attr_unique_id: str = "sa_switch_" + str(description.key)
6062
self.entity_description = description
6163
self._attr_is_on = self._hub.switch_state[self._serial]
62-
self._id = identification
64+
self._id: str = self._hub.get_id[self._serial]
6365

6466
@property
6567
def device_info(self) -> DeviceInfo:

0 commit comments

Comments
 (0)