Blink Camera support

I know this topic has been discussed before.. and I also know IFTTT has some Blink support as well.

But, I'm wondering if there's anyone who'd be willing to write a Hubitat driver for Blink which uses this unofficial REST API - GitHub - MattTW/BlinkMonitorProtocol: Unofficial documentation for the Blink Wire-Free HD Home Monitoring & Alert System

I tested it and it does work. I'm thinking about including it directly in my Android dashboard as well but honestly it'd be a lot better if it were supported on the Hub instead.

The REST API allows for a few things like:

  • arm/disarm system
  • get thumbnail image for a camera
  • view RTSP stream

Even just the arm/disarm logic would be nice..

Anyway, just wanted to ask the question!

thanks
joe

4 Likes

I will take a look at it this weekend. I have a couple Blink cameras myself and it would be nice to add them in one way or another, although I had not even thought of it before. Plus some of my other API driver attempts are ending in failure so it would be good to have a success.

8 Likes

please would love to use blink with hubitat

1 Like

Same here.

The new policy of 3 free from IFTTT make it unusable for me. It takes one rule to arm and another to disarm. I have 2 sets of camera, meaning I would need 4 rules to use them.

I realy hope something could be done about it.

1 Like

You may also want to know about other libraries on GitHub. I found the below informative:

I'm guessing the hard(er) part of this is that every new device login requires a PIN verification code. Maybe there's other drivers like this - but seems like that would be somewhat tricky.

I too would really like Blink integration especially with IFTTT going the way it has.
Fingers crossed some clever individual can put something together.

2 Likes

I am not as worried about the PIN. It requires email verification, then the PIN will be entered in the driver. So some user error is likely but I will try to document the steps.

UPDATED:
Successfully requested the PIN and getting an email with it to validate it. Stumbling a bit at the validation step though (the formatting of the POST back is getting me I think).

1 Like

You would do it in the app where, once the id was successful another page would pop-up for the access code (if not already entered).

I remember having issues getting it to validate FWIW.. I forgot what the issue was - but I do have a shell script that goes the login and validation - here's a snippet:

function printVerifyBody() {
    cat <<EOF
    {
      "pin": "${PIN}"
    }
EOF
}

function verifyPin() {
    curl --request POST \
        --header 'content-type: application/json' \
        --header "token-auth: $TOKEN" \
        --data "$(printVerifyBody)" \
        --url https://rest-$REGION.immedia-semi.com/api/v4/account/$ACCT/client/$CLIENT/pin/verify
}

I think what tripped me up was an extra comma in the JSON body

2 Likes

Need to take a break from it for tonight...
Your function samples match up with what I have been trying from the API sample, but I am having no success. I get an "401 = Unauthorized" for the http.
When trying CURL (to see about different formats and just to match up with the API sample and your functions, I get an Invalid PIN response.

Frustrating to feel like it is so close and thinking I must just have a formatting/typo somewhere (thus why I tried the CURL also).

1 Like

Same thing happened to me and I couldn't figure it out.. I was about to give up and realized the JSON I was sending had an extra comma in it.

dunno if this will help.. i got the login and verify to work using this script I wrote. My goal was to prompt for the email/password and then automatically set the values for CLIENT/ACCOUNT/REGION/etc.. but, instead I had to first login and then update the script to set those values.

I'm not sure the best way to send JSON data that has variables in it in a curl command -- hence the functions to print out the JSON..

#!/bin/sh

EMAIL=
PASS=

ACCT=
CLIENT=
PIN=
TOKEN=
REGION=

function printLoginBody() {
    cat <<EOF
    {
      "unique_id": "00000000-0000-0000-0000-000000000000",
      "email": "${EMAIL}",
      "password": "${PASS}"
    }
EOF
}

function login() {
    curl -X POST \
        -H 'Content-Type: application/json'  \
        --data "$(printLoginBody)" \
        --url https://rest-prod.immedia-semi.com/api/v4/account/login
}

function printVerifyBody() {
    cat <<EOF
    {
      "pin": "${PIN}"
    }
EOF
}

function verifyPin() {
    curl --request POST \
        --header 'content-type: application/json' \
        --header "token-auth: $TOKEN" \
        --data "$(printVerifyBody)" \
        --url https://rest-$REGION.immedia-semi.com/api/v4/account/$ACCT/client/$CLIENT/pin/verify
}

function fetchDevices() {
    curl --request GET \
        --header 'content-type: application/json' \
        --header "token-auth: $TOKEN" \
        --url https://rest-$REGION.immedia-semi.com/api/v3/accounts/$ACCT/homescreen
}

echo
echo
echo "Select from the options below:"
select ans in login verifyPIN fetchDevices exit
do
    case $ans in
        login)
            login
            break;
            ;;
        verifyPIN)
            verifyPin
            break;
            ;;
        fetchDevices)
            fetchDevices
            break;
            ;;
        exit)
            exit;
            ;;
    esac
done
1 Like

Following! This would be helpful for me as well. I have two Blink hubs (indoor and outdoor) and arm/disarm based on geofencing/time of day. Would be good to move this off IFTTT and make it local (without have to set up yet another hub RPi; etc!)

The biggest challenge will be receiving timely motion alerts from the cloud without using an external link of some sort. Information I see shows no broadcast from the Cloud, instead frequent polling. I can see Hubitat providing 30 second latency unless you can get a webSocket interface to Blink working or you use a node.js computer or account on (yet another) web product.

Note: If you have an Amazon Alexa account, you should be able to (1) arm/disarm and (2) receive motion alerts from a camera system linked to Amazon Alexa. I can work out instructions for this (I would have to reinstall my old camera system and link to Alexa to test the concept).

Dave

As far as I'm aware Alexa can only arm/disarm via voice commands. It is not possible using Alexa Routines.

Really. You should be able to use a routine that uses the motion alert. See below from Aug of last year

Since it seems like most people have examples using curl (which I have never used before now) I tried using it to see what happens then I felt I would be able to make the driver replicate it. I already had the portion to request the PIN working, so I started with a curl command to do the equivalent figuring that once I had one figured out, the other should be similar...

I have replaced any "identifying" information in the below examples with variable names.

This will successfully trigger a PIN request:

curl --request POST --url https://rest-prod.immedia-semi.com/api/v4/account/login --header "content-type: application/json" --data "{'unique_id': '${ UNIQUE ID HERE }', 'password':'${ PASSWORD }','email':'${ EMAIL }'}"

However, the huge number of variants submitting the PIN verification are failing (either Unauthorized Access 101, or more typically an Invalid PIN with code 1621 response). Any idea on the correct structure of the curl for that part? I have tried 15 different variants so at this point I figure it is just something simple and I need a different pair of eyes to look at it. Here is a sample of one (that failed) that I had the most hope for:

curl --request POST --url https://rest-prod.immedia-semi.com/api/v4/account/${ ACCT# }/client/${ CLIENT# }/pin/verify --header "content-type: application/json" --header "token-auth:${ TOKEN }" --data '{"pin":"${ PIN }"}'
1 Like

It would be nice to get the actual motion outputs directly, instead of having to bounce them through Alexa.

Even nicer would be the ability to get the temperature and the light level from them.

1 Like

I have created some rough examples using my old TP-Link cloud device as a template. It may be more familiar.

def getTokenExample(eMail, password) {
	def data = [
		unique_id: "00000000-0000-0000-0000-000000000000",
		email: "${eMail}",
 		password: "${password}"
	]
	def params = [
		uri: "https://rest-prod.immedia-semi.com/api/v4/account/login",
		contentType: 'application/json',
		headers: ['Accept':'application/json; version=1, */*; q=0.01'],
		body : new groovy.json.JsonBuilder(data).toString()
	]
	httpPostJson(params) {resp ->		//	Can also try httpPost
		log.trace resp.status
		log.trace resp.data
		//	if successful, the token would be in the response text.  Example
		//	state.token = resp.data.result.token
		//	Region, Account, and Client should also be in the response somewhere.
		//	state.region = ...........
		//	state.account = ..............
		//	state.client = .........................
	}
}

def enterTokenExample() {
	//	Variables are in form ${variableName}
	def token = state.token	//	from getTokenExample
	def region = "enter region from the example"	//	REGION FROM EXAMPLE
	def account = "enter the account from the example"	//	ACCT from example
	def client = "enter client from the example"
	def data = [
		pin: "${PIN}"	//	FROM PHONE.
		//	This is a potenial error point.  The PIN is entered here as a string, does the app expect a number?
		//	if so, it would be pin: PIN
	]
	def params = [
		uri: "https://rest-${region}.immedia-semi.com/api/v4/account/${account}/client/${client}/pin/verify",
		contentType: 'application/json',
		headers: [token-auth: token],
		body : new groovy.json.JsonBuilder(data).toString()
	]
	httpPostJson(params) {resp ->		//	Can also try httpPost
		log.trace resp.status
		log.trace resp.data
	}
}

def fetchDevices() {
	//	Variables are in form ${variableName}
	def token = state.token	//	from getTokenExample
	def region = "enter region from the example"	//	REGION FROM EXAMPLE
	def account = "enter the account from the example"	//	ACCT from example
	def client = "enter client from the example"
	
	def params = [
		uri: "https://rest-${region}.immedia-semi.com/api/v3/accounts/${account}/homescreen",
		contentType: 'application/json',
		headers: [token-auth: token]
	]
	httpGet(params) {resp ->
		log.trace resp.status
		log.trace resp.data
	}
}
2 Likes

Welcome to the community!

You should be able get all these directly from the cloud. The latency for the motion detection will be dependent on how frequently you send the get command to the cloud. This latency will NOT be instantaneous. I can see ever 15 or 30 seconds, but more frequently may cause hub performance issues.

This is a designer issue. However, using Amazon is an alternate that would reduce Hubitat load for motion detection.

Dave

1 Like