fronzbot/blinkpy

Monitor Movement Detection Alerts

drcolula opened this issue · 7 comments

Is there a function that listens and receives the movement detection notifications?

If not, I was thinking of sending requests every second to check the notifications flags, however, I don't know if the blink servers/account can handle that many requests.

I didn't want to risk it.

I configured my router to use reserved IP addresses for the camera and then used ping (node red in HA) to check if the camera is connected to the network or not. A few seconds after coming on to the network (ping success), I refresh blink and get the status. As a proxy for motion events, a successful ping is actually pretty accurate, particularly if you don't take snapshots and only have motion triggered videos.

This all works pretty well though I don't like spamming my WIFI network with ICMP packets! My plan next is to listen for DHCP chatter between camera and router and only use ping to detect disconnection from the network. I hacked it up and saw that the approach can work but I don't really know where to start to get it into HA (which has some DHCP sniffing but only for config flows).

@drcolula - I definitely would advise against 1s requests to blink. Some users have had their accounts suspended when making too many requests in a short time. To answer your other question: there is no function that will listen for and receive notifications (at least that anyone is aware of). I know IFTTT has such a function but Blink works with them directly so, without that relationship, it probably will never happen for this library.

@gee-jay-bee that's a clever approach. It would be interesting to see what type of effort would be needed to implement that in blinkpy itself 🤔

It's not clear to me whether a component in HA is allowed to "abuse" the DHCP listener offered in the core (to discover devices for config flow) to find devices over and over like this.

If yes and the discovery provides MAC address and IP address then I think it's relatively straightforward to add config to the blink integration so that it knows the MAC address of each camera. Knowing that, the DHCP discovery would then indicate when a camera comes online. Having the IP address would mean being able to ping the camera until it goes offline (avoiding the need for a static IP in the router). I guess sending ICMP ping is a problem solved already in the ping binary sensor so surely some reuse there!

All I did to test the theory was use a script using SCAPY to listen for DHCP and ping command to see that things were available in the expected order.

I wouldn't know where to start to get it into the Blink Integration. I guess the DHCP discovery could go into the blinkpy library or in the component itself if the core discovery wasnt suitable. The ping might be easier in the component from a reuse perspective? I have not really gone so deep into the HA code to know I'm afraid.

Some interesting results from my experiments:
I executed the function blink.download_videos() constantly (with a delay of 1 second) in a loop for two days, and there was no problem, it downloaded correctly the new videos while they were generated (not so many, maybe one each 2 or 3 hours).

However, when I executed the Auth function (needed in my case because I am trying a serverless approach) in a loop with a delay of 10s, after 28 successful executions, in the next one there was an error. Looking further for the problem, I discovered this message:

{"message":"Login limit exceeded. Please disable any 3rd party automation and try again in 60 minutes.","lockout_time_remaining":0,"force_password_reset":false,"allow_pin_resend_seconds":90,"code":106}

I just got this from blink and my accounts don't work:

My name is ___ and I am with the Blink team. While doing a routine server audit, your account was flagged and subsequently disabled due to unsupported scripts or apps running on your system.

The only automation that is permitted for use with the Blink system is through Alexa and/or IFTTT.

Please disable these scripts or apps and reply here once completed so that we can re-enable your account.
stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within seven days. Thank you for your contributions.

stale commented

This issue is now being closed due to inactivity.