Fix strings

This commit is contained in:
G Johansson 2025-07-03 19:13:16 +00:00
parent 2f43b44443
commit 1c64a88309
2 changed files with 5 additions and 26 deletions

View File

@ -86,22 +86,6 @@ async def get_options_schema(handler: SchemaCommonFlowHandler) -> vol.Schema:
) )
def _is_valid_data_points(check_data_points: list[str]) -> bool:
"""Validate data points."""
result = False
for data_point in check_data_points:
if not data_point.find(",") > 0:
return False
values = data_point.split(",", maxsplit=1)
for value in values:
try:
float(value)
except ValueError:
return False
result = True
return result
async def validate_options( async def validate_options(
handler: SchemaCommonFlowHandler, user_input: dict[str, Any] handler: SchemaCommonFlowHandler, user_input: dict[str, Any]
) -> dict[str, Any]: ) -> dict[str, Any]:
@ -110,9 +94,6 @@ async def validate_options(
user_input[CONF_PRECISION] = int(user_input[CONF_PRECISION]) user_input[CONF_PRECISION] = int(user_input[CONF_PRECISION])
user_input[CONF_DEGREE] = int(user_input[CONF_DEGREE]) user_input[CONF_DEGREE] = int(user_input[CONF_DEGREE])
if not _is_valid_data_points(user_input[CONF_DATAPOINTS]):
raise SchemaFlowError("incorrect_datapoints")
if len(user_input[CONF_DATAPOINTS]) <= user_input[CONF_DEGREE]: if len(user_input[CONF_DATAPOINTS]) <= user_input[CONF_DEGREE]:
raise SchemaFlowError("not_enough_datapoints") raise SchemaFlowError("not_enough_datapoints")

View File

@ -4,7 +4,6 @@
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]" "already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
}, },
"error": { "error": {
"incorrect_datapoints": "Datapoints needs to be provided in the right format, ex. '1.0, 0.0'.",
"not_enough_datapoints": "The number of datapoints needs to be more than the configured degree." "not_enough_datapoints": "The number of datapoints needs to be more than the configured degree."
}, },
"step": { "step": {
@ -20,7 +19,7 @@
} }
}, },
"options": { "options": {
"description": "Read the documention for further details on how to configure the statistics sensor using these options.", "description": "Read the documentation for further details on how to configure the statistics sensor using these options.",
"data": { "data": {
"data_points": "Data points", "data_points": "Data points",
"attribute": "Attribute", "attribute": "Attribute",
@ -31,10 +30,10 @@
"unit_of_measurement": "Unit of measurement" "unit_of_measurement": "Unit of measurement"
}, },
"data_description": { "data_description": {
"data_points": "Add a collection of data point conversions with uncompensated value and the compensated value. The number of required data point sets is equal to the polynomial degree + 1.", "data_points": "Add a collection of data point conversions with the uncompensated value and the compensated value. The number of required data point sets is equal to the polynomial degree + 1.",
"attribute": "Attribute from the source to monitor/compensate.", "attribute": "Attribute from the source to monitor/compensate.",
"upper_limit": "Enables an upper limit for the sensor. The upper limit is defined by the data collections (data_points) greatest uncompensated value.", "upper_limit": "Enables an upper limit for the sensor. The upper limit is defined by the data collection's (data_points) greatest uncompensated value.",
"lower_limit": "Enables a lower limit for the sensor. The lower limit is defined by the data collections (data_points) lowest uncompensated value.", "lower_limit": "Enables a lower limit for the sensor. The lower limit is defined by the data collection's (data_points) lowest uncompensated value.",
"precision": "Defines the precision of the calculated values, through the argument of round().", "precision": "Defines the precision of the calculated values, through the argument of round().",
"degree": "The degree of a polynomial.", "degree": "The degree of a polynomial.",
"unit_of_measurement": "Defines the units of measurement of the sensor, if any." "unit_of_measurement": "Defines the units of measurement of the sensor, if any."
@ -47,7 +46,6 @@
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]" "already_configured": "[%key:common::config_flow::abort::already_configured_account%]"
}, },
"error": { "error": {
"incorrect_datapoints": "[%key:component::compensation::config::error::incorrect_datapoints%]",
"not_enough_datapoints": "[%key:component::compensation::config::error::not_enough_datapoints%]" "not_enough_datapoints": "[%key:component::compensation::config::error::not_enough_datapoints%]"
}, },
"step": { "step": {
@ -84,7 +82,7 @@
}, },
"exceptions": { "exceptions": {
"setup_error": { "setup_error": {
"message": "Setup of {title} could not be setup due to {error}" "message": "Setup of {title} could not be completed due to {error}"
} }
} }
} }