Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

get_battery_level() does not work for Arlo Q cameras #33

Open
tchellomello opened this issue Jul 9, 2017 · 10 comments
Open

get_battery_level() does not work for Arlo Q cameras #33

tchellomello opened this issue Jul 9, 2017 · 10 comments
Assignees
Milestone

Comments

@tchellomello
Copy link
Owner

Arlo Q cameras does not require a base station.

We will need to treat this situation and if possible get the same attributes for Arlo Q cameras too

@tchellomello
Copy link
Owner Author

Related issue: home-assistant/core#8412

@tchellomello tchellomello modified the milestones: 0.0.7, 0.0.6 Jul 20, 2017
@broox
Copy link
Collaborator

broox commented Sep 25, 2017

Can anyone with an Arlo Q camera show what the API response looks like so that we can add it to a test fixture?

@tchellomello tchellomello modified the milestones: 0.0.7, 0.0.8 Sep 26, 2017
@tchellomello tchellomello modified the milestones: 0.0.8, 0.0.9 Oct 10, 2017
@ryanwinter ryanwinter self-assigned this Oct 18, 2017
@ryanwinter
Copy link
Collaborator

ryanwinter commented Oct 18, 2017

I duplicated some work with the basestation to see if I could get something working, however I'm having some initial problems with the sseclient.

        url = SUBSCRIBE_ENDPOINT + "?token=" + self._session_token
        data = self._session.query(url, method='GET', raw=True, stream=True)
        self.__sseclient = sseclient.SSEClient(data)

data ends up being <Response> which obviously doesnt plug into the SSEClient call very well and throws an exception. Does this call return some subscription URL for the basestation?

I dont know too much about the SSEClient subscription service, but I do see this call working successfully with the device through arlo.netgear.com.

@ryanwinter
Copy link
Collaborator

I'm blocked by this at the moment, does anyone have any insight?

@tchellomello
Copy link
Owner Author

Hello @ryanwinter, what kind of error are you getting? I just ran a quick test with rpdb here and it worked to me.

telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
> /home/mdemello/devel/python-arlo/pyarlo/base_station.py(49)thread_function()
-> self.__subscribed = True
(Pdb) l
 44
 45         def thread_function(self):
 46             """Thread function."""
 47
 48             import rpdb; rpdb.set_trace()
 49  ->         self.__subscribed = True
 50             url = SUBSCRIBE_ENDPOINT + "?token=" + self._session_token
 51
 52             data = self._session.query(url, method='GET', raw=True, stream=True)
 53             self.__sseclient = sseclient.SSEClient(data)
 54
(Pdb) n
> /home/mdemello/devel/python-arlo/pyarlo/base_station.py(50)thread_function()
-> url = SUBSCRIBE_ENDPOINT + "?token=" + self._session_token
(Pdb) n
> /home/mdemello/devel/python-arlo/pyarlo/base_station.py(52)thread_function()
-> data = self._session.query(url, method='GET', raw=True, stream=True)
(Pdb) url
'https://arlo.netgear.com/hmsweb/client/subscribe?token=2_5tW9XE5l3RVbbyQ<REDACTED>

> /home/mdemello/devel/python-arlo/pyarlo/base_station.py(53)thread_function()
-> self.__sseclient = sseclient.SSEClient(data)
(Pdb) data
<Response [200]>
(Pdb) n
> /home/mdemello/devel/python-arlo/pyarlo/base_station.py(55)thread_function()
-> for event in (self.__sseclient).events():

(Pdb) dir(self._ArloBaseStation__sseclient)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_char_enc', '_event_source', '_logger', '_read', 'close', 'events']
(Pdb)

(Pdb) self._ArloBaseStation__sseclient.events()
<generator object SSEClient.events at 0x7f5254bd0830>

Where events() will only return some data from that thread in case of a notification event.

Does it make sense? What error are you getting?

@tchellomello tchellomello modified the milestones: 0.0.9, v0.10.0, v0.1.0, v0.1.1 Oct 25, 2017
@ryanwinter
Copy link
Collaborator

This makes sense, the part I'm having issues with is line 52/53. What is the purpose of line 52? I'm getting the data = "<Response [200]>", but then SSEClient throws an error with that input.

I'm still trying to get my head around the debugging here, maybe I have a bad dependency?

Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Program Files\Python36\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "D:\projects\python-arlo\pyarlo\base_station_q.py", line 54, in thread_function
    self.__sseclient = sseclient.SSEClient(data)
  File "C:\Program Files\Python36\lib\site-packages\sseclient.py", line 39, in __init__
    self._connect()
  File "C:\Program Files\Python36\lib\site-packages\sseclient.py", line 47, in _connect
    self.resp = requester.get(self.url, stream=True, **self.requests_kwargs)
  File "C:\Program Files\Python36\lib\site-packages\requests\api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Program Files\Python36\lib\site-packages\requests\api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Program Files\Python36\lib\site-packages\requests\sessions.py", line 494, in request
    prep = self.prepare_request(req)
  File "C:\Program Files\Python36\lib\site-packages\requests\sessions.py", line 437, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "C:\Program Files\Python36\lib\site-packages\requests\models.py", line 305, in prepare
    self.prepare_url(url, params)
  File "C:\Program Files\Python36\lib\site-packages\requests\models.py", line 379, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL '<Response [200]>': No schema supplied. Perhaps you meant http://<Response [200]>?

@ryanwinter
Copy link
Collaborator

Ok, so making some progress, it seems I had install sseclient, instead of sseclient-py :|

@ryanwinter
Copy link
Collaborator

Awesome, so this is pretty much as expected. The Arlo Q cameras act as their own base station.

@tchellomello
Copy link
Owner Author

@ryanwinter oh.. good to know that!! So we will need to modify the code in order to check the try to modify its behavior. Are you working on a patch to make it fully compatible with Arlo Q camera since you own them?

@Megachip
Copy link

Reference:
home-assistant/core#15026 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants