Doorbel a virtual Switch

From Domoticz
Jump to: navigation, search

Your doorbell as switch in Domoticz.

First you need to connect your 12 AV relays in parallel with your doorbell.

When your doorbell button is pressed, the contact of your relays will connect GPIO18 to ground.

Now install the software

sudo apt-get install python-dev python-pip
sudo install --upgrade distribute
sudo install ipython
sudo install --upgrade RPi.GPIO

This is the python script I made

# Doorbell py with read contact uitlezen, 
# GPIO 18 to Ground when button is pushed 
# Release 0.1/
# Author J. Jeurissen
# Copyright (c) 2015  J. Jeurissen 
# Python 3

import urllib
import urllib.request
import json
import RPi.GPIO as GPIO
import time

# Settings for the domoticz server
domoticzusername = ""
domoticzpassword = ""

domoticzurl = 'http://'+domoticzserver+'/json.htm?type=command&param=switchlight&idx=170&switchcmd=On'


GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)

while True:
	input_state = GPIO.input(18)
	if input_state == False:
		print('Button Pressed')

Add in crontab the following line so your python script is always running

@reboot python3 /path/