Hi,
I read a lot of people making physical buttons to control something via MQTT.
But can you just simple connect a physical button to your nodemcu, and detect the push via ESPhome code and then trigger a script /automation/…?
I don’t understand why you need mqtt for this.
real life example:
My son wants to know if he can interrupt my working at home. He pushes a button on a breadboard connected to my nodemcu.
this triggers a light to go on in my desk, and I can reply him via home assistant with a color on an rgb led on his side. (green is come upstairs, red is no)
(second part already built and working:)
but I want to make him push an arcarde button without having to programm MQTT. as esphome can dectect so many sensors etc, could it easily detect a signal from a button?
You don’t. You can use the api.
Just connect the push button as a gpio binary sensor in ESPHome and trigger whatever you want with it in home assistant.
MQTT is a communication protocol allowing devices to talk to each other. You have to use either the API or MQTT in your ESPHome code to allow the NodeMCU and HA to talk to each other. API means the “server” is built into the ESPHome device and HA makes a direct connection to listen for changes. MQTT has its own broker service like a central server where HA and devices can publish state changes to a topic and subscribe or listen for state changes in other topics.
Okay, thanks for the info. I’m really low on the tech-ladder. I managed to set up HA, but many simple ideas seem to have overcomplicated solutions.
I knew it would be simpler thanks a million for the reply.
thanks for the clear explaniation ! I have mqtt set up for my milight ledstrip, took me ages to get it working (thanks to the people in this forum it now works) but i’m a bit affraid to change anything to my MQTT broker…
Tom - did you ever get this figured out and setup? I have been trying to make a similar device with two ESP8266’s and have beating my head against the wall. I tried going around HA, but direct UDP or HTTP communication between the two devices seems to difficult. Despite what tutorials say, I have tried to use, adjust, and update the code that is provided from various people and nothing seems to work.
Anyway - would be curious to see the backend of your HA with the API etc. Thanks!
I actually skipped the whole mqtt part. You can define any button connected to your Nodemcu as a switch in home assistant. what are you trying to do exactly?
Yeah I plan on skipping MQTT as well after my UDP/HTTP debacle. Plus I already have sensors communicating via MQTT and I don’t want to accidentally disrupt them, ha.
So I might make your idea as well - it is fantastic for working from home! But my wife’s original idea was to keep the kids from getting out of bed. So they would have a button near their bed that they press. When the button is pressed, we get a notification - ideally an LED connected to a second ESP8266 lights up - to tell us that they need something.
If that works, I would like to have 3 lights and buttons; one for bathroom, another for water, and one more for something like they are scared.
I think I can figure out well enough how to get the ESPHOME to create a binary sensor in HASS. Was it easy enough for you?
Yes, I have one setup but removed it off of ESPHOME because I needed it to do other things (light LEDs) while also taking in sensor data and doing that in yaml files became over my head. So I have it communicating over MQTT which is working well. But I did have it all setup in ESPHome and can do that easily enough. Thanks for linking that, tho! I have an esp8266 all setup with buttons on a breadboard so I’m going to try that this morning. Thanks again!
Thanks for your help man! you+HA solved what I toiled with for many days in less than a single day! Got the buttons to work and then got them to trigger LEDs on a separate esp8266 very easily. time to get creative with it now!