ESP8266-12F Hardware Button - MQTT - Tasmota

I try to configure Tasmota to send mqtt-status, when I connect GND to GPIO4, GND to GPIO5, and so on, … => “On” or “Off” like a switch.
Then I will use it in Home Assistant to power on/off my lights (shelly, …)

Thanks a lot!

maybe you will look at ESPHome? Direct integration into HA?
And GPIO sensors are only a few lines YAML.


As I understand it, you want a switch. Tasmota can sent MQTT for switches. You can select different switchmodes, or can create rules.
As you describe it you will create two switches. Only one GPIO is enough for a switch/button with on/off stautus to sent to HA

How to configure it? I woul like to use my ESP with 4 Buttons und send MQTT: On (by pushing the button) and off again by releasing…

You configure the button as a switch (is always recommented as it gives you more option)
The dufault is SwitchMode 0, that toggles when you press and toggle again when you release

Check the SwitchModes here

I configured 4 GPIOs as a switch and get in the console this output:
00:00:52.469 MQT: stat/tasmota_A1DEC5/RESULT = {“POWER”:“ON”}
00:00:52.472 MQT: stat/tasmota_A1DEC5/POWER = ON
00:00:55.782 MQT: stat/tasmota_A1DEC5/RESULT = {“POWER”:“OFF”}
00:00:55.785 MQT: stat/tasmota_A1DEC5/POWER = OFF

so I dont’t know wich GPIO that is