Fix xiaomi_aqara duplicated battery sensors (#39961)

pull/40018/head
Xiaonan Shen 2020-09-13 14:44:32 +08:00 committed by GitHub
parent bab4ad4f17
commit e3c51f0350
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -86,8 +86,12 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
_LOGGER.warning("Unmapped Device Model")
# Set up battery sensors
seen_sids = set() # Set of device sids that are already seen
for devices in gateway.devices.values():
for device in devices:
if device["sid"] in seen_sids:
continue
seen_sids.add(device["sid"])
if device["model"] in BATTERY_MODELS:
entities.append(
XiaomiBatterySensor(device, "Battery", gateway, config_entry)