Use a single source of data for switchbot (#84215)

This commit is contained in:
J. Nick Koston 2022-12-19 07:47:42 -10:00 committed by GitHub
parent 6e612a45ff
commit 7c13e7cdfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 55 deletions

View file

@ -54,7 +54,7 @@ async def async_setup_entry(
coordinator: SwitchbotDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
async_add_entities(
SwitchBotBinarySensor(coordinator, binary_sensor)
for binary_sensor in coordinator.data["data"]
for binary_sensor in coordinator.device.parsed_data
if binary_sensor in BINARY_SENSOR_TYPES
)
@ -77,4 +77,4 @@ class SwitchBotBinarySensor(SwitchbotEntity, BinarySensorEntity):
@property
def is_on(self) -> bool:
"""Return the state of the sensor."""
return self.data["data"][self._sensor]
return self.parsed_data[self._sensor]