Use a single source of data for switchbot (#84215)
This commit is contained in:
parent
6e612a45ff
commit
7c13e7cdfd
6 changed files with 39 additions and 55 deletions
|
@ -89,11 +89,8 @@ async def async_setup_entry(
|
|||
"""Set up Switchbot sensor based on a config entry."""
|
||||
coordinator: SwitchbotDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
entities = [
|
||||
SwitchBotSensor(
|
||||
coordinator,
|
||||
sensor,
|
||||
)
|
||||
for sensor in coordinator.data["data"]
|
||||
SwitchBotSensor(coordinator, sensor)
|
||||
for sensor in coordinator.device.parsed_data
|
||||
if sensor in SENSOR_TYPES
|
||||
]
|
||||
entities.append(SwitchbotRSSISensor(coordinator, "rssi"))
|
||||
|
@ -117,7 +114,7 @@ class SwitchBotSensor(SwitchbotEntity, SensorEntity):
|
|||
@property
|
||||
def native_value(self) -> str | int | None:
|
||||
"""Return the state of the sensor."""
|
||||
return self.data["data"][self._sensor]
|
||||
return self.parsed_data[self._sensor]
|
||||
|
||||
|
||||
class SwitchbotRSSISensor(SwitchBotSensor):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue