From 5e88760fa7b8344caced66c1447592d5701d7812 Mon Sep 17 00:00:00 2001 From: Philip Allgaier <mail@spacegaier.de> Date: Tue, 26 Oct 2021 20:41:44 +0200 Subject: [PATCH] Add translations for binary_sensor device classes (#58471) Co-authored-by: J. Nick Koston <nick@koston.org> --- homeassistant/components/binary_sensor/strings.json | 13 +++++++++++++ script/hassfest/translations.py | 10 +++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/binary_sensor/strings.json b/homeassistant/components/binary_sensor/strings.json index a96808d68a3..eb97b370105 100644 --- a/homeassistant/components/binary_sensor/strings.json +++ b/homeassistant/components/binary_sensor/strings.json @@ -207,5 +207,18 @@ "off": "[%key:common::state::off%]", "on": "[%key:common::state::on%]" } + }, + "device_class": { + "cold": "cold", + "gas": "gas", + "heat": "heat", + "moisture": "moisture", + "motion": "motion", + "occupancy": "occupancy", + "power": "power", + "problem": "problem", + "smoke": "smoke", + "sound": "sound", + "vibration": "vibration" } } \ No newline at end of file diff --git a/script/hassfest/translations.py b/script/hassfest/translations.py index e24b37d71d9..841638a9718 100644 --- a/script/hassfest/translations.py +++ b/script/hassfest/translations.py @@ -196,7 +196,7 @@ def gen_platform_strings_schema(config: Config, integration: Integration): """ def device_class_validator(value): - """Key validator for platorm states. + """Key validator for platform states. Platform states are only allowed to provide states for device classes they prefix. """ @@ -246,6 +246,14 @@ def validate_translation_file(config: Config, integration: Integration, all_stri strings_schema = gen_auth_schema(config, integration) elif integration.domain == "onboarding": strings_schema = ONBOARDING_SCHEMA + elif integration.domain == "binary_sensor": + strings_schema = gen_strings_schema(config, integration).extend( + { + vol.Optional("device_class"): cv.schema_with_slug_keys( + cv.string_with_no_html, slug_validator=vol.Any("_", cv.slug) + ) + } + ) else: strings_schema = gen_strings_schema(config, integration) -- GitLab