Blink Camera as Video Doorbell

Yep, blink changed the endpoints again :man_facepalming: I don’t have any videos past May 13th with the current endpoint, but I’ve had success with the following (albeit, fields have changed which is very annoying):

/api/v1/accounts/<account_id>/media/changed?since=<time>&page=<page>

So I think you guys can fix your script by removing line 48 and adding:

url = "{}/api/v1/accounts/{}/media/changed?since={}&page={}".format(blink.urls.base_url, blink.account_id, from_time, 0)
videos = api.http_get(blink, url)['media']

Also I opened an issue here on my repo that hopefully I (or someone else :slightly_smiling_face:) can get to in short order to push out the bugfix.

Thanks @fronzbot. Unfortunately I’m seeing Cannot obtain new token for server auth. and then None is returned. I’ll do some more digging when I get some time.

Hmm, I wonder if that endpoint is region specific or something then

got it working.

  • need to set the region: https://rest-u003.immedia-semi.com (u003 is new york)
  • responseData[“videos”] ==> responseData[“media”]
  • videos[0][“address”] ==> videos[0][“media”]
  • camera_name ==> device_name

code updated: Here
Thank you @fronzbot

Just fyi, AFAIK that endpoint is only valid in the US. If you authenticate with a prde (Europe) endpoint, you will be denied access to US servers

Hey guys. I just made a pre-release for this fix. If you can test it locally to make sure it’s working, it would be HUGELY appreciated. Just install it with the following command:

pip install blinkpy==0.14.0.dev0

Fantastic! Works a treat. Thanks @fronzbot.

I had to change:

videos = api.request_videos(blink, time=from_time)["videos"]
to
videos = api.request_videos(blink, time=from_time)["media"]

and also

video_address = "{}{}".format(blink.urls.base_url, video["address"])
to
video_address = "{}{}".format(blink.urls.base_url, video["media"])

But other than that (for the purposes of this script at least) it works again :slight_smile:.

1 Like

Perfect! Thanks for checking. Hopefully it will work for a few more weeks before Blink randomly changes endpoints again lol :roll_eyes:

I did install blinkpy-0.14.0.dev0 using the pip install above and still can’t have blink back with HA. It keeps saying Error to endpoint.

@Dullage which file did you change?

Try installing the actual release: 0.14.0

The dev0 version had only some of the fixes, and DID NOT include a change that I think might be impacting you (different endpoint subdomains)

Thanks. I’m still receiving same error. I’m on 0.90.2. It was working fine before until, as mentioned, they changed the endpoint

2019-06-04 15:40:11 ERROR (Thread-4) [blinkpy.helpers.util] Endpoint https://rest.u002.immedia-semi.com/api/v3/accounts/None/homescreen failed. Possible issue with Blink servers.
2019-06-04 15:40:11 ERROR (MainThread) [homeassistant.setup] Error during setup of component blink

[blinkpy.helpers.util] Cannot connect to server with url https://rest.u002.immedia-semi.com/api/v3/accounts/None/homescreen.
2019-06-04 15:40:10 INFO (Thread-4) [blinkpy.helpers.util] Auth token expired, attempting reauthorization.
2019-06-04 15:40:10 INFO (Thread-4) [blinkpy.blinkpy] Attempting login with https://prod.immedia-semi.com/api/v2/login
2019-06-04 15:40:10 INFO (MainThread) [homeassistant.setup] Setup of domain notify took 14.7 seconds.
2019-06-04 15:40:11 INFO (Thread-4) [blinkpy.helpers.util] Cannot connect to server with url https://rest.u002.immedia-semi.com/api/v3/accounts/None/homescreen.
2019-06-04 15:40:11 ERROR (Thread-4) [blinkpy.helpers.util] Endpoint https://rest.u002.immedia-semi.com/api/v3/accounts/None/homescreen failed. Possible issue with Blink servers.
2019-06-04 15:40:11 ERROR (MainThread) [homeassistant.setup] Error during setup of component blink

Performing that pip install won’t work inside home-assistant, it’s for the folks in this thread using python directly.

This will be fixed in home-assistant in 0.94.0

1 Like

Getting the following error messages:

2019-06-12 10:33:05 INFO (SyncWorker_7) [blinkpy.blinkpy] Attempting login with https://prod.immedia-semi.com/login
2019-06-12 10:33:05 INFO (SyncWorker_7) [blinkpy.blinkpy] Attempting login with https://rest.piri.immedia-semi.com/login
2019-06-12 10:33:05 INFO (SyncWorker_7) [blinkpy.helpers.util] Cannot connect to server with url https://rest.piri.immedia-semi.com/login.
2019-06-12 10:33:05 INFO (SyncWorker_7) [blinkpy.helpers.util] Auth token expired, attempting reauthorization.

I got the error on 0.94.0. I updated to 0.94.2 and still get the error. Can anyone help?

Hi James, I replied to your thread here

OK so without being aware of this thread I implemented exactly the same solution, but instead of using a shell_command to call a python script that is accessing the HA API, I am using a python_script called from an automation. Some people might find this avoids some issues they have been having with python installations and API permissions.

"""
Capture a timestamped camera image using the service camera.snapshot.
"""
BLINK_SLEEP_TIME = 7  # seconds to wait for Blink
HA_SLEEP_TIME = 3 # seconds to wait for HA
CAMERA_ENTITY_ID = 'camera.blink_living_room'
CAMERA_NAME = 'Living_room'

now = datetime.datetime.now()
time_str = "{}_{}_{}_{}_{}_{}_{}".format(
    now.year, now.month, now.day, now.hour,
    now.minute, now.second, now.microsecond)

# Trigger a capture now
hass.services.call(
    'blink', 'trigger_camera',
    {'name': CAMERA_NAME})
time.sleep(BLINK_SLEEP_TIME)

# Update representation in HA
hass.services.call(
    'blink', 'blink_update')
time.sleep(HA_SLEEP_TIME)

# Save using snapshot
folder = '/config/www/blink_{}_'.format(CAMERA_NAME)
filename = folder + time_str + '.jpg'

hass.services.call(
    'camera', 'snapshot',
    {'entity_id': CAMERA_ENTITY_ID,
     'filename': filename})

## We need to wait for this file to be created before sending to notify pushbullet
time.sleep(HA_SLEEP_TIME)

hass.services.call(
    'notify', 'pushbullet_robin', {
        "message": "File saved : " + filename,
        "title": "blink {} notification".format(CAMERA_NAME),
        "data": {"file": filename}
    })

Note that in my case the blink camera is behind a glass window, so I am not triggering off the blink PIR sensor, but actually from an independent PIR sensor on the porch

1 Like

Thank you so much @fronzbot for the update to handle the changes to authorisation! I updated Home Assistant, clicked accept in the email Blink sent me and everything just works again :slight_smile: .

In regards to my doorbell script, I was able to exec into my Home Assistant docker container to run the script manually, I clicked accept in the email, skipped the code prompt in the console and the script completed ok. As expected, if I run it again it no longer prompts for a code (as it’s been authorised previously).

I’m not sure what identifier has been authorized here and there’s the possibility that whatever it is might change. So I’m thinking I should call the Blink class with no_prompt=True. Then, my presumption is that, if the identifier does change I’ll just get another email, the script will fail that run but will be ok on the next run. Does this logic sound correct to you?

I’m not sure what identifier has been authorized here and there’s the possibility that whatever it is might change.

The identifier that they (Blink) seem to be keying off of is the device_id property. There is a uuid field that Blink also expects at login so I assume in the future THAT will be used, but so far it looks like it’s ignored.

So I’m thinking I should call the Blink class with no_prompt=True. Then, my presumption is that, if the identifier does change I’ll just get another email, the script will fail that run but will be ok on the next run. Does this logic sound correct to you?

Yep, that sounds right to me!

EDIT- worth mentioning, since you’re initializing a Blink object in your script, you could always initialize it with your own device_id so that you have control over the identifier. It’s not required but might be helpful?

Thanks @fronzbot, adding a device_id to the script is a good idea and I’ve updated everything else as discussed. It works nicely.

I’ve also committed the changes to my Home Assistant Config repo as well so anyone interested can see the latest version of the script.

1 Like

Hi, is the integration broken?just realized that is not working

Have a read of this post: Blink Integration stopped working and can't login