Blink Camera as Video Doorbell

I’m not using node red, but I want to send it via telegram too, I need some help with this

The data structure for Telegram looks slightly different, see here: https://www.home-assistant.io/components/telegram/#video-support.

I don’t use Telegram myself so I can’t test but I think it should look something like this:

data = {
    "message": "Doorbell",
    "data": {
        "video": {
            "url": "{}/local/{}?1=1".format(
                secrets["blinkHassApiBaseURL"], VIDEO_FILENAME
            )
        }
    },
}

That works, thank you, but I get the video but not the text, sorry I’m new in python

Maybe try:

data = {
    "message": "Doorbell",
    "data": {
        "video": {
            "url": "{}/local/{}?1=1".format(
                secrets["blinkHassApiBaseURL"], VIDEO_FILENAME
            ),
            "caption": "Doorbell"
        }
    },
}

just try this, its working now, awasome, thank you

1 Like

Hi, I’m notice that my home assistant get unresponsive after trigger the script, have to reboot the container, any thoughts?this is the log after i run the script before get unresponsive

2019-04-22 21:08:56 INFO (ThreadPoolExecutor-0_0) [pycec] Looking for new devices...

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 0)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 0)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 1)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 1)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 2)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 2)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 3)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 3)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 4)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 4)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 5)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 5)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 6)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 6)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 7)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 7)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 8)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 8)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 9)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 9)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 10)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 10)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 11)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 11)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 12)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 12)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 13)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 13)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:08:56 ERROR (ThreadPoolExecutor-0_0) [asyncio] Exception in callback functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 14)

handle: <Handle functools.partial(<bound method HDMINetwork._after_polled of <pycec.network.HDMINetwork object at 0x7fe4ccbdf780>>, 14)>

Traceback (most recent call last):

File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run

File "/usr/local/lib/python3.7/site-packages/pycec/network.py", line 345, in _after_polled

self._device_status[device] = task.result()

File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 73, in _poll_device

self.transmit(PollCommand(device))

File "/usr/local/lib/python3.7/site-packages/pycec/tcp.py", line 92, in transmit

self._transport.write(("%s\n" % command.raw).encode())

AttributeError: 'NoneType' object has no attribute 'write'

2019-04-22 21:09:01 ERROR (MainThread) [ngrok_init] <urlopen error [Errno 111] Connection refused>

2019-04-22 21:09:07 ERROR (MainThread) [ngrok_init] <urlopen error [Errno 111] Connection refused>

2019-04-22 21:09:07 INFO (MainThread) [homeassistant.components.automation] Executing doorbell

2019-04-22 21:09:07 INFO (MainThread) [homeassistant.helpers.script] Script doorbell: Running script

2019-04-22 21:09:07 INFO (MainThread) [homeassistant.helpers.script] Script doorbell: Executing step call service

Are you running HassIO or your own Docker container? If the latter then I would suggest maybe trying to run the script from within the Docker container to see how it gets on i.e. run…

command docker exec -it <container name> /bin/bash

…to get a Shell and then run the script in there.

If you’re using HassIO then I can’t really help troubleshoot as I’ve never used it.

1 Like

Ok thank you, I’m using hassio on Docker, it’s strange tough, it was working before, I’m not set the camera yet, so I been testing it, I realized yesterday that stops working and make hassio unresponsive

1 Like

Hmm, anyone else seeing issues over the last few days?

I’m not getting any videos through so I did some digging. Running api.request_videos with a time value a few days ago shows the latest video being dated mid-day yesterday. The app however shows lots of videos since then. Not sure where things are going wrong here.

same thing here. haven’t been getting anything since 3 days ago and haven’t got time to look into it yet.

Must be an API change, I’ll have a look when I get a chance.

Maybe something for @fronzbot to be aware of.

Yep, blink changed the endpoints again :man_facepalming: I don’t have any videos past May 13th with the current endpoint, but I’ve had success with the following (albeit, fields have changed which is very annoying):

/api/v1/accounts/<account_id>/media/changed?since=<time>&page=<page>

So I think you guys can fix your script by removing line 48 and adding:

url = "{}/api/v1/accounts/{}/media/changed?since={}&page={}".format(blink.urls.base_url, blink.account_id, from_time, 0)
videos = api.http_get(blink, url)['media']

Also I opened an issue here on my repo that hopefully I (or someone else :slightly_smiling_face:) can get to in short order to push out the bugfix.

Thanks @fronzbot. Unfortunately I’m seeing Cannot obtain new token for server auth. and then None is returned. I’ll do some more digging when I get some time.

Hmm, I wonder if that endpoint is region specific or something then

got it working.

  • need to set the region: https://rest-u003.immedia-semi.com (u003 is new york)
  • responseData[“videos”] ==> responseData[“media”]
  • videos[0][“address”] ==> videos[0][“media”]
  • camera_name ==> device_name

code updated: Here
Thank you @fronzbot

Just fyi, AFAIK that endpoint is only valid in the US. If you authenticate with a prde (Europe) endpoint, you will be denied access to US servers

Hey guys. I just made a pre-release for this fix. If you can test it locally to make sure it’s working, it would be HUGELY appreciated. Just install it with the following command:

pip install blinkpy==0.14.0.dev0

Fantastic! Works a treat. Thanks @fronzbot.

I had to change:

videos = api.request_videos(blink, time=from_time)["videos"]
to
videos = api.request_videos(blink, time=from_time)["media"]

and also

video_address = "{}{}".format(blink.urls.base_url, video["address"])
to
video_address = "{}{}".format(blink.urls.base_url, video["media"])

But other than that (for the purposes of this script at least) it works again :slight_smile:.

1 Like

Perfect! Thanks for checking. Hopefully it will work for a few more weeks before Blink randomly changes endpoints again lol :roll_eyes:

I did install blinkpy-0.14.0.dev0 using the pip install above and still can’t have blink back with HA. It keeps saying Error to endpoint.

@Dullage which file did you change?