HOWTO: Integrate doorPi [SIP based Raspberry doorbell] into openHAB

Some time ago, I wanted to have a SIP based doorbell to nicely integrate with my smarthome and while searching, I came across doorPi.

With my below described config, one will be able to turn on the lights on your doorPi based on openHAB Astro Binding, have your Alexa say something like “Doorbell is ringing” and hangup when the door is opened.

Prerequisits
You need to have a up and running doorPi.
Instructions can be found here (German only, sorry)
https://www.doorpi.org/forum/lexicon/entry/1-installation-doorpi-mittels-pypi-auf-einem-raspberry-pi-raspbian/

doorPi.ini - piFace config

[keyboards]
prodsystem = piface

[prodsystem_InputPins]
0 = sleep:0		// doorbell pushbutton
1 = sleep:0		// Lights ON
2 = sleep:0		// Lights OFF
3 = hangup:0	// Receive openHAB command to hangup when door is opened

[prodsystem_OutputPins]
0 = Sound
1 = Lights

Usually, you would use your input pins directly to make a call in doorPi. Defining just a sleep command lets us use the event system to take further action.
The output pins present piFace outputs to switch the relais for the soundcard or the lights.

doorPi.ini - Event config

[EVENT_OnKeyPressed_prodsystem.0]
10 = os_execute:curl --header "Content-Type: text/plain" --request POST --data "ON" http://192.168.0.112:8080/rest/items/doorPiCall
20 = call:**611#622#623

When the doorbell button is pressed, this event is triggered, sending a REST call to a openHAB Switch Item, indicating an active call. The call will be initiated in line two.

[EVENT_OnKeyPressed_prodsystem.1]
10 = out:Lights,1
[EVENT_OnKeyPressed_prodsystem.2]
10 = out:Lights,0

The unused piFace inputs 1 and 2 are used to receive a trigger from openHAB to switch ON/OFF the lights.

[EVENT_OnMediaNotRequired]
10 = out:Sound,0
20 = os_execute:curl --header "Content-Type: text/plain" --request POST --data "OFF" http://192.168.0.112:8080/rest/items/doorPiCall

Switch off the amplifier and send information to openHAB that the door call has ended.

[EVENT_OnMediaRequired]
10 = out:Verstaerker,1

Switch on the amplifier when a call will be initiated.

openHAB Items

Switch doorPiCall "doorPi call active"	<soundvolume>
String Echo_Living_TTS "Text to Speech" {channel="amazonechocontrol:echo:148fa16d:B0F00715603600UB:textToSpeech"}

openHAB Rules

rule "Switch ON doorPi lights"
when 
	Channel 'astro:sun:local:set#event' triggered START  
then
	sendHttpGetRequest("http://user:password@doorPi.local/control/trigger_event?event_name=OnKeyPressed_prodsystem.1&event_source=doorpi.keyboard.from_piface")
end
    
rule "Switch OFF doorPi lights"
when 
	Channel 'astro:sun:local:rise#event' triggered START  
then
	sendHttpGetRequest("http://user:password@doorPi.local/control/trigger_event?event_name=OnKeyPressed_prodsystem.2&event_source=doorpi.keyboard.from_piface")
end

rule "Hangup doorPi call when frontdoor is opened"
when
    Item ContactFrontDoor changed to OPEN
then
    if (doorPiCall.state == ON) {
        sendHttpGetRequest("http://user:password@doorpi.local/control/trigger_event?event_name=OnKeyPressed_prodsystem.3&event_source=doorpi.keyboard.from_piface")	
	}
end

rule "doorPi calling"
when
	Item doorPiCall changed to ON
then
    Echo_Living_TTS.sendCommand("Doorbell Is Ringing")
end

What is missing ?
A fancy widget for HABpanel to receive the video stream with integration of a JavaScript SIP client.

5 Likes

Did not forget about it! I will provide in the next few days!

This was not mentioned to push you George.:smiley:

1 Like

Hello dear,

Can doorPi work with any SIP intercom like 2N, Dahua without needing of SIP server? And it is ok to run doorPi on raspberryPI that hosts openHAB?

No, it can’t as it is using a SIP client for communication, so you need a SIP Server like Asterisk.
I would not recommend to run it on the same PI as openHAB, as you ideally locate it next to your doorbell.

Is there an updated instructions for Doorpi in english ? Would like to try this as it seems really cost effective compared to eg. Doorbird

Hi George,
any news on the SIP intercom widget?

Best
Hans-Jörg

DoorPi is a complete different project, so please ask specific questions on their community.