fronzbot / blinkpy

A Python library for the Blink Camera system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't arm/disarm more than one camera at a time

iamds opened this issue · comments

commented

Describe the bug
When I try to arm/disarm more than one camera, only the first camera is armed/disarmed. Is this due to calling the api too quickly?

To Reproduce
Steps to reproduce the behavior:

blink = Blink()
auth = Auth(json_load("/home/username/creds.json"))
blink.auth = auth
blink.start()

blink.cameras["camera1"].arm = True
blink.cameras["camera2"].arm = True

This will only arm camera1

Expected behavior
I would expect camera1 and camera2 to be armed

blinkpy version (not needed if filling out Home Assistant version):
blinkpy 0.16.3

Yes this is intended behavior. The arm API call is internally throttled to prevent accounts from getting suspended. You should add a delay of a minimum of 5s (10s recommended)

commented
blink = Blink()
auth = Auth(json_load("/home/username/creds.json"))
blink.auth = auth
blink.start()

blink.cameras["camera1"].arm = True
time.sleep(30)
blink.cameras["camera2"].arm = True

also only arms 1 camera

How are you checking that the arm call succeeded/failed?

commented

I'm viewing it in the app

commented

without the sleep, it will only arm the first camera.
with the sleep it will arm the first camera if both are disarmed, on a second run it will arm the second camera because the first camera is already armed

It takes some time for changes to be updated in the app. I've had to close out and open before to see updates. The arm API endpoints are camera-specific so one camera needing another to be armed before it is armed doesn't make sense here

commented

Do you have an example that you know works?

commented

My full app is:

from blinkpy.blinkpy import Blink
from blinkpy.auth import Auth
from blinkpy.helpers.util import json_load
import time

blink = Blink()
auth = Auth(json_load("/home/pi/blinkcredentions.json"))
blink.auth = auth
blink.start()

print("")
for name, camera in blink.cameras.items():
    print(name + str(camera.arm))
print("")

time.sleep(30)
blink.cameras["back"].arm = False
blink.refresh()
print("")
for name, camera in blink.cameras.items():
    print(name + str(camera.arm))
print("")

time.sleep(30)
blink.cameras["hallway"].arm = False
blink.refresh()
print("")
for name, camera in blink.cameras.items():
    print(name + str(camera.arm))
print("")

and this outputs:

hallwayTrue
frontTrue
backTrue
porchTrue


hallwayTrue
frontTrue
backFalse
porchTrue


hallwayTrue
frontTrue
backFalse
porchTrue

Add a small delay (say 10s) right before the call to refresh and see if the output changes at all.

commented

It's inconsistent. Sometimes it works, sometimes it doesn't

That would be a blink server throttling problem then. It's a constant struggle. In general, the longer you wait between calls the more reliable the output. I'm going to close this again since it appears to just be a problem with too many API calls in rapid succession causing calls to be ignored on the blink server. Let me know if you run into any other data points suggesting a bug with the library 👍

commented

Thanks Kevin!