fix: fixes
Some checks failed
Integration Testing / Test Integration (2025.9.4, 3.13) (push) Failing after 38s
Code Quality Check / Code Quality Analysis (push) Successful in 15s

Signed-off-by: Rafal Zielinski <sq4ind@gmail.com>
This commit is contained in:
2025-09-28 15:58:07 +01:00
parent e0edf6f865
commit 86f60e72b7
21 changed files with 147 additions and 466 deletions

View File

@@ -24,11 +24,9 @@ async def async_setup_entry(
coordinator = hass.data[DOMAIN][config_entry.entry_id]["coordinator"]
api = hass.data[DOMAIN][config_entry.entry_id]["api"]
entities = []
# Add global protection switch
entities.append(AdGuardProtectionSwitch(coordinator, api))
entities = [AdGuardProtectionSwitch(coordinator, api)]
# Add client switches
# Add client switches if clients exist
for client_name in coordinator.clients.keys():
entities.append(AdGuardClientSwitch(coordinator, api, client_name))
@@ -74,7 +72,6 @@ class AdGuardProtectionSwitch(AdGuardBaseSwitch):
try:
await self.api.set_protection(True)
await self.coordinator.async_request_refresh()
_LOGGER.info("AdGuard protection enabled")
except Exception as err:
_LOGGER.error("Failed to enable AdGuard protection: %s", err)
raise
@@ -84,7 +81,6 @@ class AdGuardProtectionSwitch(AdGuardBaseSwitch):
try:
await self.api.set_protection(False)
await self.coordinator.async_request_refresh()
_LOGGER.info("AdGuard protection disabled")
except Exception as err:
_LOGGER.error("Failed to disable AdGuard protection: %s", err)
raise
@@ -123,7 +119,6 @@ class AdGuardClientSwitch(AdGuardBaseSwitch):
}
await self.api.update_client(update_data)
await self.coordinator.async_request_refresh()
_LOGGER.info("Enabled protection for client %s", self.client_name)
except Exception as err:
_LOGGER.error("Failed to enable protection for %s: %s", self.client_name, err)
raise
@@ -139,7 +134,6 @@ class AdGuardClientSwitch(AdGuardBaseSwitch):
}
await self.api.update_client(update_data)
await self.coordinator.async_request_refresh()
_LOGGER.info("Disabled protection for client %s", self.client_name)
except Exception as err:
_LOGGER.error("Failed to disable protection for %s: %s", self.client_name, err)
raise