[PROJECT] Driver for Blink API

I ended up removing and re-adding just to start over.. requested PIN and still waiting for the PIN email to arrive - 10 mins so far.

While waiting I was watching the logs I ran another PIN request.. I noticed this time that the cameras (3) and sync module were added even though I haven't entered the Client PIN yet. Could the driver be saving some of this info even though I removed and re-installed?

Also, I tried to use the refresh command but the log rightly pointed out I hadn't entered the PIN yet.

dev:3432020-09-23 10:38:33.156 am errorBlink - Select the Request PIN command to request a PIN be emailed to you from Blink.
dev:3432020-09-23 10:38:03.820 am debugBlink - addChild(Camera-89002)
dev:3432020-09-23 10:38:03.336 am debugBlink - addChild(Camera-88989)
dev:3432020-09-23 10:38:02.860 am debugBlink - addChild(Camera-88951)
dev:3432020-09-23 10:38:02.357 am debugBlink - addChild(SyncModule-67329)
dev:3432020-09-23 10:36:45.554 am infoBlink - Requesting PIN for validation.
dev:3432020-09-23 10:35:34.753 am debugBlink - Driver version up to date
dev:3432020-09-23 10:35:34.177 am infoBlink - Updated
dev:3432020-09-23 10:32:20.954 am infoBlink - Requesting PIN for validation.

Would it be possible to schedule a randomised token refresh every 23 hours or so. If it is a randomised time it would save thrashing the blink servers with everyone updating at the exact same time. Give them less reason to get annoyed and potentially stop the activity.

1 Like

I plan on building it into the DailyCheck() which is scheduled based on the time you last Saved Preferences. Considering the sleep schedules for most users I bet it will seem pretty random. Even if there were hundreds of us, that would be inconsequential compared to the app.

1 Like

To be honest I have no idea how it did that. If you remove the parent device it loses the ClientID. My guess is that Blink really does not use that much then, and just recognizes your account... Which might explain the lack of a PIN emailed to you and the fact the other areas worked. It could not possibly add devices unless it got data back which means your auth-token was valid.

1 Like

If anyone likes examples, here is one that appears to be working as intended:

3 Likes

I'm going to remove the device, reboot the hub and start over. Is it possible the auth token wasn't getting cleared when I removed the device? Maybe it was still using that which ultimately is all I needed to stay logged-in (even though I never set the email PIN through the UI)

I'm trying a simple webcore piston to schedule a RequestPIN. Do I also need to do a VerifyPIN?

That is a good shout. Having written a couple of utils that work with Blink, they can be a little sensitive to people abusing their servers and infrastructure. Anything that can be done to make the HE interactions look like their mobile app is definitely a good thing!

2 Likes

Well, I removed the device and restarted HE. Re-added the device and entered email/pass, save prefs, request PIN and nothing. At least this time it didn't create the child camera devices so I assume it's not using any saved data.

Anyway, as a last resort I went and found the PIN they emailed me yesterday when I initially added the device and entered it. I think it worked because it re-created all of the cameras/sync/network child devices.

However, trying to arm the system failed so it's clearly not in a happy place :slight_smile:

Here's my log if it helps:

## I tried to arm system here ##
dev:3482020-09-23 03:33:02.193 pm errorBlink - 202 from Blink

## below logs happened after I entered yesterday's PIN and hit verify PIN ##
dev:3552020-09-23 03:32:13.306 pm infoSyncModule-67329 - Updated
dev:3552020-09-23 03:32:13.303 pm infoSyncModule-67329 - State variables cleared
dev:3552020-09-23 03:32:13.299 pm infoSyncModule-67329 - Installed
dev:3542020-09-23 03:30:38.505 pm infoCamera-89002 - Updated
dev:3542020-09-23 03:30:38.490 pm infoCamera-89002 - State variables cleared
dev:3542020-09-23 03:30:38.485 pm infoCamera-89002 - Installed
dev:3532020-09-23 03:30:38.140 pm infoCamera-88989 - Updated
dev:3532020-09-23 03:30:38.138 pm infoCamera-88989 - State variables cleared
dev:3532020-09-23 03:30:38.100 pm infoCamera-88989 - Installed
dev:3492020-09-23 03:30:37.861 pm infoCamera-88951 - Updated
dev:3492020-09-23 03:30:37.858 pm infoCamera-88951 - State variables cleared
dev:3492020-09-23 03:30:37.844 pm infoCamera-88951 - Installed
dev:3502020-09-23 03:30:37.836 pm infoNetwork-39640 - Updated
dev:3502020-09-23 03:30:37.832 pm infoNetwork-39640 - State variables cleared
dev:3502020-09-23 03:30:37.814 pm infoNetwork-39640 - Installed
dev:3482020-09-23 03:30:37.274 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.272 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.268 pm errorBlink - Exception in addChild: java.lang.IllegalArgumentException: A device with the same device network ID exists, Please use a different DNI
dev:3482020-09-23 03:30:37.269 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.268 pm errorBlink - Exception in addChild: java.lang.IllegalArgumentException: A device with the same device network ID exists, Please use a different DNI
dev:3482020-09-23 03:30:37.267 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.266 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.264 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.262 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.260 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.260 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.258 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.256 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.255 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.253 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.251 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.237 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.236 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.236 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.234 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.233 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.233 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.230 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.228 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.225 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.223 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.222 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.221 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.221 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.220 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.218 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.218 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.215 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.215 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.213 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.212 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.211 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.210 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.208 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.206 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.195 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.202 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.201 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.199 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.197 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.195 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.193 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.192 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.190 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.187 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.185 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:37.183 pm errorBlink - Video Event Data null
dev:3482020-09-23 03:30:33.082 pm infoBlink - Updated

Here's my state variables too if it helps:

Verified : true
AccountID : <snip>
Tier : u008
Version : 0.1.3
Network : [39640]
Driver : BlinkAPI
ClientID : 5552890-195-7550-4067-<snip>
AuthToken : <snip>
AuthorizationFailures : 0
Client : <snip>

It looks to me like when you removed the parent it did not remove the original children.

That old PIN should not work. They are only going to be valid for 40 minutes. Plus you have all those video events for some reason.

At this point there is a lot going on. I need to check on this when I get home tonight and can work on it directly.

1 Like

Agreed, although I try to be nice with any API I am working with. Part of the reason everything is manual by default at this time and I am not even adding faster than a 5 minute refresh rate. Most things are being designed to only check once a day also.

2 Likes

I'm happy to help test! Next time I'll set the log level to trace before starting so there's more for you to see

1 Like

This is great, thanks! This was the last IFTTT app I had that I really needed.

1 Like

Ok... so that 202 error that triggered stuff is not REALLY an error. I had never heard of it but it basically appears to mean that the server accepted your request but did not complete it yet. So I added it to be recognized for that portion and had it mention to "try again".

I also updated the Video Events area (I do not HAVE any on my account as of this moment, so the initial logging method was a guess which is obviously wrong).

Lastly, I changed the child devices add error to try to be better about errors... but it really looks like somehow one stuck around. Which is REALLY odd because the driver uninstall area is pretty thin. If you uninstall, it looks for ANY child device for that parent and deletes. No debate and no real complications to it.

New versions are posted:
BlinkAPI.groovy = 0.1.4
BlinkChild.groovy = 0.1.2

Changes are:

  • Correction to Video Events logging
  • Minor adjustments to child device handling
  • Added (but not all) variables for Camera Info reporting
  • Update event on parent device
3 Likes

I updated - added a new device and removed it (just to make sure any children got removed). Re-added and tried to get a PIN but it never arrived.

Any thoughts?

dev:3572020-09-23 08:51:12.961 pm traceBlink - Login response = {"account":{"id":<SNIP>,"verification_required":false,"new_account":false},"client":{"id":<SNIP>,"verification_required":false},"authtoken":{"authtoken":"<SNIP>","message":"auth"},"region":{"tier":"u008","description":"United States","code":"us"},"lockout_time_remaining":0,"force_password_reset":false,"allow_pin_resend_seconds":60}
dev:3572020-09-23 08:51:12.410 pm infoBlink - Requesting PIN for validation or reauthorizing auth-token.

I hadn't tried to get the PIN since this afternoon and I've only requested it maybe 5 times today total.. the Blink app works fine too

Is this an expected response? It's almost like it's saying it doesn't need me to enter a PIN..

last note for tonight.. it actually seems like I don't need to enter a PIN at all! I did a homescreen command and watched the logs and it looks like everything was fetched and created just fine.

I also was able to arm and disarm the system.. thanks for adding that note in the logs "Blink - Request accepted but not completed. Please try again."


Next up - individually enabling/disabling motion detection on a given camera. I entered the camera ID but that command failed (404). Where do I enter the network ID which is being sent as '/null/'?
image

dev:3572020-09-23 09:09:06.416 pm errorBlink - 404 from Blink
dev:3572020-09-23 09:09:06.105 pm traceBlink - Enable Motion Params = [uri:https://rest-u008.immedia-semi.com/network/null/camera/88951/enable, headers:[token-auth:SNIP]

You cannot manually enter the Network ID in such a case, it should be listed as a state variable within the camera. I did notice I had both Network ID AND NetworkID states... but they had the same value. In any case I am posting version 0.1.5 which should standardize on Network ID and hopefully solve that problem.

As for the Verification Required... maybe it is saying it does not need the PIN validation because your account has done it before. The problem with this is that since there is no API documentation from Blink there is really no way of knowing and they could change things at a whim.

In any case:
BlinkAPI.groovy version 0.1.5 is now posted. Only change is to standardize the Network ID state.

2 Likes

that worked!

1 Like

I'm trying to think through how I can use the Blink cameras on my dashboard. My app uses the MakerAPI to get all devices/attributes/commands.

I see 3 cameras (type=BlinkChild) and 1 type=BlinkAPI device. Only the BlinkAPI device has the commands such as arm/disarm/enable motion/etc. The camera devices have a bunch of attributes but none of these commands.

Ideally, each camera would have some commands which can be applied just to the camera - like enable/disable motion detection, get thumbnail, video, etc (future stuff I know..).

Anyway, it seems like I'm going to need to display a dashboard tile for the overall Blink system and 1 for each camera. It'd be really nice if I could use that Thumbnail File image for the dashboard tile. That would make it clear which camera is which

  {
    "name": "Blink",
    "label": "Blink",
    "type": "BlinkAPI",
    "id": "357",
    "date": "2020-09-25T00:51:00+0000",
    "model": null,
    "manufacturer": null,
    "capabilities": [
      "Refresh",
      "Sensor",
      "Actuator"
    ],
    "attributes": {
      "ClientID": null,
      "dataType": "STRING",
      "values": null,
      "Driver": null,
      "Updated": "2020-09-24T00:42:59+00:00",
      "Version": "Patch development 0.1.5 version"
    },
    "commands": [
      {
        "command": "ArmSystem"
      },
      {
        "command": "DisableMotionDetection"
      },
      {
        "command": "DisarmSystem"
      },
      {
        "command": "EnableMotionDetection"
      },
      {
        "command": "GetCameraInfo"
      },
      {
        "command": "GetCameraUsage"
      },
      {
        "command": "GetHomescreen"
      },
      {
        "command": "GetNetworks"
      },
      {
        "command": "GetNotifications"
      },
      {
        "command": "GetVideoEvents"
      },
      {
        "command": "RequestPIN"
      },
      {
        "command": "VerifyPIN"
      },
      {
        "command": "refresh"
      }
    ]
  },
    {
    "name": "Camera-88951",
    "label": "Camera-88951",
    "type": "BlinkChild",
    "id": "359",
    "date": "2020-09-24T13:23:57+0000",
    "model": null,
    "manufacturer": null,
    "capabilities": [
      "TemperatureMeasurement",
      "Battery",
      "Sensor"
    ],
    "attributes": {
      "Account": null,
      "dataType": "NUMBER",
      "values": null,
      "Account ID": null,
      "Alert Interval": null,
      "Alert Repeat": null,
      "Alert Tone Enable": null,
      "Arm String": null,
      "Armed": null,
      "Auto Arm By Geo": null,
      "Auto Arm By Time": null,
      "Battery Alert Account": null,
      "Battery Alert Count": null,
      "Battery Check Time": null,
      "Battery Number": "3",
      "Battery Status": "ok",
      "Battery Voltage": null,
      "Busy": null,
      "Camera Error": null,
      "Clip Bitrate": null,
      "Clip Seconds": null,
      "Clip Warning Threshold": null,
      "Created": null,
      "Daylight Savings Time": null,
      "Enabled": null,
      "Encryption Key": null,
      "Feature Plan ID": null,
      "Firmware Version": null,
      "ID": null,
      "Illuminator Duration": null,
      "Illuminator Intensity": null,
      "Issues": "[]",
      "LFR Alert Count": null,
      "LFR Channel": null,
      "LFR Strength": "5",
      "Last HB": null,
      "Last Snapshot Event": null,
      "LiveView Mode": null,
      "LiveView Seconds": null,
      "Liveview Bitrate": null,
      "Local Storage Compatible": null,
      "Local Storage Enabled": null,
      "Local Storage Status": null,
      "Manufacturer Mez Type": null,
      "Max Resolution": null,
      "Motion Detection Enabled": "false",
      "Motion Sensitivity": null,
      "Name": "front door",
      "Network ID": "39640",
      "Network Key": null,
      "Network Origin": null,
      "NetworkID": null,
      "Onboarded": null,
      "Ping Interval": null,
      "Privacy Zones Compatible": null,
      "Record Audio Enable": null,
      "SM Backup Enabled": null,
      "Serial": null,
      "Snapshot Enabled": null,
      "Status": "done",
      "Storage Total": null,
      "Storage Used": null,
      "Sync Module Error": null,
      "Temp Adjust": null,
      "Temp Alerts Enabled": null,
      "Temperature Alert Count": null,
      "Thumbnail": null,
      "Thumbnail File": "fw_7.96__Zi7psW4H_2020_09_18__12_44PM.jpg",
      "Thumbnail Image": null,
      "Time Zone": null,
      "Type": "xt2",
      "Updated": "2020-09-23T22:57:59+00:00",
      "Usage": null,
      "Usage Rate": "false",
      "Video Description": null,
      "Video History Count": null,
      "Video Length": null,
      "Video Quality": null,
      "Video Recording Optional": null,
      "WiFi Strength": "5",
      "WiFi Timeout": null,
      "battery": null,
      "temperature": "75"
    },
    "commands": [
      {
        "command": "Clear"
      }
    ]
  },
1 Like

Download the Hubitat app