mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add support for field descriptions in config flows (#68604)
This commit is contained in:
parent
63ca0e70be
commit
20c0a5a838
@ -3,7 +3,6 @@
|
|||||||
"step": {
|
"step": {
|
||||||
"user": {
|
"user": {
|
||||||
"title": "New Derivative sensor",
|
"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": {
|
"data": {
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"round": "Precision",
|
"round": "Precision",
|
||||||
@ -11,6 +10,11 @@
|
|||||||
"time_window": "Time window",
|
"time_window": "Time window",
|
||||||
"unit_prefix": "Metric prefix",
|
"unit_prefix": "Metric prefix",
|
||||||
"unit_time": "Time unit"
|
"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": {
|
"options": {
|
||||||
"step": {
|
"step": {
|
||||||
"options": {
|
"options": {
|
||||||
"description": "[%key:component::derivative::config::step::user::description%]",
|
|
||||||
"data": {
|
"data": {
|
||||||
"name": "[%key:component::derivative::config::step::user::data::name%]",
|
"name": "[%key:component::derivative::config::step::user::data::name%]",
|
||||||
"round": "[%key:component::derivative::config::step::user::data::round%]",
|
"round": "[%key:component::derivative::config::step::user::data::round%]",
|
||||||
@ -26,6 +29,11 @@
|
|||||||
"time_window": "[%key:component::derivative::config::step::user::data::time_window%]",
|
"time_window": "[%key:component::derivative::config::step::user::data::time_window%]",
|
||||||
"unit_prefix": "[%key:component::derivative::config::step::user::data::unit_prefix%]",
|
"unit_prefix": "[%key:component::derivative::config::step::user::data::unit_prefix%]",
|
||||||
"unit_time": "[%key:component::derivative::config::step::user::data::unit_time%]"
|
"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%]."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,11 @@
|
|||||||
"unit_prefix": "Metric prefix",
|
"unit_prefix": "Metric prefix",
|
||||||
"unit_time": "Time unit"
|
"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"
|
"title": "New Derivative sensor"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,7 +30,11 @@
|
|||||||
"unit_prefix": "Metric prefix",
|
"unit_prefix": "Metric prefix",
|
||||||
"unit_time": "Time unit"
|
"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.."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,7 @@ def gen_data_entry_schema(
|
|||||||
step_title_class("title"): cv.string_with_no_html,
|
step_title_class("title"): cv.string_with_no_html,
|
||||||
vol.Optional("description"): 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"): {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},
|
vol.Optional("menu_options"): {str: cv.string_with_no_html},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -125,7 +126,19 @@ def gen_data_entry_schema(
|
|||||||
removed_title_validator, config, integration
|
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):
|
def gen_strings_schema(config: Config, integration: Integration):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user