Skip to content

Commit

Permalink
Merge pull request #123 from gjohansson-ST/modify_data_faster
Browse files Browse the repository at this point in the history
Modify data faster
  • Loading branch information
gjohansson-ST authored Oct 3, 2022
2 parents 4bc8336 + 06581b7 commit a193dc0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions custom_components/sector/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ async def triggerlock(
try:
if command == "unlock":
await self._request(API_URL + "/Panel/Unlock", json_data=message_json)
self.data[panel_id]["lock"][lock]["status"] = "unlock"
if command == "lock":
await self._request(API_URL + "/Panel/Lock", json_data=message_json)
self.data[panel_id]["lock"][lock]["status"] = "lock"
except (UpdateFailed, ConfigEntryAuthFailed) as error:
raise HomeAssistantError(
f"Could not lock {lock} on error {str(error)}"
Expand All @@ -83,11 +85,13 @@ async def triggerswitch(self, identity: str, command: str, panel_id: str) -> Non
f"{API_URL}/Panel/TurnOnSmartplug?switchId={identity}&panelId={panel_id}",
json_data=message_json,
)
self.data[panel_id]["switch"][identity]["status"] = "On"
if command == "off":
await self._request(
f"{API_URL}/Panel/TurnOffSmartplug?switchId={identity}&panelId={panel_id}",
json_data=message_json,
)
self.data[panel_id]["switch"][identity]["status"] = "Off"
except (UpdateFailed, ConfigEntryAuthFailed) as error:
raise HomeAssistantError(
f"Could not change switch {identity} on error {str(error)}"
Expand All @@ -107,12 +111,15 @@ async def triggeralarm(self, command: str, code: str, panel_id: str) -> None:
try:
if command == "full":
await self._request(API_URL + "/Panel/Arm", json_data=message_json)
self.data[panel_id]["alarmstatus"] = 3
if command == "partial":
await self._request(
API_URL + "/Panel/PartialArm", json_data=message_json
)
self.data[panel_id]["alarmstatus"] = 2
if command == "disarm":
await self._request(API_URL + "/Panel/Disarm", json_data=message_json)
self.data[panel_id]["alarmstatus"] = 1
except (UpdateFailed, ConfigEntryAuthFailed) as error:
raise HomeAssistantError(
f"Could not arm/disarm {panel_id} on error {str(error)}"
Expand Down

0 comments on commit a193dc0

Please sign in to comment.