Closed robweber closed 5 years ago
Hey @robweber,
Calling GetDevices()
without any arguments returns all of your devices, but I can see how it would be useful to be able to filter on more than one device type at a time. I'm open to that change. Please shoot me a PR.
Thanks!
Awesome, will do. My eventual goal is to get the Kodi maintainer of the addon too support more device types so rather than filtering out what they don't want I'm hoping this change will motivate them to add more types without doing additional filtering on their end. I'll tag this issue when I submit the PR - thanks!
Cool beans! I appreciate the help.
While you're at it, I was thinking it might be useful to add an option to filter provisioned
devices.
def GetDevices(self, device_type=None, device_state=None):
"""
This method returns an array that contains the basestation, cameras, etc. and their metadata.
If you pass in a valid device type ('basestation', 'camera', etc.), this method will return an array of just those devices that match that type.
"""
devices = self.request.get('https://my.arlo.com/hmsweb/users/devices')
if device_type:
devices = [ device for device in devices if device.get('deviceType'). in device_type]
if device_state:
devices = [ device for device in devices if device.get("state") in device_state]
return devices
Pretty much have this all done and tested. Before submitting one question on the device state. How many device states are there? Mine are all provisioned so I'm not sure. Just wondering if the states are "provisioned/unprovisioned" would the arg be better off as a boolean?
#in this one "True" meaning only return provisioned, "False" being all devices?
def GetDevices(self, device_type=None, filter_provisioned=False):
I'm not 100% sure. I think it's just those two cases. If you want to go that route, I would default to None
and make None
return all devices, True
provisioned, and False
unprovisioned.
def GetDevices(self, device_type=None, filter_provisioned=None):
Going to close this out since you merged in the change.
Would it be possible to pass in an array of device types to GetDevices instead of just the one? I have an ArloQ as well as Arlo Pro units so the "camera" type doesn't return everything. I'd need to use 2 calls to GetDevices() for each specific type. Since the deviceType filter is done post HTTP call this seems a bit inefficient.
Looking at your code would you perhaps be open to passing in an array of types instead of just the string? You could still maintain backwards compatibility if necessary. I haven't tested this but some rough code could be like the following:
If you're open to this modification I could submit a pull request. I didn't examine the library in detail to see if this would affect other places in your code.
What version of Python are you using (
python -V
)?Part of Kodi so Python 2.7 - using Arlo Streamer Addon
What operating system and processor architecture are you using (
python -c 'import platform; print(platform.uname());'
)?Architectures differ, Windows and Linux
Which Arlo hardware do you have (camera types - [Arlo, Pro, Q, etc.], basestation model, etc.)?
Arlo Pro and ArloQ