Problem adding mqtt sonoff tasmosta switch to Home assistant

Hello,

i am using my own mqtt server not hassio add on. I have added the following to the configuration.yaml file:

mqtt:

  broker: !secret mqtt_url
  port: !secret mqtt_port
  username: !secret mqtt_user
  password: !secret mqtt_pass
  client_id: home-assistant
  discovery: true
  discovery_prefix: homeassistant

switch:
  - platform: mqtt
    name: “sonoff”
    state_topic: “stat/sonoff/RESULT”
    value_template: ‘{{ value_json[“POWER1”] }}’
    command_topic: “cmnd/sonoff/POWER1”
    availability_topic: “tele/sonoff/LWT”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    payload_available: “Online”
    payload_not_available: “Offline”
    retain: true

I ran the CHECK CONFIG and it reported Valid.

When I restart HA i get the message INVALID CONFIG:

The following components and platforms could not be set up:
mqtt
switch.mqtt
Please check your config

I have set user and password for mqtt server and homeassistant connects to it without any issues. I have even publish to the topic to turn the switch on from home assistant mqtt integration page and it works fine. But i just can’t add switch, is there something that i am missing?

Thank you very much for any upcoming messages.

It would help if you formatted your code correctly. use ``` before and after the code.

…and HassIO no longer exists. Your title might confuse newbies

Thank you for the tip it’s my first post :slight_smile:

I’ve corrected it, thank you

The only thing I see that might be different than mine is the value template.

Try:

 '{{ value_json.POWER1}}'

Also make sure that you check your quotation mark style that you are using the standard text type and not the “fancy” type. It’s hard to tell from your code which type they are.

For Tasmota MQTT use auto discovery, super easy.

Well that acctually helped, thank you very much :grinning:

Will try that as well, thank you