diff --git a/homeassistant/components/derivative/strings.json b/homeassistant/components/derivative/strings.json index c21a486d039..b225653cafa 100644 --- a/homeassistant/components/derivative/strings.json +++ b/homeassistant/components/derivative/strings.json @@ -3,7 +3,6 @@ "step": { "user": { "title": "New Derivative sensor", - "description": "Precision controls the number of decimal digits in the output.\nIf the time window is not 0, the sensor's value is a time weighted moving average of derivatives within the window.\nThe derivative will be scaled according to the selected metric prefix and time unit of the derivative.", "data": { "name": "Name", "round": "Precision", @@ -11,6 +10,11 @@ "time_window": "Time window", "unit_prefix": "Metric prefix", "unit_time": "Time unit" + }, + "data_description": { + "round": "Controls the number of decimal digits in the output.", + "time_window": "If set, the sensor's value is a time weighted moving average of derivatives within this window.", + "unit_prefix": "The derivative will be scaled according to the selected metric prefix and time unit of the derivative." } } } @@ -18,7 +22,6 @@ "options": { "step": { "options": { - "description": "[%key:component::derivative::config::step::user::description%]", "data": { "name": "[%key:component::derivative::config::step::user::data::name%]", "round": "[%key:component::derivative::config::step::user::data::round%]", @@ -26,8 +29,13 @@ "time_window": "[%key:component::derivative::config::step::user::data::time_window%]", "unit_prefix": "[%key:component::derivative::config::step::user::data::unit_prefix%]", "unit_time": "[%key:component::derivative::config::step::user::data::unit_time%]" + }, + "data_description": { + "round": "[%key:component::derivative::config::step::user::data_description::round%]", + "time_window": "[%key:component::derivative::config::step::user::data_description::time_window%]", + "unit_prefix": "[%key:component::derivative::config::step::user::data_description::unit_prefix%]." } } } } -} \ No newline at end of file +} diff --git a/homeassistant/components/derivative/translations/en.json b/homeassistant/components/derivative/translations/en.json index b1fa702fe3c..cfa3bf2ab96 100644 --- a/homeassistant/components/derivative/translations/en.json +++ b/homeassistant/components/derivative/translations/en.json @@ -10,7 +10,11 @@ "unit_prefix": "Metric prefix", "unit_time": "Time unit" }, - "description": "Precision controls the number of decimal digits in the output.\nIf the time window is not 0, the sensor's value is a time weighted moving average of derivatives within the window.\nThe derivative will be scaled according to the selected metric prefix and time unit of the derivative.", + "data_description": { + "round": "Controls the number of decimal digits in the output.", + "time_window": "If set, the sensor's value is a time weighted moving average of derivatives within this window.", + "unit_prefix": "The derivative will be scaled according to the selected metric prefix and time unit of the derivative." + }, "title": "New Derivative sensor" } } @@ -26,7 +30,11 @@ "unit_prefix": "Metric prefix", "unit_time": "Time unit" }, - "description": "Precision controls the number of decimal digits in the output.\nIf the time window is not 0, the sensor's value is a time weighted moving average of derivatives within the window.\nThe derivative will be scaled according to the selected metric prefix and time unit of the derivative." + "data_description": { + "round": "Controls the number of decimal digits in the output.", + "time_window": "If set, the sensor's value is a time weighted moving average of derivatives within this window.", + "unit_prefix": "The derivative will be scaled according to the selected metric prefix and time unit of the derivative.." + } } } } diff --git a/script/hassfest/translations.py b/script/hassfest/translations.py index b721b4d708d..5e64c70210c 100644 --- a/script/hassfest/translations.py +++ b/script/hassfest/translations.py @@ -110,6 +110,7 @@ def gen_data_entry_schema( step_title_class("title"): cv.string_with_no_html, vol.Optional("description"): cv.string_with_no_html, vol.Optional("data"): {str: cv.string_with_no_html}, + vol.Optional("data_description"): {str: cv.string_with_no_html}, vol.Optional("menu_options"): {str: cv.string_with_no_html}, } }, @@ -125,7 +126,19 @@ def gen_data_entry_schema( removed_title_validator, config, integration ) - return schema + def data_description_validator(value): + """Validate data description.""" + for step_info in value["step"].values(): + if "data_description" not in step_info: + continue + + for key in step_info["data_description"]: + if key not in step_info["data"]: + raise vol.Invalid(f"data_description key {key} is not in data") + + return value + + return vol.All(vol.Schema(schema), data_description_validator) def gen_strings_schema(config: Config, integration: Integration):