Add translations for binary_sensor device classes (#58471)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Philip Allgaier 2021-10-26 20:41:44 +02:00 committed by GitHub
parent 370c7a7ccf
commit 5e88760fa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -207,5 +207,18 @@
"off": "[%key:common::state::off%]", "off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]" "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"
} }
} }

View File

@ -196,7 +196,7 @@ def gen_platform_strings_schema(config: Config, integration: Integration):
""" """
def device_class_validator(value): 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. 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) strings_schema = gen_auth_schema(config, integration)
elif integration.domain == "onboarding": elif integration.domain == "onboarding":
strings_schema = ONBOARDING_SCHEMA 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: else:
strings_schema = gen_strings_schema(config, integration) strings_schema = gen_strings_schema(config, integration)