Migrate SimpliSafe to new web-based authentication (#57212)

This commit is contained in:
Aaron Bach 2021-10-19 14:09:48 -06:00 committed by GitHub
parent 8e0cb5fcec
commit bf7c99c1f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 366 additions and 388 deletions

View file

@ -1,7 +1,9 @@
"""Support for SimpliSafe binary sensors."""
from __future__ import annotations
from simplipy.entity import Entity as SimplipyEntity, EntityTypes
from simplipy.device import DeviceTypes
from simplipy.device.sensor.v2 import SensorV2
from simplipy.device.sensor.v3 import SensorV3
from simplipy.system.v2 import SystemV2
from simplipy.system.v3 import SystemV3
@ -23,25 +25,25 @@ from . import SimpliSafe, SimpliSafeBaseSensor
from .const import DATA_CLIENT, DOMAIN, LOGGER
SUPPORTED_BATTERY_SENSOR_TYPES = [
EntityTypes.carbon_monoxide,
EntityTypes.entry,
EntityTypes.glass_break,
EntityTypes.leak,
EntityTypes.lock_keypad,
EntityTypes.motion,
EntityTypes.siren,
EntityTypes.smoke,
EntityTypes.temperature,
DeviceTypes.carbon_monoxide,
DeviceTypes.entry,
DeviceTypes.glass_break,
DeviceTypes.leak,
DeviceTypes.lock_keypad,
DeviceTypes.motion,
DeviceTypes.siren,
DeviceTypes.smoke,
DeviceTypes.temperature,
]
TRIGGERED_SENSOR_TYPES = {
EntityTypes.carbon_monoxide: DEVICE_CLASS_GAS,
EntityTypes.entry: DEVICE_CLASS_DOOR,
EntityTypes.glass_break: DEVICE_CLASS_SAFETY,
EntityTypes.leak: DEVICE_CLASS_MOISTURE,
EntityTypes.motion: DEVICE_CLASS_MOTION,
EntityTypes.siren: DEVICE_CLASS_SAFETY,
EntityTypes.smoke: DEVICE_CLASS_SMOKE,
DeviceTypes.carbon_monoxide: DEVICE_CLASS_GAS,
DeviceTypes.entry: DEVICE_CLASS_DOOR,
DeviceTypes.glass_break: DEVICE_CLASS_SAFETY,
DeviceTypes.leak: DEVICE_CLASS_MOISTURE,
DeviceTypes.motion: DEVICE_CLASS_MOTION,
DeviceTypes.siren: DEVICE_CLASS_SAFETY,
DeviceTypes.smoke: DEVICE_CLASS_SMOKE,
}
@ -49,7 +51,7 @@ async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up SimpliSafe binary sensors based on a config entry."""
simplisafe = hass.data[DOMAIN][DATA_CLIENT][entry.entry_id]
simplisafe = hass.data[DOMAIN][entry.entry_id][DATA_CLIENT]
sensors: list[BatteryBinarySensor | TriggeredBinarySensor] = []
@ -81,7 +83,7 @@ class TriggeredBinarySensor(SimpliSafeBaseSensor, BinarySensorEntity):
self,
simplisafe: SimpliSafe,
system: SystemV2 | SystemV3,
sensor: SimplipyEntity,
sensor: SensorV2 | SensorV3,
device_class: str,
) -> None:
"""Initialize."""
@ -104,7 +106,7 @@ class BatteryBinarySensor(SimpliSafeBaseSensor, BinarySensorEntity):
self,
simplisafe: SimpliSafe,
system: SystemV2 | SystemV3,
sensor: SimplipyEntity,
sensor: SensorV2 | SensorV3,
) -> None:
"""Initialize."""
super().__init__(simplisafe, system, sensor)