Blink Camera as Video Doorbell

Which version of the script are you using? The one from my repo or the one from this Gist?

UPDATE: The repo version of the script is now up to date so I have deleted the Gist.

I was using this

Just tried the new one but without any luck.
getting the token was ok, but right after the I see

<Response [401]>

update: tried the new repo (updated) and still getting the 401 error.

Might be a regional difference? What country are you in?

really? I am in US.

It’s certainly still working fine for me so I can imagine it’s something like that.

There is a good chance they use a different host name in the US than they do here in the UK. The host for getting the token is already different to that to get the video.

The only thing I can suggest is tracing what host your Blink phone app is talking to using a proxy app like Fiddler (that’s how I figured it out for the UK).

Will try that and report back. Thanks a lot.

There are different api endpoints per region (prde for Europe is the only one I remember off the top of my head) but sometimes they send you to different servers on login (I’ve seen prod and u003 for US, as an example). You can use the blinkpy library (which is what the homeassistant component is built on) to replace some methods in this script and then it will be region agnostic.

Basically, using this library will automatically grab the correct region when you login so you don’t even have to worry about it. There’s also a built in method to download videos as well, for what it’s worth.

1 Like

Got it working. Thanks a lot. ya I got the region code from here and then it was all good. THanks all.

btw fronzbot: I know hassio has the component that can download the latest video. However from my testing, it doesn’t always grab the latest. sometime the video downloaded was hours ago. I never could get the latest. Hence digging into python code now.

That sounds like a bug with the component- what version did you test with?

At any rate, I was specifically talking about the ability to download videos using the library itself inside a standalone python script. To login, and then retrieve videos from all cameras since some arbitrary date…say March 20th of this year, you’d just use the following code (off the top of my head):

from blinkpy import blinkpy

blink = blinkpy.Blink(username="yourusername", password="yourpassword")
blink.download_videos("/some/path", since="2019/03/20", camera="all")

So a lot of all that extra stuff is just built into the library to make api calls easier.

I am using version 0.90.1 (Hassio), now with the python script so everything is working great. Just thought it’d be nice if I could just use the built-in component. thanks anyway.

Hi can you share how you managed to do it in hassio? thanks

same process as Dullage mentioned (see the first post). you do need to add/modify the code so it deals with the region properly. I can definitely put up the updated code if you need.

That would be awesome, thank you

hi, can you share your updated code?thanks

I’ve just pushed an update to my script that uses @fronzbot’s great blinkpy library (as much as I could replace anyway). Hopefully this should solve the region issue for anyone using it.

Note: I currently offset the time by 1 hour (and 1 minute) as it appears the Blink API doesn’t account for this. Might not be an issue in your country so just change OFFSET_SECONDS = 3660 to OFFSET_SECONDS = 60

1 Like

:thinking: Interesting. This actually sounds like the root cause of @efurban’s problem with the home-assistant configuration (and thus a bug with my library). I’m not sure I ever handle timezones when checking for latest videos… I’ll have to dig into that to see what I can fix.

2 Likes

Sorry for the delay. It’s my first time contributing here. The script, the shell command config, and the NodeRed Workflow are all Here

About the script:

  • It is based on Dullage’s previous code. Thank you Dullage!
  • Handles region
  • Added logging
  • Added filename as an input argument
  • Removed iOS notification

How I am using it with nodered:

  • Define a shell command in HA
    – blink: python3 /config/blink/blink.py {{videoFilename}}
  • In NodeRed: Door Open --> Delay 30 secs --> Use moment to generate a filename with the current timestamp --> call the shell command with the filename arg
    –> send the video via telegram

Let me know if you have any quesgtions.

1 Like

Thank you, I will tested, just got the code from dullage now

Awasome, I get the notification, but not the video, I’m using telegram, could be that the cause ?