Piston to act as backup for changes to Blink cam settings


#1

1) Give a description of the problem
I use RBoy’s Blink camera integration with ST to change several settings on my Blink camera when location mode changes occur (and I have a couple routines that trigger the mode changes).

I’ve noticed that sometimes one or more of the Blink settings doesn’t always get changed even though the routine executed and the mode changed. I believe it’s due to some random timeouts on Blink’s servers.

2) What is the expected behavior?
I want WebCoRE to watch for a good morning routine to occur, and then after five minutes have passed, if any of the settings did not update, WebCoRE should update them.

Basically what I want to happen is:

When routine A occurs, wait five minutes,
If setting B hasn’t changed, take action X
If setting C hasn’t changed, take action Y
If setting D hasn’t changed, take action Z

If all the settings were changed when the routine occurred, do nothing

3) What is happening/not happening?
WebCoRE sees the routine, and then immediately makes one of the setting changes (monitor off). The other settings do not change. Then the piston is finished.

I’m sure I’m approaching this all wrong, I really don’t know anything about coding this kind of stuff beyond a very simple If-then statement. So any input is appreciated, and if it makes more sense to start over from scratch, that’s fine. Thanks!

4)


#2

A couple things I notice.

The if statement on line 22-23. This will not cause a wait. Basically it is checking if the monitor status changed in the last 5 minutes.
You should add a new action above all these ifs to get a 5 minute wait.

You continually nest your if statements. So your second one will only check if the one before it was false and so on.

All the checks should be immediately in the then statement of the first if.


#3

Thanks for your input.

OK, I assumed as much when I saw that the monitor action was being taken right away (since it was more than 5 mins since the monitor status had last changed, but not since the routine ran).

I’m not quite sure how to add an action that only does “wait five minutes” but I’ll play around with it.

I realize that part of the piston is probably all wrong. I think what I was going for was something like

If routine runs
(and if monitor status hasn’t changed 5 mins later, then turn off monitor)
(and if motion sensitivity setting hasn’t changed 5 mins later, then set motion sensitivity to 7)
(and if video length hasn’t changed 5 mins later, then set video length to 10 seconds)

Clearly that’s not how it turned out though.


#4

Here’s another try at it. I’m getting closer but still not quite there.

The piston starts when the routine executes, and then waits a minute.

But the piston never runs the if-then statement in 21-30. It could be I set the wrong condition, I’m not sure.

The other two actions that come next are running. But strangely, it’s setting the motion sensitivity to a value other than 7. It keeps changing to 9 in the Blink app. The setvideolength part works.


#5

Do you have the logging set to full? Also turn the trace on. That will show visual bars next to conditions that were evaluated and whether they were true/false.

The motion sensitivity might just be getting the correct arguments passed to it.


#6

Thanks, I need to run it again with fuller logging.

I checked with another piston that the state of the monitor on/off is the right condition to watch, and that I can turn it on/off too with a different trigger.

So it’s something about the logic in the first part. I’m probably trying to use the wrong comparator, and it’s never really checking for the status of the Blink monitor.

I’ll have to figure out what the right value is to send for motion sensitivity.


#7

I set the Blink camera so that the Monitor was on, motionsensitivity 1, and videolength 30 sec. This is what the log showed at that point.

10/28/2017, 1:13:46 PM +294ms
+2ms	╔Starting piston... (v0.2.0fb.20171026)
+328ms	║╔Subscribing to devices...
+396ms	║║Subscribing to ****.routineExecuted.38984ced-4bf6-4120-b992-6bb36f4e1482...
+476ms	║║Subscribing to ******...
+477ms	║╚Finished subscribing (151ms)
+503ms	║Comparison (string) null executes (string) :4b876b5ff0da261af8c124d69fcd0fff: = false (6ms)
+526ms	║Comparison (string) on is (string) On = false (1ms)
+554ms	║Comparison (string) 8 is_different_than (integer) 7 = true (8ms)
+570ms	║Comparison (string) 3 is_different_than (integer) 10 = true (2ms)
+584ms	╚Piston successfully started (584ms)
Clear Full 

I ran the piston and it didn’t work that well. Here’s a screenshot with the trace. And the log below it.

10/28/2017, 1:27:42 PM +459ms
+1ms	╔Received event [******].time = 1509211663727 with a delay of -1269ms
+363ms	║RunTime Analysis CS > 218ms > PS > 114ms > PE > 31ms > CE
+374ms	║Runtime (39891 bytes) successfully initialized in 114ms (v0.2.0fb.20171026) (372ms)
+375ms	║╔Execution stage started
+422ms	║║Comparison (string) 3 is_different_than (integer) 10 = true (10ms)
+424ms	║║Condition #23 evaluated true (20ms)
+425ms	║║Condition group #20 evaluated true (state did not change) (21ms)
+427ms	║║Cancelling statement #21's schedules...
+3403ms	║║Executed physical command [*********].setVideoLength([10]) (2965ms)
+3404ms	║║Executed [*********].setVideoLength (2973ms)
+3408ms	║╚Execution stage complete. (3032ms)
+3415ms	╚Event processed successfully (3415ms)

10/28/2017, 1:27:31 PM +238ms
+1ms	╔Received event [*******].time = 1509211652482 with a delay of -1244ms
+153ms	║RunTime Analysis CS > 32ms > PS > 88ms > PE > 32ms > CE
+165ms	║Runtime (39888 bytes) successfully initialized in 88ms (v0.2.0fb.20171026) (163ms)
+166ms	║╔Execution stage started
+192ms	║║Comparison (string) on is (string) On = false (1ms)
+194ms	║║Condition #13 evaluated false (13ms)
+195ms	║║Condition group #8 evaluated false (state did not change) (14ms)
+215ms	║║Comparison (string) 8 is_different_than (integer) 7 = true (10ms)
+217ms	║║Condition #19 evaluated true (18ms)
+218ms	║║Condition group #14 evaluated true (state did not change) (20ms)
+221ms	║║Cancelling statement #15's schedules...
+2478ms	║║Executed physical command [*********].setMotionSensitivity([6]) (2253ms)
+2479ms	║║Executed [*********].setMotionSensitivity (2255ms)
+2483ms	║║Cancelling statement #17's schedules...
+2487ms	║║Executed virtual command wait (0ms)
+2488ms	║║Requesting a wake up for Sat, Oct 28 2017 @ 1:27:43 PM EDT (in 10.0s)
+2494ms	║╚Execution stage complete. (2327ms)
+2495ms	║Setting up scheduled job for Sat, Oct 28 2017 @ 1:27:43 PM EDT (in 9.994s)
+2510ms	╚Event processed successfully (2510ms)

10/28/2017, 1:22:32 PM +361ms
+1ms	╔Received event [*****].routineExecuted = 38984ced-4bf6-4120-b992-6bb36f4e1482 with a delay of 35ms
+88ms	║RunTime Analysis CS > 11ms > PS > 49ms > PE > 28ms > CE
+98ms	║Runtime (39893 bytes) successfully initialized in 49ms (v0.2.0fb.20171026) (97ms)
+99ms	║╔Execution stage started
+109ms	║║Comparison (string) :4b876b5ff0da261af8c124d69fcd0fff: executes (string) :4b876b5ff0da261af8c124d69fcd0fff: = true (2ms)
+110ms	║║Cancelling condition #24's schedules...
+111ms	║║Condition #24 evaluated true (6ms)
+112ms	║║Cancelling condition #1's schedules...
+113ms	║║Condition group #1 evaluated true (state changed) (9ms)
+115ms	║║Cancelling statement #6's schedules...
+119ms	║║Executed virtual command wait (0ms)
+120ms	║║Requesting a wake up for Sat, Oct 28 2017 @ 1:27:32 PM EDT (in 300.0s)
+125ms	║╚Execution stage complete. (27ms)
+127ms	║Setting up scheduled job for Sat, Oct 28 2017 @ 1:27:32 PM EDT (in 299.995s)
+142ms	╚Event processed successfully (141ms)

#8

I figured out why the monitorstatus wasnt working. I input “On” when it should have been “on” without a capital O. Now that part works fine. And the set video length is good too.

So now it’s just that motionsensitivity, which is running but ends up with the wrong number in the blink app.


#9

Good catch. Hopefully the motion sensitivity is simple. Test other values and see what it ends up as


#10

Had to let it go for a few days as I was traveling.

But I just got it all sorted out.

I hadn’t noticed at first when creating a task there was a dropdown menu for adding different types of parameters.

I think it had defaulted to a string but when I tried adding an integer instead, it seems to work now.

Thanks for your suggestions!


#11

@marktheknife can you share the piston with us? Thanks


#12

Sure here you go.


#13

Once I got that one working, I made a similar piston to change the settings when my goodnight routine runs too.


#14

@marktheknife thanks for the pistons or you using your Blink also as a motion sensors? If so how are you doing it? Thanks.


#15

No, that’s just what the snapshot button on the WebCoRE dashboard does when you take a pic of the piston. I think it does that to anonymize the names of the devices in the piston so it can be shared with others while minimizing certain privacy concerns.