Thank you so helpful - how have you added this into HASS? Do you have to define a specific value_template ??
I have it as a mqtt sensor
- platform: mqtt
state_topic: "home/sensornode1"
name: "SN1 Reed"
value_template: '{{ value_json.reed }}'
Thanks, does that trigger the state instantaneous for you? Mine only seems to trigger when I go from open > closed… but now I can’t see to get it to display the state as open at all… the reed is connect to GND and D6. Would I also need to connect the D6 leg to 3.3v?
Yes mine is instant. Ill need to run out and double check But I am pretty sure oneside of the reed is to 3.3v and the other is to d6.
Just some food for thought…
I had a setup like this in place before I switched over to using Xiaomi Door Sensors. The setup ran on batteries and obviously power consumption is a big deal. I wasn’t impressed with the deep sleep of the ESP and so I sat a power control unit in the circuit.
Most of the time the ESP was completely off (the reed was NO / normally open). The door opening triggered the power control to power up the ESP, the ESP did its thing over MQTT and as soon as it had completed it sent a signal to the power control unit to power itself down. All in the all ESP was only on for about 3 seconds (using a static IP speeds the connection process).
Thanks - appreciate the help. I had a play, If I have one leg on the reed connected to D6, I have to switch the other leg between 3.3v and GND for it to switch between open and closed… So I tried having the D6 leg also connected to 3.3V (so it would switch between GND and 3.3 basically) but it must be shorting something because it gets incredible hot! (I only made this mistake once…)
Thank you - My reed switches don’t have a com port though, they’re just basic magnetic ones (NC)
Your write up looks very comprehensive though - can you share the reed switches you’re using?
https://www.amazon.com/gp/product/B0009SUF08/ref=oh_aui_detailpage_o09_s00?ie=UTF8&psc=1
your reeds should work. one of those wires is a COM and the other is an NC, tho i’m not sure which is which. [plus: make sure you set it to NC in the garHAge code before uploading to the esp8266]
my switches just give you an option of NC or NO. i chose NO. but it matters not which you chose.
Great info here! I have a lot of experience with ESP8266 and contact sensors, but new to HASS. I’m the creator of a similar project called Konnected that’s based on an NodeMCU ESP8266. The main use case here is for converting an old wired security system into a home automation platform (including reed switches and motion sensors and much more).
Right now Konnected integrates with SmartThings only, but we’re starting to accelerate our platform expansion plans and was thinking that HomeAssistant would be a great platform for Konnected.
The project is open-source on github: https://github.com/konnected-io/konnected-security and we sell DIY kits and (soon) custom hardware based on the ESP8266 for easy plug-and-play installation.
Is this something that would be interesting to you or the HASS community? I’m really interested in your thoughts/feedback on a product like this for HASS.
I have built this Multisensor. I am getting good indication from the PIR which is showing ‘standby’ or ‘motion detected’. I am struggling to implement the PIR state into an automation so that it will control a light.
Any suggestions would be greatly appreciated.
Had another attempt today and got it sorted. The states - ‘standby’ or 'motion detected ’ didn’t work yesterday when I used them as a trigger…but today it worked!!
As an alternative to the suggestions above I used Tasmota as described in @DrZzs video at
ps: Not all the videos I link to on YouTube are mine
Hi, Thanks so much for this, I have been able to use it and modify it to suit my application. One question. I cant seem to figure out what I need to call on the MQTT server to make the controller fire up the relay output. I have tried mqtt topic but the controller doesn’t show RX on the serial monitoring and it doesn’t fire up the output.
I am using this with OpenHAB, however I am using MQTTfx to test it
Thank you
Just chiming in here because I think I have a project that can (hopefully) make this whole setup a lot easier and with no coding experience required whatsoever.
esphomeyaml is a project of mine that creates custom firmwares for your ESP8266/ESP32 devices straight from YAML configuration files. Among the supported features are: Hass MQTT Auto-Discovery, Internal Web Server, Smart OTA, easy extensibility, RGB lights, and the best thing: It’s made for Home Assistant and tries to make the setup process as easy as possible with setup wizards and upload helpers. Hope you like it
I used esphomeyaml and used reed switch, nodemcu (esp8266 and mqtt (mosquito) for my garage notification. It works excellent.
I upload the code with the Reed switch I have one wire in D6 and the other in 3v3. The Reed is NC. The thing is:if I’m touching the wire at D6 it works flawlessly… If I Dont touch the wire it doesn’t work… Unless the status is closed… Meaning: when I’m not in touch with the wire and the status is closed, I aprouch the magnet and it changes to open but it doesn’t change again when I separate them… If the status is open and I aprouch the magnet when I’m not in touch with the wire it doesn’t work at all. So I’m thinking: what am I missing? Does anyone know a solution for this?
What’ the voltage on the D6 with no wire connected to it?
D6 may have a internal pull up on this pin to 3.3. If this is the case suggest you trying to short D6 to ground and see what happens. Good practice is to have a pull up/down on input pins so they don’t float between states.
It is never too late to say thank you…so Thank you!!
Had been reading for hours on arduino forums on how to convert the payload to a string, but couldn’t get it done.
Your code worked perfectly immediately!!
Thanks for sharing,