[PROJECT] Driver for Blink API

Updated Version(s):

  • BlinkAPI.groovy = 0.2.3

Change(s):

  • Corrected switch behavior. Before MiniCameras were on/off with Motion, but that cannot be controlled from them. They CAN Arm/Disarm though and that is what their on/off command did, so I made it so the switch properly triggers off that now.
  • Altered way Armed System(s) were being populated during arming/disarming
2 Likes

Hi @snell - I'm using the latest drivers and noticed if I view a camera device in HE and hit "Disarm System" button nothing happens.

I captured the logs and it appears it's calling "/arm" and not "/disarm" (assuming that's the name of the disarm command but maybe not).

dev:3642020-11-20 01:02:55.888 pm traceBlink - Child Event: Arm String = Armed
dev:3642020-11-20 01:02:55.874 pm traceBlink - Child Event: Armed = true
dev:3642020-11-20 01:02:55.847 pm traceBlink - Child Event: Arm String = Armed
dev:3642020-11-20 01:02:55.833 pm traceBlink - Child Event: Armed = true
dev:3642020-11-20 01:02:55.806 pm traceBlink - Child Event: Arm String = Armed
dev:3642020-11-20 01:02:55.791 pm traceBlink - Child Event: Armed = true
dev:3642020-11-20 01:02:55.763 pm traceBlink - Child Event: switch = on
dev:3642020-11-20 01:02:55.751 pm traceBlink - Child Event: Arm String = Armed
dev:3642020-11-20 01:02:55.740 pm traceBlink - Child Event: Armed = true
dev:3642020-11-20 01:02:55.728 pm traceBlink - Child Event: Updated = Fri Nov 20 13:02:55 EST 2020
dev:3642020-11-20 01:02:55.670 pm traceBlink - Event: Updated = Fri Nov 20 13:02:55 EST 2020
dev:3642020-11-20 01:02:55.665 pm traceBlink - General Response: data: [Method:Arm System, ID:39640], resp.data: hubitat.scheduling.AsyncResponse@3f404e
dev:3642020-11-20 01:02:54.926 pm traceBlink - Arm System Params = https://rest-u008.immedia-semi.com/api/v1/accounts/XXX/networks/39640/state/arm

The cameras are armed. Looking at the state variables on the camera page I see "Armed = true" but also see some mismatched/duplicated string variables too

Arm String : Disarmed
Armed : true
...
Motion Detection Enabled : true
Name : front door
Network ID : 39640
Type : xt2
Updated : 2020-11-18T17:14:57+00:00
battery : 75
switch : on
temperature : 59
Arm String : Armed
Arm String : Disarmed
Arm String : Armed
Arm String : Disarmed
Arm String : Armed

Thanks! Found the culprit easy enough.

Updated Version(s):

  • BlinkChild.groovy = 0.1.11

Change(s):

  • Fix for the Disarm System command. Basically a copy/paste error left it so that Cameras and MiniCameras were always calling the ArmSystem on the parent NOT the DisarmSystem like they should have been.

Are you saving the files as UTF-8 ?
image
I'm assuming this should be °F ?

It is saved in iso-8859-1 because I have had problems with that before on my various weather related API drivers.

I am not seeing that happening this time though. I just checked the driver again in my browser and then loaded it on a Hubitat that does not have it and I still see the normal degree symbol (°).

Ok maybe it a linux thing then... my system uses UTF-8 globally. I always have to scan driver/app code to fix these issues.

Yeah, I had that problem over and over again until I switched the format on my webserver to iso-8859-1. I still have to open the file, reopen it with the correct iso, then paste in the updated one from my Hubitat... Very annoying. But if I do not, the degree symbol always turns into something odd. I try to remember to check for it every time just to be sure also but sometimes I forget which is what I thought might have happened this time. So thanks for checking about it just to make sure!

1 Like

It's a shame that many programs do not test for the encoding bit. HE should but I guess its not possible when you use import as that is a raw import.

Hi, maybe a very stupid question but my camera's report the temperature in Fahrenheit. How can I change to Celsius? Thanks!

The cameras in general report in Fahrenheit but the driver is SUPPOSED to convert it to whatever temperature scale your Hubitat is set as (on the Settings - Locations & Modes - Temp Scale). If it is not doing so... that would be a problem and an annoying one because I have reused this code in a BUNCH of drivers without issue prior (and even using it to convert from C to my native F when testing the UK's Met service for example). Let me know if the Hubitat is correct and there is still and issue with it. I want to make sure something like this works.

The place the driver handles it is on line 2110 (where it takes the returned temperature and sends it through the ConvertTemperature function at line 2850).

I've had the same problem (shows F value not converted to C) since I started using this. At one point I hard-coded the conversion but stopped doing it after a few updates. My other temperature sensors are all fine.

My cameras report temperature correctly in C

Edit: Spoke too soon. Did a homescreen and now it reports in F

Now I am lost!

If I do a refresh on the parent device, my camera report the correct temp but in F.
If I do a get camera info on the child device the correct temp in C appears for a second then change to a odd number which is neither correct in C nor in F.

Like @Evilborg the code is showing � instead of ° in the driver code. I don't know what to do with that.

Edit: I change the � for "&deg" and the symbol is showing fine but it did nothing for the value tho.

Ok dokey then. Obviously a problem here. I will have to take a look tomorrow and see if I can figure out why. What is really odd is that all the methods that provide temperature all do it through the process devices, that same line 2110. So for it to be providing different temperatures...

One quick question ymerj. For the odd number... could you send me the number the parent showed, then the number the child showed? I wonder if one is being passed from the API as C, I think it is F, and try to convert it to C making it worse...

You are all using C and it is set that way on your hub... I think I need to convert my hub for a bit while I am doing these tests tomorrow and also see what the API reports if I switch what the Blink app says my temperature scale... Lots to do. But tomorrow. It has been a long day already.

Thanks for pointing out the problem folks! I appreciate knowing about them so I can fix them.

1 Like

Updated Version(s):

  • BlinkAPI.groovy = 0.2.4

Change(s):

  • Temperature conversion should be fixed now. If you were using F you would never have noticed. But users of C would have seen intermittent results where the value should be correct if they used CameraInfo but became incorrect as soon as a GetHomescreen was run. This is because temperature data can come back in not 1, not 2, but (at least) 3 different places. I handled 2 but the third that was coming in (as part of Signals data) was slipping through and not being converted. I tried it a bunch of times on mine with my Hubitat set for C and it seems to work now. The conversion numbers all proved correct (I have a past with some temperature conversion, but rather than "trust myself" I ran every sample through a conversion calculator). Plus the API only appears to provide F. Even switching the scale in the app did not alter what was returned in my tests.

Different Topic(s):

  • Trying a different upload format for the file today. Let me know if the degree symbol still turns into something weird. That is NOT something I can change about the driver unless I just remove it entirely. It is purely how the text encoding goes onto the webserver as opposed to what my browser thinks it is when I copy it from the Hubitat driver code window.

Symbol showing ok.
Temperature correct and in C after refresh.
But odd number still show up after get camera info. (see events from 2 camera):

Yes it is minus 6 here in Canada.

I'm seeing the same. When you hit GetCameraInfo you can see the Temperature change in the Current States and it goes up and then back down again to what it should be within a second. It is showing C now though :smiley:

Minus six "sounds" cold until I see the degrees C. Then I think of when I was testing and it was a nice warm 39 (F) but that showed as only 3.88 (C). Once you folks hit -18 (C) then I start to think of it as a bit cold out. :slight_smile:

As for the odd temperatures... I found the "troublemaker". It was the "last_connect" data that comes back in a CameraInfo. It includes past data that was overriding the existing data (and getting overwritten) causing the bump. It is now fixed (I am now ignoring that data, no known value to it anyways).

Updated Version(s):

  • BlinkAPI.groovy = 0.2.5

Change(s):

  • Now ignoring the "last_connect" data from CameraInfo responses instead of tossing it into the ProcessDevices. The data was older and was causing overwrite issues (it would overwrite current data and be overwritten as well) for extra events with no value.

Temperature measurement fixed! Thank you!

1 Like

Maybe just one more remark on the Celsius temperature: the decimals are always the same, ie x.11, x.22, x.33, x.44 etc. Probably how the camera's report them. Can it be rounded off to maybe one decimal?