Fix LaCrosse View not updating (#79474)

This commit is contained in:
IceBotYT 2022-10-02 21:14:02 -04:00 committed by GitHub
parent da960f6ed4
commit d6a6d0d754
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -105,7 +105,7 @@ async def async_setup_entry(
sensors: list[Sensor] = coordinator.data
sensor_list = []
for sensor in sensors:
for i, sensor in enumerate(sensors):
for field in sensor.sensor_field_names:
description = SENSOR_DESCRIPTIONS.get(field)
if description is None:
@ -125,6 +125,7 @@ async def async_setup_entry(
coordinator=coordinator,
description=description,
sensor=sensor,
index=i,
)
)
@ -144,6 +145,7 @@ class LaCrosseViewSensor(
description: LaCrosseSensorEntityDescription,
coordinator: DataUpdateCoordinator[list[Sensor]],
sensor: Sensor,
index: int,
) -> None:
"""Initialize."""
super().__init__(coordinator)
@ -157,11 +159,11 @@ class LaCrosseViewSensor(
"model": sensor.model,
"via_device": (DOMAIN, sensor.location.id),
}
self._sensor = sensor
self.index = index
@property
def native_value(self) -> float | str:
"""Return the sensor value."""
return self.entity_description.value_fn(
self._sensor, self.entity_description.key
self.coordinator.data[self.index], self.entity_description.key
)