Correct keyerror exception. (#52150)
This commit is contained in:
parent
5687ced7b3
commit
c558c77413
1 changed files with 2 additions and 2 deletions
|
@ -40,10 +40,10 @@ def sensor_schema_validator(config):
|
||||||
structure = (
|
structure = (
|
||||||
f">{DEFAULT_STRUCT_FORMAT[config[CONF_DATA_TYPE]][config[CONF_COUNT]]}"
|
f">{DEFAULT_STRUCT_FORMAT[config[CONF_DATA_TYPE]][config[CONF_COUNT]]}"
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError as key:
|
||||||
raise vol.Invalid(
|
raise vol.Invalid(
|
||||||
f"Unable to detect data type for {config[CONF_NAME]} sensor, try a custom type"
|
f"Unable to detect data type for {config[CONF_NAME]} sensor, try a custom type"
|
||||||
) from KeyError
|
) from key
|
||||||
else:
|
else:
|
||||||
structure = config.get(CONF_STRUCTURE)
|
structure = config.get(CONF_STRUCTURE)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue