-
-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arlo: add basestation and basestation siren + other tweaks (#636)
* configure stream refresh * use modelId directly * bump 0.6.8 * lower refresh rate to 20 min * basestations as DeviceProviders + various type annotations * reorder * trickle discover basestations to avoid clobbering cameras * generalize device creation + start of siren * functional basestation siren * bump 0.7.0 for beta
- Loading branch information
Showing
10 changed files
with
306 additions
and
125 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from scrypted_sdk import ScryptedDeviceBase | ||
from scrypted_sdk.types import DeviceProvider, ScryptedInterface, ScryptedDeviceType | ||
|
||
from .device_base import ArloDeviceBase | ||
from .siren import ArloSiren | ||
|
||
|
||
class ArloBasestation(ArloDeviceBase, DeviceProvider): | ||
siren: ArloSiren = None | ||
|
||
def get_applicable_interfaces(self) -> list: | ||
return [ScryptedInterface.DeviceProvider.value] | ||
|
||
def get_device_type(self) -> str: | ||
return ScryptedDeviceType.DeviceProvider.value | ||
|
||
def get_builtin_child_device_manifests(self) -> list: | ||
return [ | ||
{ | ||
"info": { | ||
"model": f"{self.arlo_device['modelId']} {self.arlo_device['properties'].get('hwVersion', '')}".strip(), | ||
"manufacturer": "Arlo", | ||
"firmware": self.arlo_device.get("firmwareVersion"), | ||
"serialNumber": self.arlo_device["deviceId"], | ||
}, | ||
"nativeId": f'{self.arlo_device["deviceId"]}.siren', | ||
"name": f'{self.arlo_device["deviceName"]} Siren', | ||
"interfaces": [ScryptedInterface.OnOff.value], | ||
"type": ScryptedDeviceType.Siren.value, | ||
"providerNativeId": self.nativeId, | ||
} | ||
] | ||
|
||
async def getDevice(self, nativeId: str) -> ScryptedDeviceBase: | ||
if not nativeId.startswith(self.nativeId): | ||
# must be a camera, so get it from the provider | ||
return await self.provider.getDevice(nativeId) | ||
|
||
if nativeId.endswith("siren"): | ||
if not self.siren: | ||
self.siren = ArloSiren(nativeId, self.arlo_device, self.arlo_basestation, self.provider) | ||
return self.siren | ||
|
||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from scrypted_sdk import ScryptedDeviceBase | ||
|
||
from .logging import ScryptedDeviceLoggerMixin | ||
from .util import BackgroundTaskMixin | ||
from .provider import ArloProvider | ||
|
||
class ArloDeviceBase(ScryptedDeviceBase, ScryptedDeviceLoggerMixin, BackgroundTaskMixin): | ||
nativeId: str = None | ||
arlo_device: dict = None | ||
arlo_basestation: dict = None | ||
provider: ArloProvider = None | ||
stop_subscriptions: bool = False | ||
|
||
def __init__(self, nativeId: str, arlo_device: dict, arlo_basestation: dict, provider: ArloProvider) -> None: | ||
super().__init__(nativeId=nativeId) | ||
|
||
self.logger_name = nativeId | ||
|
||
self.nativeId = nativeId | ||
self.arlo_device = arlo_device | ||
self.arlo_basestation = arlo_basestation | ||
self.provider = provider | ||
self.logger.setLevel(self.provider.get_current_log_level()) | ||
|
||
def __del__(self): | ||
self.stop_subscriptions = True | ||
self.cancel_pending_tasks() | ||
|
||
def get_applicable_interfaces(self) -> list: | ||
"""Returns the list of Scrypted interfaces that applies to this device.""" | ||
return [] | ||
|
||
def get_device_type(self) -> str: | ||
"""Returns the Scrypted device type that applies to this device.""" | ||
return "" | ||
|
||
def get_device_manifest(self) -> dict: | ||
"""Returns the Scrypted device manifest representing this device.""" | ||
parent = None | ||
if self.arlo_device.get("parentId") and self.arlo_device["parentId"] != self.arlo_device["deviceId"]: | ||
parent = self.arlo_device["parentId"] | ||
|
||
return { | ||
"info": { | ||
"model": f"{self.arlo_device['modelId']} {self.arlo_device['properties'].get('hwVersion', '')}".strip(), | ||
"manufacturer": "Arlo", | ||
"firmware": self.arlo_device.get("firmwareVersion"), | ||
"serialNumber": self.arlo_device["deviceId"], | ||
}, | ||
"nativeId": self.arlo_device["deviceId"], | ||
"name": self.arlo_device["deviceName"], | ||
"interfaces": self.get_applicable_interfaces(), | ||
"type": self.get_device_type(), | ||
"providerNativeId": parent, | ||
} | ||
|
||
def get_builtin_child_device_manifests(self) -> list: | ||
"""Returns the list of child device manifests representing hardware features built into this device.""" | ||
return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
from scrypted_sdk.types import BinarySensor, ScryptedInterface | ||
|
||
from .camera import ArloCamera | ||
from .provider import ArloProvider | ||
|
||
|
||
class ArloDoorbell(ArloCamera, BinarySensor): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
def __init__(self, nativeId: str, arlo_device: dict, arlo_basestation: dict, provider: ArloProvider) -> None: | ||
super().__init__(nativeId=nativeId, arlo_device=arlo_device, arlo_basestation=arlo_basestation, provider=provider) | ||
|
||
self.start_doorbell_subscription() | ||
|
||
def start_doorbell_subscription(self): | ||
def start_doorbell_subscription(self) -> None: | ||
def callback(doorbellPressed): | ||
self.binaryState = doorbellPressed | ||
return self.stop_subscriptions | ||
|
||
self.register_task( | ||
self.provider.arlo.SubscribeToDoorbellEvents(self.arlo_basestation, self.arlo_device, callback) | ||
) | ||
|
||
def get_applicable_interfaces(self): | ||
def get_applicable_interfaces(self) -> list: | ||
camera_interfaces = super().get_applicable_interfaces() | ||
camera_interfaces.append(ScryptedInterface.BinarySensor.value) | ||
|
||
model_id = self.arlo_device['properties']['modelId'].lower() | ||
model_id = self.arlo_device['modelId'].lower() | ||
if model_id.startswith("avd1001"): | ||
camera_interfaces.remove(ScryptedInterface.Battery.value) | ||
return camera_interfaces | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.