From 62fe9144f185e349048567cb6429b805fb87782d Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker <joostlek@outlook.com> Date: Mon, 22 Jan 2024 09:10:26 +0100 Subject: [PATCH] Add icon translations to Adguard (#108406) --- homeassistant/components/adguard/icons.json | 75 +++++++++++++++++++++ homeassistant/components/adguard/sensor.py | 8 --- homeassistant/components/adguard/switch.py | 6 -- 3 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 homeassistant/components/adguard/icons.json diff --git a/homeassistant/components/adguard/icons.json b/homeassistant/components/adguard/icons.json new file mode 100644 index 00000000000..9c5df8a4a45 --- /dev/null +++ b/homeassistant/components/adguard/icons.json @@ -0,0 +1,75 @@ +{ + "entity": { + "sensor": { + "dns_queries": { + "default": "mdi:magnify" + }, + "dns_queries_blocked": { + "default": "mdi:magnify-close" + }, + "dns_queries_blocked_ratio": { + "default": "mdi:magnify-close" + }, + "parental_control_blocked": { + "default": "mdi:human-male-girl" + }, + "safe_browsing_blocked": { + "default": "mdi:shield-half-full" + }, + "safe_searches_enforced": { + "default": "mdi:shield-search" + }, + "average_processing_speed": { + "default": "mdi:speedometer" + }, + "rules_count": { + "default": "mdi:counter" + } + }, + "switch": { + "protection": { + "default": "mdi:shield-check", + "state": { + "off": "mdi:shield-off" + } + }, + "parental": { + "default": "mdi:shield-check", + "state": { + "off": "mdi:shield-off" + } + }, + "safe_search": { + "default": "mdi:shield-check", + "state": { + "off": "mdi:shield-off" + } + }, + "safe_browsing": { + "default": "mdi:shield-check", + "state": { + "off": "mdi:shield-off" + } + }, + "filtering": { + "default": "mdi:shield-check", + "state": { + "off": "mdi:shield-off" + } + }, + "query_log": { + "default": "mdi:shield-check", + "state": { + "off": "mdi:shield-off" + } + } + } + }, + "services": { + "add_url": "mdi:link-plus", + "remove_url": "mdi:link-off", + "enable_url": "mdi:link-variant", + "disable_url": "mdi:link-variant-off", + "refresh": "mdi:refresh" + } +} diff --git a/homeassistant/components/adguard/sensor.py b/homeassistant/components/adguard/sensor.py index c8ec5023533..e1cec6c4d3b 100644 --- a/homeassistant/components/adguard/sensor.py +++ b/homeassistant/components/adguard/sensor.py @@ -33,56 +33,48 @@ SENSORS: tuple[AdGuardHomeEntityDescription, ...] = ( AdGuardHomeEntityDescription( key="dns_queries", translation_key="dns_queries", - icon="mdi:magnify", native_unit_of_measurement="queries", value_fn=lambda adguard: adguard.stats.dns_queries(), ), AdGuardHomeEntityDescription( key="blocked_filtering", translation_key="dns_queries_blocked", - icon="mdi:magnify-close", native_unit_of_measurement="queries", value_fn=lambda adguard: adguard.stats.blocked_filtering(), ), AdGuardHomeEntityDescription( key="blocked_percentage", translation_key="dns_queries_blocked_ratio", - icon="mdi:magnify-close", native_unit_of_measurement=PERCENTAGE, value_fn=lambda adguard: adguard.stats.blocked_percentage(), ), AdGuardHomeEntityDescription( key="blocked_parental", translation_key="parental_control_blocked", - icon="mdi:human-male-girl", native_unit_of_measurement="requests", value_fn=lambda adguard: adguard.stats.replaced_parental(), ), AdGuardHomeEntityDescription( key="blocked_safebrowsing", translation_key="safe_browsing_blocked", - icon="mdi:shield-half-full", native_unit_of_measurement="requests", value_fn=lambda adguard: adguard.stats.replaced_safebrowsing(), ), AdGuardHomeEntityDescription( key="enforced_safesearch", translation_key="safe_searches_enforced", - icon="mdi:shield-search", native_unit_of_measurement="requests", value_fn=lambda adguard: adguard.stats.replaced_safesearch(), ), AdGuardHomeEntityDescription( key="average_speed", translation_key="average_processing_speed", - icon="mdi:speedometer", native_unit_of_measurement=UnitOfTime.MILLISECONDS, value_fn=lambda adguard: adguard.stats.avg_processing_time(), ), AdGuardHomeEntityDescription( key="rules_count", translation_key="rules_count", - icon="mdi:counter", native_unit_of_measurement="rules", value_fn=lambda adguard: adguard.filtering.rules_count(allowlist=False), entity_registry_enabled_default=False, diff --git a/homeassistant/components/adguard/switch.py b/homeassistant/components/adguard/switch.py index 4b6fe06cdab..0aa88aa3ffd 100644 --- a/homeassistant/components/adguard/switch.py +++ b/homeassistant/components/adguard/switch.py @@ -34,7 +34,6 @@ SWITCHES: tuple[AdGuardHomeSwitchEntityDescription, ...] = ( AdGuardHomeSwitchEntityDescription( key="protection", translation_key="protection", - icon="mdi:shield-check", is_on_fn=lambda adguard: adguard.protection_enabled, turn_on_fn=lambda adguard: adguard.enable_protection, turn_off_fn=lambda adguard: adguard.disable_protection, @@ -42,7 +41,6 @@ SWITCHES: tuple[AdGuardHomeSwitchEntityDescription, ...] = ( AdGuardHomeSwitchEntityDescription( key="parental", translation_key="parental", - icon="mdi:shield-check", is_on_fn=lambda adguard: adguard.parental.enabled, turn_on_fn=lambda adguard: adguard.parental.enable, turn_off_fn=lambda adguard: adguard.parental.disable, @@ -50,7 +48,6 @@ SWITCHES: tuple[AdGuardHomeSwitchEntityDescription, ...] = ( AdGuardHomeSwitchEntityDescription( key="safesearch", translation_key="safe_search", - icon="mdi:shield-check", is_on_fn=lambda adguard: adguard.safesearch.enabled, turn_on_fn=lambda adguard: adguard.safesearch.enable, turn_off_fn=lambda adguard: adguard.safesearch.disable, @@ -58,7 +55,6 @@ SWITCHES: tuple[AdGuardHomeSwitchEntityDescription, ...] = ( AdGuardHomeSwitchEntityDescription( key="safebrowsing", translation_key="safe_browsing", - icon="mdi:shield-check", is_on_fn=lambda adguard: adguard.safebrowsing.enabled, turn_on_fn=lambda adguard: adguard.safebrowsing.enable, turn_off_fn=lambda adguard: adguard.safebrowsing.disable, @@ -66,7 +62,6 @@ SWITCHES: tuple[AdGuardHomeSwitchEntityDescription, ...] = ( AdGuardHomeSwitchEntityDescription( key="filtering", translation_key="filtering", - icon="mdi:shield-check", is_on_fn=lambda adguard: adguard.filtering.enabled, turn_on_fn=lambda adguard: adguard.filtering.enable, turn_off_fn=lambda adguard: adguard.filtering.disable, @@ -74,7 +69,6 @@ SWITCHES: tuple[AdGuardHomeSwitchEntityDescription, ...] = ( AdGuardHomeSwitchEntityDescription( key="querylog", translation_key="query_log", - icon="mdi:shield-check", is_on_fn=lambda adguard: adguard.querylog.enabled, turn_on_fn=lambda adguard: adguard.querylog.enable, turn_off_fn=lambda adguard: adguard.querylog.disable, -- GitLab