6.1 KiB
| title | description | published | date | tags | editor | dateCreated |
|---|---|---|---|---|---|---|
| Door bell | 1 | 2024-03-03T21:33:41.160Z | markdown | 2024-03-02T02:22:57.232Z |
Requirements
- using Bluetooth or WiFi or Zigbee
- forwarding ringing of door bell
- opening of door
- Home Assistant connection
- smartphone app?
- physical reset button
Current system
Siedle ht 511-01
Manufacturer solution
https://www.siedle.de/de-de/produkte/iq-hts-siedle-iq-hts/ https://www.youtube.com/watch?v=DIXJsIaVCGQ
Arduino-based solution
https://www.reichelt.de/magazin/projekte/smarte-tuerklingel/ https://rhfeinmechanik.de/blog/2022/07/25/klingelarduino-turklingel-an-fritzbox-mit-arduino/ https://www.az-delivery.de/en/blogs/azdelivery-blog-fur-arduino-und-raspberry-pi/smartgong-teil-1 https://www.mikrocontroller.net/topic/460394 https://www.videosprechanlagen.info/Kann-man-Klingeldraht-verlaengern https://www.mikrocontroller.net/topic/533047 https://forum.arduino.cc/t/wlan-klingel-mit-esp8266-fur-fritzbox/589769
Preferred solution
===https://www.panbachi.de/smarte-tuerklingel-alte-sprechanlage-smart-machen/===
BOM
Wemos D1 mini --> can use wemos esp32-c3 mini Relay Shield für den Wemos D1 mini https://www.reichelt.de/d1-shield-relais-d1z-relais-p266083.html?&trstct=pos_2&nbc=1 Tripler Base für den Wemos D1 mini https://www.reichelt.de/d1-shield-tripple-base-d1z-tripple-base-p266084.html?&trstct=pos_6&nbc=1 LM2596 DC-DC Step-down https://www.reichelt.de/entwicklerboards-spannungsregler-dc-dc-wandler-lm2596-debo-dcdc-down-2-p282579.html?&trstct=pos_4&nbc=1 B80C800DM Brückengleichrichter PC814 Wechselstrom Optokoppler (Vor den Optokoppler habe ich noch einen 1k Widerstand geschaltet) https://www.reichelt.de/optokoppler-pc-824h-p76185.html?&trstct=pos_0&nbc=1
Code
//DoorBell.ino
#include <Homie.h>
int readDelay = 50;
int buttonPressDelay = 3000;
int openingDelay = 3000;
int inputPin = D3;
int relayPin = D1;
int inputValue = 0;
bool opened = false;
int timeOpened = 0;
HomieNode doorbellNode("button", "button");
HomieNode openerNode("switch", "switch");
boolean openerHandler(const HomieRange& range, const String& value) {
if(value != "true" && value != "false") return false;
if(value == "true") {
digitalWrite(relayPin, HIGH);
openerNode.setProperty("on").send("true");
Serial.println("Opener started ...");
opened = true;
timeOpened = millis();
}
return true;
}
void loopHandler() {
inputValue = digitalRead(inputPin);
digitalWrite(BUILTIN_LED, inputValue);
if(inputValue == 0) {
Serial.println("Doorbell pressed ...");
doorbellNode.setProperty("pressed").send("true");
delay(buttonPressDelay);
doorbellNode.setProperty("pressed").send("false");
}
delay(readDelay);
}
void setup() {
Serial.begin(115200);
Serial.println();
pinMode(inputPin, INPUT_PULLUP);
pinMode(BUILTIN_LED, OUTPUT);
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, LOW);
Homie_setBrand("doorbell");
Homie_setFirmware("Doorbell", "1.0.0");
openerNode.advertise("on").settable(openerHandler);
Homie.setLoopFunction(loopHandler);
Homie.setup();
}
void loop() {
int timeNow = millis();
if(timeOpened > 0 && (timeNow - timeOpened) > 3000) {
Serial.println("Close ...");
Serial.println(timeNow);
Serial.println(timeOpened);
timeOpened = 0;
digitalWrite(relayPin, LOW);
openerNode.setProperty("on").send("false");
Serial.println("Opener finished ...");
}
Homie.loop();
}
Die dazugehörige config.json würde wie folgt aussehen:
{
"name": "Doorbell",
"device_id": "c01",
"wifi": {
"ssid": "[SSID]",
"password": "[PASSWORD]"
},
"mqtt": {
"host": "192.168.178.54",
"port": 1883,
"base_topic": "doorbell/",
"auth": true,
"username": "homeassistant",
"password": ""
},
"ota": {
"enabled": true
}
}
Zum Thema Homie und Wemos D1 mini werde ich noch einen weiteren Artikel schreiben.
Anbindung an Home-Assistant
#configuration.yaml
mqtt:
embedded:
binary_sensor:
- platform: "mqtt"
name: intercom_bell
state_topic: "doorbell/c01/button/pressed"
payload_on: "true"
payload_off: "false"
device_class: "sound"
retain: true
switch:
- platform: mqtt
name: intercom_opener
state_topic: "doorbell/c01/switch/on"
command_topic: "doorbell/c01/switch/on/set"
payload_on: "true"
payload_off: "false"
retain: true
icon: mdi:lock
#customize.yaml
binary_sensor.intercom_bell:
friendly_name: Klingel
switch.intercom_opener:
friendly_name: Türöffner
Regeln für Telegram
#automation.yaml
- alias: 'Telegram Bot: Benachrichtige über klingeln'
trigger:
platform: state
entity_id: binary_sensor.intercom_bell
from: 'off'
to: 'on'
action:
- service: telegram_bot.send_message
data_template:
message: 'Es klingelt an der Tür'
disable_notification: true
inline_keyboard:
- "Tür öffnen:/open_door"
- alias: 'Telegram Bot: Öffne die Tür'
trigger:
platform: event
event_type: telegram_callback
event_data:
data: '/open_door'
action:
- service: telegram_bot.edit_replymarkup
data_template:
message_id: 'last'
chat_id: '{{ trigger.event.data.chat_id }}'
inline_keyboard: []
- service: telegram_bot.send_message
data_template:
target: '{{ trigger.event.data.user_id }}'
message: 'Die Tür wird geöffnet'
disable_notification: true
- service: switch.turn_on
entity_id: switch.intercom_opener







