Die Post ist da!

Gerne wird der Homematic Reedkontakt verwendet, um den Briefkasten zu überwachen. Vor Kurzem habe ich mir ebenfalls drei solcher Fenstersensoren bestellt - also Zeit, meine eigene Briefkastenüberwachung zu realisieren.

Die Installation der Hardware war sehr einfach: Im Briefkasten habe ich auf Höhe der Briefkastenklappe den Homematic IP Fenster- und Türkontakt mit Magnet (HmIP-SWDM) mit dem mitgelieferten Klebeband befestigt. Den Magneten habe ich aus seinem Gehäuse gelöst und direkt auf die Briefkastenklappe geklebt. Schon funktioniert die Erkennung, wenn die Briefkastenklappe geöffnet wird.

Die Benachrichtigung über Post ist auch sehr einfach realisiert:

  • Wenn ich zuhause bin, erfolgt die Benachrichtigung über eine Audio-Ausgabe bei meinen Amazon Echos in Wohnzimmer und Schlafzimmer (TTS, Text to Speech).
  • Bin ich unterwegs, erhalte ich eine Telegram Nachricht mit einem Bild von der Überwachungskamera am Hauseingang.
  • In beiden Fällen wird der Status auch im Dashboard angezeigt.

Eigentlich könnte ich damit zufrieden und fertig sein - aber eine perfekte Lösung muss ja auch den "Reset" berücksichtigen, wenn ich den Briefkasten geleert habe.

  • Einfachste Umsetzung wäre: Ich führe den Reset im Dashboard mit einem Schalter durch - aber das ist doch nicht wirklich automatisch!
  • Eine weitere Idee: Ein zweiter Sensor im Briefkasten überwacht, ob die Briefkastentüre geöffnet wird und sendet das Signal für einen Reset. Aber noch ein Sensor im Briefkasten, nur dafür? Hardware-Overkill und noch weniger Platz im Briefkasten!
  • Also nochmal ein bisschen über den Vorgang nachdenken: Wann leere ich den Briefkasten und welche Sensoren melden zu dem Zeitpunkt welchen Zustand? Die Lösung: Der Briefkasten meldet natürlich offene Klappe (da die Briefkastentüre geöffnet wird). Wenn ich den Briefkasten öffne, stehe ich vor meiner Haustüre, die ist also ebenfalls geöffnet - und da habe ich die Logik:
    1. Wenn der Briefkasten geöffnet wird und
    2. gleichzeitig die Haustüre offen ist, dann ist es ein Reset!

In Node-Red habe ich den Vorgang in folgendem Flow abgebildet - er beinhaltet noch Besonderheiten wie Abfangen einer Fehlernachricht (falls der Sensor einen anderen Statuswert als "offen" oder "geschlossen" melden sollte) oder Weiterleitung zur Funktion, die ein Bild der Überwachungskamera aufnimmt und via Telegram verschickt.

Der Export des gesamten Flows sieht so aus:


[{"id":"d7ec5956.b980c8","type":"change","z":"1eebd769.168a29","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.val","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":302,"y":148,"wires":[["d65e258f.6e15e8"]]},{"id":"c6104e1e.6938d","type":"change","z":"1eebd769.168a29","name":"Post ist da!","rules":[{"t":"set","p":"payload","pt":"msg","to":"offen","tot":"str"},{"t":"set","p":"Post","pt":"global","to":"ist im Briefkasten!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":328.680419921875,"y":313.43701171875,"wires":[["b943cd1b.303e1"]]},{"id":"d65e258f.6e15e8","type":"switch","z":"1eebd769.168a29","name":"Status?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":109.4285888671875,"y":260.0714416503906,"wires":[["5d710e9f.2791d","2bf40b13.a22f54"],["dba05f39.0623d"],["bf88595f.cced58"]]},{"id":"bf88595f.cced58","type":"change","z":"1eebd769.168a29","name":"Fehlerfall","rules":[{"t":"set","p":"payload","pt":"msg","to":"Fehler","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":246.28561401367188,"y":394.2856750488281,"wires":[[]]},{"id":"1df246e9.2a2ba9","type":"change","z":"1eebd769.168a29","name":"Briefkasten","rules":[{"t":"set","p":"topic","pt":"msg","to":"Briefkasten","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":120.8094482421875,"y":148.571533203125,"wires":[["d7ec5956.b980c8"]]},{"id":"29c55118.5479de","type":"ui_text","z":"1eebd769.168a29","group":"8ed20f8c.85d81","order":0,"width":"0","height":"0","name":"","label":"Post","format":"{{msg.payload}}","layout":"row-spread","x":835.0005111694336,"y":319.0004024505615,"wires":[]},{"id":"b943cd1b.303e1","type":"change","z":"1eebd769.168a29","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Post","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":528.5001831054688,"y":314.5001525878906,"wires":[["29c55118.5479de","d3b5aa86.934818"]]},{"id":"d3b5aa86.934818","type":"switch","z":"1eebd769.168a29","name":"zuhause?","property":"Audioausgabe","propertyType":"global","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":699.2501831054688,"y":351.7501220703125,"wires":[["27b98e97.90fb22","7b1a3b6f.109d24"],["6c2495d6.5352dc"]]},{"id":"5d710e9f.2791d","type":"function","z":"1eebd769.168a29","name":"Redis Haustuere","func":"msg.payload = ['hm/status/Haustuere/STATE'];\nreturn msg;","outputs":1,"noerr":0,"x":314.0050354003906,"y":268.3452453613281,"wires":[["97e85312.460aa"]]},{"id":"97e85312.460aa","type":"redis-command","z":"1eebd769.168a29","server":"d8603138.adb178","command":"get","name":"","topic":"","x":486.2093505859375,"y":270.509765625,"wires":[["484cb306.62cb0c"]]},{"id":"484cb306.62cb0c","type":"json","z":"1eebd769.168a29","name":"","property":"payload","action":"","pretty":false,"x":620.2188110351562,"y":270.2718200683594,"wires":[["93eb439e.fdc53"]]},{"id":"ceb7de22.57ec","type":"comment","z":"1eebd769.168a29","name":"Briefkasten: Post und Leerung","info":"","x":167.03082275390625,"y":35.94645690917969,"wires":[]},{"id":"6c2495d6.5352dc","type":"link out","z":"1eebd769.168a29","name":"Post_OutTelegram","links":["9ca3483c.c76dc8"],"x":839.1504898071289,"y":421.8202610015869,"wires":[]},{"id":"2bf40b13.a22f54","type":"change","z":"1eebd769.168a29","name":"Klappe offen","rules":[{"t":"set","p":"payload","pt":"msg","to":"offen","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":514.6947021484375,"y":190.01808166503906,"wires":[["17ffd9d0.3fec16"]]},{"id":"dba05f39.0623d","type":"change","z":"1eebd769.168a29","name":"Klappe zu","rules":[{"t":"set","p":"payload","pt":"msg","to":"geschlossen","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":504.9775390625,"y":226.56210327148438,"wires":[["17ffd9d0.3fec16"]]},{"id":"17ffd9d0.3fec16","type":"ui_text","z":"1eebd769.168a29","group":"8ed20f8c.85d81","order":0,"width":"0","height":"0","name":"","label":"Klappe","format":"{{msg.payload}}","layout":"row-spread","x":725.47900390625,"y":207.68995666503906,"wires":[]},{"id":"7b1a3b6f.109d24","type":"http request","z":"1eebd769.168a29","name":"Marshall Ausgabe","method":"GET","ret":"txt","paytoqs":false,"url":"https://192.168.2.5:8888//alexa.php?device_name=herwigs_stanmore_ii_voice&text_tts=Trari, trara: Die Post ist da!","tls":"","proxy":"","authType":"","x":915.4769287109375,"y":386.4611053466797,"wires":[[]]},{"id":"27b98e97.90fb22","type":"http request","z":"1eebd769.168a29","name":"Echo Schlafzimmer Ausgabe","method":"GET","ret":"txt","paytoqs":false,"url":"https://192.168.2.5:8888//alexa.php?device_name=schlafzimmer&text_tts=Die Post ist da!","tls":"","proxy":"","authType":"","x":944.5,"y":353.50022888183594,"wires":[[]]},{"id":"93eb439e.fdc53","type":"change","z":"1eebd769.168a29","name":"Haustüre","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.val","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":755.5283203125,"y":270.5193786621094,"wires":[["8e99fc76.083ce"]]},{"id":"8e99fc76.083ce","type":"switch","z":"1eebd769.168a29","name":"Status?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":904.9711303710938,"y":267.6756896972656,"wires":[["c6104e1e.6938d"],["faa4e1cf.b1fc9"]]},{"id":"faa4e1cf.b1fc9","type":"change","z":"1eebd769.168a29","name":"Briefkasten geleert","rules":[{"t":"set","p":"payload","pt":"msg","to":"geschlossen","tot":"str"},{"t":"set","p":"Post","pt":"global","to":"ist nicht da.","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1110.1263427734375,"y":274.5497741699219,"wires":[["2fa26ee.8b08b92"]]},{"id":"2fa26ee.8b08b92","type":"change","z":"1eebd769.168a29","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Post","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":1309.946044921875,"y":274.6129150390625,"wires":[["4cbeed6a.73edd4","29c55118.5479de"]]},{"id":"4cbeed6a.73edd4","type":"switch","z":"1eebd769.168a29","name":"zuhause?","property":"Audioausgabe","propertyType":"global","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":1509.3017578125,"y":275.77197265625,"wires":[["e97d4b4e.89d2a8","2244d30f.ec0b0c"],["b725d2f8.81388"]]},{"id":"e97d4b4e.89d2a8","type":"http request","z":"1eebd769.168a29","name":"Echo Schlafzimmer Ausgabe","method":"GET","ret":"txt","paytoqs":false,"url":"https://192.168.2.5:8888//alexa.php?device_name=schlafzimmer&text_tts=Briefkasten ist geleert.","tls":"","proxy":"","authType":"","x":1731.9459228515625,"y":255.61297607421875,"wires":[[]]},{"id":"2244d30f.ec0b0c","type":"http request","z":"1eebd769.168a29","name":"Marshall Ausgabe","method":"GET","ret":"txt","paytoqs":false,"url":"https://192.168.2.5:8888//alexa.php?device_name=herwigs_stanmore_ii_voice&text_tts=Briefkasten ist geleert.","tls":"","proxy":"","authType":"","x":1700.9228515625,"y":287.5738525390625,"wires":[[]]},{"id":"b725d2f8.81388","type":"function","z":"1eebd769.168a29","name":"Send Message","func":"msg.payload = { chatId : 553335071 , type : 'message' , content : 'Briefkasten geleert.' }\nreturn msg;","outputs":1,"noerr":0,"x":1689.1964111328125,"y":323.1129150390625,"wires":[["2b8ca37e.b0437c"]]},{"id":"2b8ca37e.b0437c","type":"telegram sender","z":"1eebd769.168a29","name":"","bot":"d0be14ca.db2758","x":1874.9459495544434,"y":323.61285305023193,"wires":[[]]},{"id":"9943bd54.beb12","type":"json","z":"1eebd769.168a29","name":"","property":"payload","action":"","pretty":false,"x":356.778076171875,"y":97.38092041015625,"wires":[["1df246e9.2a2ba9"]]},{"id":"3ece1539.b2e70a","type":"mqtt in","z":"1eebd769.168a29","name":"","topic":"hm/status/Briefkasten/STATE/#","qos":"2","datatype":"auto","broker":"47725f2c.3f985","x":157.000244140625,"y":98.047607421875,"wires":[["9943bd54.beb12"]]},{"id":"8ed20f8c.85d81","type":"ui_group","z":"","name":"Briefkasten","tab":"617f6e67.ba397","disp":true,"width":"6","collapse":false},{"id":"d8603138.adb178","type":"redis-config","z":"","host":"192.168.2.5","port":"6379","dbase":"db0","pass":""},{"id":"d0be14ca.db2758","type":"telegram bot","z":"","botname":"MQTT2TelegramBot","usernames":"astrohd","chatids":"553335071","baseapiurl":"","pollinterval":"300"},{"id":"47725f2c.3f985","type":"mqtt-broker","z":"","name":"","broker":"192.168.2.5","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"617f6e67.ba397","type":"ui_tab","z":"","name":"Status","icon":"dashboard"}]