Avoid mutating entity descriptions in airthings_ble (#105627)

pull/94438/head^2
Erik Montnemery 2023-12-13 15:23:38 +01:00 committed by GitHub
parent 7ab003c746
commit 2d59eba4c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,7 @@
"""Support for airthings ble sensors."""
from __future__ import annotations
import dataclasses
import logging
from airthings_ble import AirthingsDevice
@ -167,10 +168,13 @@ async def async_setup_entry(
# we need to change some units
sensors_mapping = SENSORS_MAPPING_TEMPLATE.copy()
if not is_metric:
for val in sensors_mapping.values():
for key, val in sensors_mapping.items():
if val.native_unit_of_measurement is not VOLUME_BECQUEREL:
continue
val.native_unit_of_measurement = VOLUME_PICOCURIE
sensors_mapping[key] = dataclasses.replace(
val,
native_unit_of_measurement=VOLUME_PICOCURIE,
)
entities = []
_LOGGER.debug("got sensors: %s", coordinator.data.sensors)