twrecked / pyaarlo

Asynchronous Arlo Component for Python
GNU Lesser General Public License v3.0
50 stars 34 forks source link

Failed to read current modes correctly #99

Open m0urs opened 2 years ago

m0urs commented 2 years ago

Since a few weeks I do have again the problem, that my script is no longer correctly reading the current mode of my camera and my lights. After the first connect to Arlo, the modes are read correctly. If I then change the mode via the script, the mode is changed correctly also, but then, if I try to reread the current mode, it does not reflect the current one but still the old one.

It looks rather similar to this older issue https://github.com/twrecked/pyaarlo/issues/77.

Basically what my script is doing:

# Get the base object for the device
base = getDeviceFromName("Base",arlo.base_stations)
# Set the mode for the device to the specified value
base.mode = 'disarmed'

The above does work correctly. If I check with the Arlo app, the mode is set to the correct value.

# Get the base object for the device
base = getDeviceFromName("Base",arlo.base_stations)
# Get the current mode for that device
status = base.mode

This does not work. The "status" is still the one it had after the initial connect to Arlo and the initial reading of the state.

I enclose a debug file which has the following timestamps:

Before setting the mode: 2022-07-02 14:09:13,655
After setting the mode: 2022-07-02 14:10:08,375
Before getting the mode: 2022-07-02 14:11:37,357 
After getting the mode: 2022-07-02 14:11:51,436 

I am logging in with the following parameters:

arlo = pyaarlo.PyArlo(username=username, password=password,tfa_source='imap', tfa_type='email', tfa_host=tfa_host, tfa_username=tfa_username, tfa_password=tfa_password, synchronous_mode=False, refresh_devices_every=1,reconnect_every=90, stream_timeout=180, request_timeout=120, user_agent='arlo', verbose_debug=True)

Could you please have a look, if you can see, why this is no longer working? I did not change anything on my side and it worked a few months this way.

Thanks a lot.

UPDATE:

It seems that even setting the modes are most of the time working, but not always ...

[Uploading debug-encrypted.log…]()

Jopand commented 2 years ago

In my setup it seems that modes are wrong in HA, if I use MQTT backend in aarlo. If I revert to SSE it seems to work.

m0urs commented 2 years ago

Thanks. I was not aware of the "backend" parameter in PyArlo. Just tried to switch from ""mqtt" to "sse" and will try for some time to see if this improves something.

m0urs commented 2 years ago

I can confirm that changing the backend from "mqtt" to "sse" solved the issues for me. It seems now reliable again.

Jopand commented 2 years ago

I really don't think this issue should be closed. Because if I switch to "sse" backend, I cannot get livestream from HA. That works with "mqtt"... So it would be very nice to get this fixed. The backend switching was just meant to be a clue to where the bug might be

Jopand commented 2 years ago

@m0urs could you please reopen the issue?? It is still a bug

m0urs commented 2 years ago

Reopened because the issue still seems to exist if the backend is set to "mqtt". For me with "sse" backend it is working correctly.

Jopand commented 2 years ago

Is live streaming working for you when using sse? Because I can only get live streaming when using mqtt, and that's why I would reslly like to get this mode-issue solved

m0urs commented 2 years ago

I cannot tell you. I am only using pyArlo to control the states of my cameras from within my FHEM home automation environment. E.g. switch them off if I open the door to the garden etc.

twrecked commented 2 years ago

@Jopand Can you get some traces of what happens when you start live streaming? I'd like to see the difference.

This describes how to turn on the debug.

And this explains how to encrypt the output. You only need to include the output around the time things fails.

Jopand commented 2 years ago

Will do today or tomorrow 👍

Jopand commented 2 years ago

Not working log. Backend set to "sse" https://pastebin.com/5wQjkYW5

twrecked commented 2 years ago

Thanks, I got that. Can you attach one where it works?

edit: can you also paste in your config? Or tell me what the user_agent is. And can you tell me what you are trying to stream on to.

and can you add the lovelace card configuration.

Thanks!

edit #2; I think I'm seeing something similar here, I think they changed the protocol; I'll look some more. It still works with direct streaming.

Jopand commented 2 years ago

I just tried to make a log of a working stream. I cannot make any live stream work through Home Assistant now. I get the same error in the log with invalid data:

2022-07-31 21:48:25 DEBUG (ArloEventStream) [pyaarlo] mqtt: connected=0 2022-07-31 21:48:25 DEBUG (ArloEventStream) [pyaarlo] topcs= [] 2022-07-31 21:48:26 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.aarlo_carport] Error from stream worker: Error opening stream (INVALIDDATA, Invalid data found when processing input) rtsps://arlostreaming01-z1-prod.wowza.arlo.com:443/vzmodulelive/59U17C7MB102A_EDITED_BY_ME?egressToken=542522EDITED_BY_ME&userAgent=iOS&cameraId=59U17EDITED_BY_ME&txnId=be!d17afd9EDITED_BY_ME

twrecked commented 2 years ago

My feeling is Arlo has changed their backend tto remove RTSP support - they don't need it any more since they swapped to mpeg-dash.

If you use the aarlo lovelace card you can try direct viewing, that still works for me here.

Jopand commented 2 years ago

I have direct stream. It just doesn't work when the backend is sse:

entity: camera.aarlo_indkorsel
image_click: stream
image_view: direct
name: Alrum
show:
  - motion
  - sound
  - snapshot
  - battery_level
  - signal_strength
  - captured_today
  - image_date
top_date: false
top_status: false
top_title: false
type: custom:aarlo-glance
twrecked commented 2 years ago

You traces are showing it's not using direct; see the piece userAgent=iOS in the stream open request, it would use linux if it was trying direct. And the stream worker won't be starting.

Can you try saving that config and trying once based off this example configuration, your current config looks like a mix of old style and new style and I wonder if that is confusing it.

edit: expand link

Jopand commented 2 years ago

It worked... \o/ Thanks