Door bell with pi camera and motion detection

Ive been trying to get HA or python to send photo’s to my phone via pushbullet.
I can do it on my HA pi (Raspberry Pi 3) through a python script, but cant shell_command the script from HA.

I cant seem to install the pushbullet.py module on the zero w .Ikeep getting-

ImportError: cannot import name IncompleteRead

When I run
sudo pip install pushbullet.py

sudo pip3 install pushbullet.py

works fine

But the programme I have is for python2 so will be looking into converting my code to python 3

The point is though why did it work on my pi3 and not the zero W?

I havent looked into this because all my HA notifications are through pushbullet , and the telegram bot looks more involved in getting it to work.

Saying that , due to the difficulties I posted above RE Pushbullet I might give telegram a go.

https://home-assistant.io/components/notify.telegram/

I got telegram to work finally,
setup a telegram account here
https://web.telegram.org

Setup a bot from here (Click on botfather and follow the prompts)
https://core.telegram.org/bots#6-botfather

When bot is setup you will get a token.
You will also need user ID Type the following into your browser , replacing TOKEN with the token you were just given.

https://api.telegram.org/botTOKEN/getUpdates

If the first couple of times the response is empty , keep trying.
You should get 3-4 lines of JSON

The chat id you need is the first instance of
from":{"id":12345678

The string of numbers is the ID you need.
Insert the following into your config.yml and insert your token in the api_key and id in the chat_id.

  - name: tele_doorbell
    platform: telegram
    api_key: ########insert your token########
    chat_id: 123456

My automation for the doorbell being pressed as follows

# Doorbell button Automation
  - alias: Doorbell Pressed
    trigger:
      platform: state
      entity_id: binary_sensor.doorbell_button
      to: 'on'
    action:
     service: notify.tele_doorbell
     data:
       title: Home Assistant Notification
       message: --Doorbell Pressed--
       data:
         photo:
           - url: http://1.2.3.4/camera/recent.jpg
             caption: Doorbell View

It works a treat.

2 Likes

It works with a still image.
I save the image to /var/www/html/camera/recent.jpg

then retrieve remotely with http://1.2.3.4/camera/recent.jpg
insert the ip of the pi storing the data.
You might need to install apache if it isnt already.

point 4 Is what I seem to be struggling with , still unsure of which method to use.
Do you mean face recognition or detection ? or both lol?

I’ve had a couple of situations when packages just wouldn’t install on a pi. Best bet is to download the latest firmware for the pi and have another go

Face detection is a start, don’t want an image of the back of someone’s head after all this effort :joy:

This is essentially what I do at the moment with my hikvisions, when motion is detected and Im not at home or its late at night, I setup an automation calling a script that will take 3 images from my hikvision cameras (with 1 second in between each image) and sent to me via telegram. I do this for security - if someone is breaking into my home, they can take all my HA equipment and security equipment and then i have no reference.

1 Like

Does the Pi Zero W have a way to interface a button and use MQTT to send to HA? Is this how it is done now?
Ideally it would be best to interface to as little components as possible.

As an alternate, I have seen some people use a fibaro sensor and turn that into a doorbell alert to interface to their HA system, but this was without a Pi for camera functions. This assumes having a zwave controller. Other options is to use a 8266 with something like espeasy to interface a doorbell switch. This is very easy to setup, but it introduces another components and ideally I would like to have the pi zero control this function.

In in Australia and no local distributors that stock the pi zero w as yet… looks like i might be waiting for a little while.

Was just watching this YT video on openCV and he makes a IMG download of opencv ready to go for a PI.
Not having a zero w, I cant test it but might be worth having a look for testing…

https://www.youtube.com/watch?v=1I4gHpctXbU

Here is the IMG download - should be able to intall this on the SD card and everything ready to go:
https://drive.google.com/file/d/0B11p78NlrG-vZzdJLWYxcU5iMXM/view

Some of the content from the video is hosted here (faces.xml etc):
https://github.com/shantnu/FaceDetect

1 Like

Pi zero has the gpio (you have to solder the headers on) .Also has bluetooth and wifi built in, so everything we need to interface wirelessly.

I like the look of Telegram, it even has Siri support, I will definitely look into it further.
Another option would be messenger

https://home-assistant.io/components/notify.facebook/

https://developers.facebook.com/docs/messenger-platform/send-api-reference/image-attachment

I suppose Telegram could also be used to send commands to HA using Siri. That would be cool!

I thought about sending images to cloud storage as well so if the camera or pi at the door is damaged for whatever reason, you still have the images stored remotley. thats a little way off for now , I want to start on the face detection /recognition, or communication side of things now. these are the steepest hurdles and I would like to get through them , any advice help or suggestions will be welcome, as said before raspberry pi and pyrhon is a new world to me so my learning curve will be slow.

I am sure Dropbox or Google API allows a simple file upload, I would prob plump for that.

Re recognition, I will test both local and web options. For the local I would prefer to keep it python, as I know the language well and am more comfortable tinkering with the code than say C and open CV. Will start here http://machinelearningmastery.com/tutorial-first-neural-network-python-keras/

For the online, perhaps Rekognition, as above :slight_smile: OR https://cloud.google.com/blog/big-data/2016/12/how-to-train-and-classify-images-using-google-cloud-machine-learning-and-cloud-dataflow ? Google are definitely one to watch as they have promised to move into the IOT space and create tools for raspberry pi etc

Re telegram, one could trigger the camera to send an image using the bot too :slight_smile: https://www.hackster.io/Salman_faris_vp/telegram-bot-with-raspberry-pi-f373da?f=1#=

Some nice functionality may be coming our way with the iOS app iOS actionable notification with camera image attached

One to try for on board facial recognition, lets hope Obama shows at my door one day… https://github.com/ageitgey/face_recognition

Ill give this a try over the next few days. Ive given up with openCV went through the whole process, 3 hours of compiling and it failed.

1 Like

I dont have any IOS devices, we have mainly Android hardware. I cant play with that aspect of things.