From 27922305483eba3f19b4e35fd2accce61a07ae15 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Wed, 13 Nov 2024 22:47:01 +0100 Subject: [PATCH] Fix modelling --- custom_components/sector/alarm_control_panel.py | 7 ++++++- custom_components/sector/client.py | 2 +- custom_components/sector/config_flow.py | 3 ++- custom_components/sector/coordinator.py | 2 +- custom_components/sector/lock.py | 2 +- custom_components/sector/model.py | 12 +++++++++--- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/custom_components/sector/alarm_control_panel.py b/custom_components/sector/alarm_control_panel.py index a39b5b3..f23731e 100644 --- a/custom_components/sector/alarm_control_panel.py +++ b/custom_components/sector/alarm_control_panel.py @@ -52,7 +52,12 @@ class SectorAlarmControlPanel(SectorAlarmBaseEntity, AlarmControlPanelEntity): def __init__(self, coordinator: SectorDataUpdateCoordinator) -> None: """Initialize the control panel.""" - super().__init__(coordinator, coordinator.config_entry.data[CONF_PANEL_ID], "Sector Alarm Panel", "Alarm panel") + super().__init__( + coordinator, + coordinator.config_entry.data[CONF_PANEL_ID], + "Sector Alarm Panel", + "Alarm panel", + ) self._attr_unique_id = f"{self._serial_no}_alarm_panel" _LOGGER.debug( diff --git a/custom_components/sector/client.py b/custom_components/sector/client.py index 1f7657b..d399416 100644 --- a/custom_components/sector/client.py +++ b/custom_components/sector/client.py @@ -32,7 +32,7 @@ def __init__(self, hass: HomeAssistant, email, password, panel_id): self.password = password self.panel_id = panel_id self.access_token = None - self.headers:dict[str,str] = {} + self.headers: dict[str, str] = {} self.session = None self.data_endpoints = get_data_endpoints(self.panel_id) self.action_endpoints = get_action_endpoints() diff --git a/custom_components/sector/config_flow.py b/custom_components/sector/config_flow.py index 493555e..216fe39 100644 --- a/custom_components/sector/config_flow.py +++ b/custom_components/sector/config_flow.py @@ -185,6 +185,7 @@ async def async_step_select_panel( return self.async_show_form(step_id="select_panel", data_schema=data_schema) + class SectorAlarmOptionsFlow(OptionsFlowWithConfigEntry): """Handle Sector options.""" @@ -202,4 +203,4 @@ async def async_step_init( DATA_SCHEMA_OPTIONS, self.config_entry.options, ), - ) \ No newline at end of file + ) diff --git a/custom_components/sector/coordinator.py b/custom_components/sector/coordinator.py index 0d86987..b5a2358 100644 --- a/custom_components/sector/coordinator.py +++ b/custom_components/sector/coordinator.py @@ -68,7 +68,7 @@ async def _async_update_data(self) -> dict[str, Any]: def _process_devices(self, api_data) -> tuple[dict[str, Any], dict[str, Any]]: """Process device data from the API, including humidity, closed, and alarm sensors.""" - devices:dict[str,Any] = {} + devices: dict[str, Any] = {} panel_status = api_data.get("Panel Status", {}) for category_name, category_data in api_data.items(): diff --git a/custom_components/sector/lock.py b/custom_components/sector/lock.py index 675f645..e02cab9 100644 --- a/custom_components/sector/lock.py +++ b/custom_components/sector/lock.py @@ -28,7 +28,7 @@ async def async_setup_entry( for serial_no, device_info in devices.items(): if device_info.get("model") == "Smart Lock": - device_name:str = device_info["name"] + device_name: str = device_info["name"] entities.append( SectorAlarmLock( coordinator, code_format, serial_no, device_name, "Smart Lock" diff --git a/custom_components/sector/model.py b/custom_components/sector/model.py index e6c88cd..c55842a 100644 --- a/custom_components/sector/model.py +++ b/custom_components/sector/model.py @@ -20,8 +20,10 @@ class Locks: name: str serial_no: str - lock_status: str - low_battery: str # Needs to be checked + lock_status: str # Which are valid? + low_battery: bool + sound_level: int + autolock: bool model: str = "Smart Lock" @@ -31,9 +33,12 @@ class Devices: name: str serial_no: str - device_status: str # Needs to be checked + device_status: int | bool # Needs to be checked model: str type: str + low_battery: bool + closed: bool # Only valid doors/windows + alarm: bool # Only valid doors/windows+smoke detectors+leakage detectors likely @dataclass @@ -42,3 +47,4 @@ class PanelStatus: alarm_state: int is_online: bool + ready_to_arm: bool