mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Fix KeyError in derivative and integration (#102294)
This commit is contained in:
parent
3a4341dbeb
commit
eab4c24f7f
@ -116,6 +116,10 @@ async def async_setup_entry(
|
|||||||
else:
|
else:
|
||||||
device_info = None
|
device_info = None
|
||||||
|
|
||||||
|
if (unit_prefix := config_entry.options.get(CONF_UNIT_PREFIX)) == "none":
|
||||||
|
# Before we had support for optional selectors, "none" was used for selecting nothing
|
||||||
|
unit_prefix = None
|
||||||
|
|
||||||
derivative_sensor = DerivativeSensor(
|
derivative_sensor = DerivativeSensor(
|
||||||
name=config_entry.title,
|
name=config_entry.title,
|
||||||
round_digits=int(config_entry.options[CONF_ROUND_DIGITS]),
|
round_digits=int(config_entry.options[CONF_ROUND_DIGITS]),
|
||||||
@ -123,7 +127,7 @@ async def async_setup_entry(
|
|||||||
time_window=cv.time_period_dict(config_entry.options[CONF_TIME_WINDOW]),
|
time_window=cv.time_period_dict(config_entry.options[CONF_TIME_WINDOW]),
|
||||||
unique_id=config_entry.entry_id,
|
unique_id=config_entry.entry_id,
|
||||||
unit_of_measurement=None,
|
unit_of_measurement=None,
|
||||||
unit_prefix=config_entry.options.get(CONF_UNIT_PREFIX),
|
unit_prefix=unit_prefix,
|
||||||
unit_time=config_entry.options[CONF_UNIT_TIME],
|
unit_time=config_entry.options[CONF_UNIT_TIME],
|
||||||
device_info=device_info,
|
device_info=device_info,
|
||||||
)
|
)
|
||||||
|
@ -169,13 +169,17 @@ async def async_setup_entry(
|
|||||||
else:
|
else:
|
||||||
device_info = None
|
device_info = None
|
||||||
|
|
||||||
|
if (unit_prefix := config_entry.options.get(CONF_UNIT_PREFIX)) == "none":
|
||||||
|
# Before we had support for optional selectors, "none" was used for selecting nothing
|
||||||
|
unit_prefix = None
|
||||||
|
|
||||||
integral = IntegrationSensor(
|
integral = IntegrationSensor(
|
||||||
integration_method=config_entry.options[CONF_METHOD],
|
integration_method=config_entry.options[CONF_METHOD],
|
||||||
name=config_entry.title,
|
name=config_entry.title,
|
||||||
round_digits=int(config_entry.options[CONF_ROUND_DIGITS]),
|
round_digits=int(config_entry.options[CONF_ROUND_DIGITS]),
|
||||||
source_entity=source_entity_id,
|
source_entity=source_entity_id,
|
||||||
unique_id=config_entry.entry_id,
|
unique_id=config_entry.entry_id,
|
||||||
unit_prefix=config_entry.options.get(CONF_UNIT_PREFIX),
|
unit_prefix=unit_prefix,
|
||||||
unit_time=config_entry.options[CONF_UNIT_TIME],
|
unit_time=config_entry.options[CONF_UNIT_TIME],
|
||||||
device_info=device_info,
|
device_info=device_info,
|
||||||
)
|
)
|
||||||
|
@ -176,8 +176,7 @@ def validate_user_input(
|
|||||||
]:
|
]:
|
||||||
"""Do post validation of user input.
|
"""Do post validation of user input.
|
||||||
|
|
||||||
For binary sensors: Strip none-sentinels.
|
For sensors: Validate unit of measurement.
|
||||||
For sensors: Strip none-sentinels and validate unit of measurement.
|
|
||||||
For all domaines: Set template type.
|
For all domaines: Set template type.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user