Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -6,7 +6,10 @@ from adguardhome import AdGuardHomeConnectionError
|
||||
|
||||
from homeassistant.components.adguard import AdGuardHomeDeviceEntity
|
||||
from homeassistant.components.adguard.const import (
|
||||
DATA_ADGUARD_CLIENT, DATA_ADGUARD_VERION, DOMAIN)
|
||||
DATA_ADGUARD_CLIENT,
|
||||
DATA_ADGUARD_VERION,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
from homeassistant.helpers.typing import HomeAssistantType
|
||||
@@ -18,7 +21,7 @@ PARALLEL_UPDATES = 4
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
|
||||
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
|
||||
) -> None:
|
||||
"""Set up AdGuard Home sensor based on a config entry."""
|
||||
adguard = hass.data[DOMAIN][DATA_ADGUARD_CLIENT]
|
||||
@@ -48,12 +51,7 @@ class AdGuardHomeSensor(AdGuardHomeDeviceEntity):
|
||||
"""Defines a AdGuard Home sensor."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
adguard,
|
||||
name: str,
|
||||
icon: str,
|
||||
measurement: str,
|
||||
unit_of_measurement: str,
|
||||
self, adguard, name: str, icon: str, measurement: str, unit_of_measurement: str
|
||||
) -> None:
|
||||
"""Initialize AdGuard Home sensor."""
|
||||
self._state = None
|
||||
@@ -65,12 +63,12 @@ class AdGuardHomeSensor(AdGuardHomeDeviceEntity):
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Return the unique ID for this sensor."""
|
||||
return '_'.join(
|
||||
return "_".join(
|
||||
[
|
||||
DOMAIN,
|
||||
self.adguard.host,
|
||||
str(self.adguard.port),
|
||||
'sensor',
|
||||
"sensor",
|
||||
self.measurement,
|
||||
]
|
||||
)
|
||||
@@ -92,11 +90,7 @@ class AdGuardHomeDNSQueriesSensor(AdGuardHomeSensor):
|
||||
def __init__(self, adguard):
|
||||
"""Initialize AdGuard Home sensor."""
|
||||
super().__init__(
|
||||
adguard,
|
||||
'AdGuard DNS Queries',
|
||||
'mdi:magnify',
|
||||
'dns_queries',
|
||||
'queries',
|
||||
adguard, "AdGuard DNS Queries", "mdi:magnify", "dns_queries", "queries"
|
||||
)
|
||||
|
||||
async def _adguard_update(self) -> None:
|
||||
@@ -111,10 +105,10 @@ class AdGuardHomeBlockedFilteringSensor(AdGuardHomeSensor):
|
||||
"""Initialize AdGuard Home sensor."""
|
||||
super().__init__(
|
||||
adguard,
|
||||
'AdGuard DNS Queries Blocked',
|
||||
'mdi:magnify-close',
|
||||
'blocked_filtering',
|
||||
'queries',
|
||||
"AdGuard DNS Queries Blocked",
|
||||
"mdi:magnify-close",
|
||||
"blocked_filtering",
|
||||
"queries",
|
||||
)
|
||||
|
||||
async def _adguard_update(self) -> None:
|
||||
@@ -129,10 +123,10 @@ class AdGuardHomePercentageBlockedSensor(AdGuardHomeSensor):
|
||||
"""Initialize AdGuard Home sensor."""
|
||||
super().__init__(
|
||||
adguard,
|
||||
'AdGuard DNS Queries Blocked Ratio',
|
||||
'mdi:magnify-close',
|
||||
'blocked_percentage',
|
||||
'%',
|
||||
"AdGuard DNS Queries Blocked Ratio",
|
||||
"mdi:magnify-close",
|
||||
"blocked_percentage",
|
||||
"%",
|
||||
)
|
||||
|
||||
async def _adguard_update(self) -> None:
|
||||
@@ -148,10 +142,10 @@ class AdGuardHomeReplacedParentalSensor(AdGuardHomeSensor):
|
||||
"""Initialize AdGuard Home sensor."""
|
||||
super().__init__(
|
||||
adguard,
|
||||
'AdGuard Parental Control Blocked',
|
||||
'mdi:human-male-girl',
|
||||
'blocked_parental',
|
||||
'requests',
|
||||
"AdGuard Parental Control Blocked",
|
||||
"mdi:human-male-girl",
|
||||
"blocked_parental",
|
||||
"requests",
|
||||
)
|
||||
|
||||
async def _adguard_update(self) -> None:
|
||||
@@ -166,10 +160,10 @@ class AdGuardHomeReplacedSafeBrowsingSensor(AdGuardHomeSensor):
|
||||
"""Initialize AdGuard Home sensor."""
|
||||
super().__init__(
|
||||
adguard,
|
||||
'AdGuard Safe Browsing Blocked',
|
||||
'mdi:shield-half-full',
|
||||
'blocked_safebrowsing',
|
||||
'requests',
|
||||
"AdGuard Safe Browsing Blocked",
|
||||
"mdi:shield-half-full",
|
||||
"blocked_safebrowsing",
|
||||
"requests",
|
||||
)
|
||||
|
||||
async def _adguard_update(self) -> None:
|
||||
@@ -184,10 +178,10 @@ class AdGuardHomeReplacedSafeSearchSensor(AdGuardHomeSensor):
|
||||
"""Initialize AdGuard Home sensor."""
|
||||
super().__init__(
|
||||
adguard,
|
||||
'Searches Safe Search Enforced',
|
||||
'mdi:shield-search',
|
||||
'enforced_safesearch',
|
||||
'requests',
|
||||
"Searches Safe Search Enforced",
|
||||
"mdi:shield-search",
|
||||
"enforced_safesearch",
|
||||
"requests",
|
||||
)
|
||||
|
||||
async def _adguard_update(self) -> None:
|
||||
@@ -202,10 +196,10 @@ class AdGuardHomeAverageProcessingTimeSensor(AdGuardHomeSensor):
|
||||
"""Initialize AdGuard Home sensor."""
|
||||
super().__init__(
|
||||
adguard,
|
||||
'AdGuard Average Processing Speed',
|
||||
'mdi:speedometer',
|
||||
'average_speed',
|
||||
'ms',
|
||||
"AdGuard Average Processing Speed",
|
||||
"mdi:speedometer",
|
||||
"average_speed",
|
||||
"ms",
|
||||
)
|
||||
|
||||
async def _adguard_update(self) -> None:
|
||||
@@ -220,11 +214,7 @@ class AdGuardHomeRulesCountSensor(AdGuardHomeSensor):
|
||||
def __init__(self, adguard):
|
||||
"""Initialize AdGuard Home sensor."""
|
||||
super().__init__(
|
||||
adguard,
|
||||
'AdGuard Rules Count',
|
||||
'mdi:counter',
|
||||
'rules_count',
|
||||
'rules',
|
||||
adguard, "AdGuard Rules Count", "mdi:counter", "rules_count", "rules"
|
||||
)
|
||||
|
||||
async def _adguard_update(self) -> None:
|
||||
|
||||
Reference in new issue
Block a user