Esp8266-01 mqtt 3 Switches with Tasmota firmware

Hello
it is probably the easiest. but can not get it … esp8266 switch button with tasmota flashed. how can I get it the esp with a button to turn off another sonoff tasmota ??? Whole just for you :slight_smile:
and can I install 2 buttons and run at the same time ??? how would the Yaml.file look like???

Config.yaml file:
- platform: mqtt
name: “Wohnzimmer” <<<<<<<<<<<<<this is the sonoff what I want to control remotely
command_topic: “cmnd/sonoff4/power”
state_topic: “stat/sonoff4/POWER”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true

  • platform: mqtt
    name: “Wohnzimmer-Schalter” <<<<<<<<<<<< this is the ESP8266-01 with button
    command_topic: “cmnd/sonoff5/power”
    state_topic: “stat/sonoff5/POWER”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    retain: true

Hello,
You need to add a few lines to make your switch setup complete:

- platform: mqtt
  name: "Wohnzimmer-Schalter" <<<<<<<<<<<< this is the ESP8266-01 with button
  command_topic: "cmnd/sonoff5/power"
  availability_topic: "tele/sonoff5/LWT"  # add this line
  state_topic: "stat/sonoff5/POWER"
  qos: 1
  payload_on: "ON"
  payload_off: "OFF"
  payload_available: "Online" # add this line
  payload_not_available: "Offline"  #add this line
  retain: true

Make sure that you are using correct " characters! I’m not sure if using “ will work

After restarting Home Assistant you will have at least 2 new entities :

  • switch.wohnzimmer
  • switch.wohnzimmer_schalter

You need to create an automation, with switch.wohnzimmer_schalter as “trigger” (auslöser), which calls a service “switch.toggle” on entity “switch.wohnzimmer”


You need to play a bit around so that it fits your needs.
You can have more than 1 trigger per automation. So yes, you can install more then 1 button to control another device.

1 Like

Thank you for your prompt reply :grin:
Part 1 of 1 config.yaml I did quickly :hugs:
but looks like you have a better version?! My looks like this…
I can not trigger like you :thinking: maybe another solution for that ??

You are in the wrong section. You’ll find the automation editor in “Einstellungen” -> “Automatisierung”

1 Like

Thank you. finally finished.
had sonoff<<esp problems because I had to press 2 times on the button until the light went on.
Now I have it on generic and can serve both buttons. just how can I write this now on the yaml.file so that the second button works ??

What do you mean exactly with second button?

1 Like

i would like to 2 or 3 switches on an esp8266-01. :thinking:
1 is finished Wohnzimmer :tada::confetti_ball:
Now I try to integrate 2 and 3. how would that look this time ??
how would the Yaml.file look like???
Tasmota is set to generic and swiches (to see on the picture above ;-)):point_up:

Config.Yaml file

switch:

  • platform: mqtt
    name: “Schlafzimmer” <<<<<< Want this to third switch (switch.3)
    command_topic: “cmnd/sonoff/power”
    state_topic: “stat/sonoff/POWER”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    retain: true

  • platform: mqtt
    name: “Django” <<<<<< Want this to second switch (switch.2)
    command_topic: “cmnd/sonoff3/power”
    state_topic: “stat/sonoff3/POWER”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    retain: true

  • platform: mqtt
    name: “Wohnzimmer” <<<<<<<switch 1 ok
    command_topic: “cmnd/sonoff4/power”
    state_topic: “stat/sonoff4/POWER”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    retain: true

  • platform: mqtt
    name: “Wohnzimmer-Schalter” <<<<<ESP-01 with 2 (or later with 3) swiches
    command_topic: “cmnd/sonoff5/power”
    availability_topic: “tele/sonoff5/LWT”
    state_topic: “stat/sonoff5/POWER”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    payload_available: “Online” # add this line
    payload_not_available: “Offline”
    retain: true

Home Assistant will create a separate entity for every entry “- platform: mqtt” in the switch: section in configuration.yaml.
So you’ll end up with a few entities like “switch.django” or “switch.schlafzimmer” which you can use as triggers in your automations.
An Automation can have more then 1 trigger, and an entity can be used in more then 1 automation.