From 8dcf920bc8c0d053e94b51551109886e4749c8c8 Mon Sep 17 00:00:00 2001 From: Jonathan Petersson Date: Wed, 6 Nov 2024 01:00:04 +0100 Subject: [PATCH 1/3] Fix arming and disarming --- custom_components/sector/client.py | 9 ++++++--- custom_components/sector/endpoints.py | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/custom_components/sector/client.py b/custom_components/sector/client.py index a99c23d..19e91d3 100644 --- a/custom_components/sector/client.py +++ b/custom_components/sector/client.py @@ -189,11 +189,14 @@ async def _post(self, url, payload): async def arm_system(self, mode): """Arm the alarm system.""" - url = self.action_endpoints["Arm"][1] + if mode == "totel": + url = self.action_endpoints["Arm"][1] + elif mode == "partial": + url = self.action_endpoints["PartialArm"][1] + payload = { "ArmCode": self.panel_code, "PanelId": self.panel_id, - "ArmType": mode, # 'total' or 'partial' } result = await self._post(url, payload) if result is not None: @@ -207,7 +210,7 @@ async def disarm_system(self): """Disarm the alarm system.""" url = self.action_endpoints["Disarm"][1] payload = { - "DisarmCode": self.panel_code, + "PanelCode": self.panel_code, "PanelId": self.panel_id, } result = await self._post(url, payload) diff --git a/custom_components/sector/endpoints.py b/custom_components/sector/endpoints.py index b813f80..c5fea7f 100644 --- a/custom_components/sector/endpoints.py +++ b/custom_components/sector/endpoints.py @@ -37,6 +37,7 @@ def get_action_endpoints(): "Lock": ("POST", f"{API_URL}/api/Panel/Lock"), # Arm/Disarm endpoints "Arm": ("POST", f"{API_URL}/api/Panel/Arm"), + "PartialArm": ("POST", f"{API_URL}/api/Panel/PartialArm"), "Disarm": ("POST", f"{API_URL}/api/Panel/Disarm"), } return endpoints From 8a34ff71f2505bf780a5526f5bd21b3a28d8d2e9 Mon Sep 17 00:00:00 2001 From: Jonathan Petersson Date: Wed, 6 Nov 2024 01:01:14 +0100 Subject: [PATCH 2/3] Correct payload for arming --- custom_components/sector/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/sector/client.py b/custom_components/sector/client.py index 19e91d3..6255893 100644 --- a/custom_components/sector/client.py +++ b/custom_components/sector/client.py @@ -195,7 +195,7 @@ async def arm_system(self, mode): url = self.action_endpoints["PartialArm"][1] payload = { - "ArmCode": self.panel_code, + "PanelCode": self.panel_code, "PanelId": self.panel_id, } result = await self._post(url, payload) From c9e8252a49e959b1b3c9bb46dfec8b973fce5f74 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Wed, 6 Nov 2024 08:38:40 +0100 Subject: [PATCH 3/3] Update custom_components/sector/client.py --- custom_components/sector/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/sector/client.py b/custom_components/sector/client.py index 6255893..6f188fa 100644 --- a/custom_components/sector/client.py +++ b/custom_components/sector/client.py @@ -189,7 +189,7 @@ async def _post(self, url, payload): async def arm_system(self, mode): """Arm the alarm system.""" - if mode == "totel": + if mode == "total": url = self.action_endpoints["Arm"][1] elif mode == "partial": url = self.action_endpoints["PartialArm"][1]