Fix KeyError in derivative and integration (#102294)

This commit is contained in:
Robert Resch 2023-10-19 18:22:22 +02:00 committed by GitHub
parent 3a4341dbeb
commit eab4c24f7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View file

@ -169,13 +169,17 @@ async def async_setup_entry(
else:
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(
integration_method=config_entry.options[CONF_METHOD],
name=config_entry.title,
round_digits=int(config_entry.options[CONF_ROUND_DIGITS]),
source_entity=source_entity_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],
device_info=device_info,
)