Add multi-partition support for TotalConnect (#55429)

This commit is contained in:
Austin Mroczek 2021-10-27 10:15:13 -07:00 committed by GitHub
parent 6cd83d1f66
commit baaaf3d2bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 463 additions and 256 deletions

View file

@ -2,6 +2,8 @@
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_DOOR,
DEVICE_CLASS_GAS,
DEVICE_CLASS_MOTION,
DEVICE_CLASS_SAFETY,
DEVICE_CLASS_SMOKE,
BinarySensorEntity,
)
@ -13,7 +15,7 @@ async def async_setup_entry(hass, entry, async_add_entities) -> None:
"""Set up TotalConnect device sensors based on a config entry."""
sensors = []
client_locations = hass.data[DOMAIN][entry.entry_id].locations
client_locations = hass.data[DOMAIN][entry.entry_id].client.locations
for location_id, location in client_locations.items():
for zone_id, zone in location.zones.items():
@ -70,6 +72,10 @@ class TotalConnectBinarySensor(BinarySensorEntity):
return DEVICE_CLASS_SMOKE
if self._zone.is_type_carbon_monoxide():
return DEVICE_CLASS_GAS
if self._zone.is_type_motion():
return DEVICE_CLASS_MOTION
if self._zone.is_type_medical():
return DEVICE_CLASS_SAFETY
return None
@property
@ -80,5 +86,6 @@ class TotalConnectBinarySensor(BinarySensorEntity):
"location_id": self._location_id,
"low_battery": self._is_low_battery,
"tampered": self._is_tampered,
"partition": self._zone.partition,
}
return attributes