Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix modelling #240

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion custom_components/sector/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion custom_components/sector/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion custom_components/sector/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand All @@ -202,4 +203,4 @@ async def async_step_init(
DATA_SCHEMA_OPTIONS,
self.config_entry.options,
),
)
)
2 changes: 1 addition & 1 deletion custom_components/sector/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion custom_components/sector/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 9 additions & 3 deletions custom_components/sector/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand All @@ -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
Expand All @@ -42,3 +47,4 @@ class PanelStatus:

alarm_state: int
is_online: bool
ready_to_arm: bool
Loading