Fix missing battery sensors for SimpliSafe locks (#90722)

This commit is contained in:
Aaron Bach 2023-04-03 08:42:24 -06:00 committed by GitHub
parent aeeadb570a
commit ba58fc25bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
"""Support for SimpliSafe binary sensors."""
from __future__ import annotations
from simplipy.device import DeviceTypes
from simplipy.device import DeviceTypes, DeviceV3
from simplipy.device.sensor.v3 import SensorV3
from simplipy.system.v3 import SystemV3
@ -67,6 +67,9 @@ async def async_setup_entry(
if sensor.type in SUPPORTED_BATTERY_SENSOR_TYPES:
sensors.append(BatteryBinarySensor(simplisafe, system, sensor))
for lock in system.locks.values():
sensors.append(BatteryBinarySensor(simplisafe, system, lock))
async_add_entities(sensors)
@ -99,14 +102,14 @@ class BatteryBinarySensor(SimpliSafeEntity, BinarySensorEntity):
_attr_entity_category = EntityCategory.DIAGNOSTIC
def __init__(
self, simplisafe: SimpliSafe, system: SystemV3, sensor: SensorV3
self, simplisafe: SimpliSafe, system: SystemV3, device: DeviceV3
) -> None:
"""Initialize."""
super().__init__(simplisafe, system, device=sensor)
super().__init__(simplisafe, system, device=device)
self._attr_name = "Battery"
self._attr_unique_id = f"{super().unique_id}-battery"
self._device: SensorV3
self._device: DeviceV3
@callback
def async_update_from_rest_api(self) -> None: