Adding Tasmota Switches in Config.yaml

Hi,

I have about 3 sonoff (Tasmota) switches that i am trying to integrate with my Home assistant. I have added the relevant lines for all switches but when i restart the HA, only the last one appears. I am also getting the following error:
duplicated mapping key at line 94, column -220:
switch:
^
Does anyone know what i can do in this case?

> switch:
>     platform: mqtt
>     name: "Formal Room Lamp"
>     command_topic: "cmnd/sonoff_Formal_Room_Lamp/power"
>     state_topic: "stat/sonoff_Formal_Room_Lamp/POWER"
>     qos: 1
>     payload_on: "ON"
>     payload_off: "OFF"
>     retain: true
> 
> switch:
>     platform: mqtt
>     name: "Tanu Bedroom"
>     command_topic: "cmnd/sonoff_Tanu_Room/power"
>     state_topic: "stat/sonoff_Tanu_Room/POWER"
>     qos: 1
>     payload_on: "ON"
>     payload_off: "OFF"
>     retain: true
> 
> switch:
>     platform: mqtt
>     name: "Pool Solar Heating"
>     command_topic: "cmnd/sonoff_Pool_Solar_Heating/power"
>     state_topic: "stat/sonoff_Pool_Solar_Heating/POWER"
>     qos: 1
>     payload_on: "ON"
>     payload_off: "OFF"
>     retain: true

sonoff

Hi

I’m far from an expert ( in fact Im a complete novice) but in an attempt to ‘give something back’

Looks like your formatting may be out… see my example. - I think you only need the one heading of switch, then indent platform with the ‘-’ mark. - Ive learnt one thing with Yaml and coding ( im no coder BTW) but formatting and syntax is everything.

  • config-grab

Good luck,

Jarrod.

Yes as Jarrod said your spacing is wrong and you can’t define the switch 3 times.

You can also turn on autodiscovery in HA and tasmota and let them take care of it themselves

1 Like

how -> auto discovery, have exactly as above and my switches still not showing.
using the mqtt broker deployed as a add on:

mqtt:
broker: 192.xx.0.xx
port: 1883
client_id: homeassistant
username: mqtt_dev
password: xxxx

switch:

  • platform: mqtt
    name: “Garage Left Light”
    state_topic: “stat/garage_left_light/POWER”
    command_topic: “cmnd/garage_left_light/POWER”
    availability_topic: “tele/garage_left_light/LWT”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    payload_available: “Online”
    payload_not_available: “Offline”
    state_on: ON
    state_off: OFF
    retain: false
  • platform: mqtt
    name: “Garage Right Light”
    state_topic: “stat/garage_right_light/POWER”
    command_topic: “cmnd/garage_right_light/POWER”
    availability_topic: “tele/garage_right_light/LWT”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    payload_available: “Online”
    payload_not_available: “Offline”
    state_on: ON
    state_off: OFF
    retain: false

Which tasmota binary did you flash? Are you sure your tasmota devices are connected to your mqtt broker?

got it resolved, it some how had the wrong IP in known_devices. once I went integration and removed this, restarted and then add the correct IP for broker in configuration.yaml it all started coming alive.
G