Solved: Mqtt turns me mad

Hi!
At first, sorry for my english, give my best.

My problem: cant get a mqtt switch running
The switch is a shelly1, configured to use mqtt.
With mqtt.fy i am able to see the messages.
On hass.io i set up mosquitto, mqtt.fx connects to mosquitto.
In my configuration.yaml i try with this:

- platform: mqtt
name: "switch test"
state_topic: "shellies/shelly1-25A222/relay/0"
command_topic: "shellies/shelly1-25A222/relay/0/command"
qos: 0
payload_on: "on"
payload_off: "off"
retain: false
optimistic: false

Hass.io told me:
Component not found: state_topic Invalid config for [switch.mqtt]: required key not provided @ data[‘command_topic’]. Got None. (See ?, line ?). Component not found: qos Component not found: command_topic Component not found: retain Component not found: payload_off Component not found: name Component not found: payload_on Component not found: optimistic

i am sure must be a silly mistake on my side but cant find/see it.

Any idea? Help me on the horse please.

Regards
Holger

if that is how you have the code formatted that is your problem.

switch:
  - platform: mqtt
    name: "switch test"
    state_topic: "shellies/shelly1-25A222/relay/0"
    command_topic: "shellies/shelly1-25A222/relay/0/command"
    qos: 0
    payload_on: "on"
    payload_off: "off"
    retain: false
    optimistic: false

The ON and OFF are normally uppercase as well

Have you familiarized yourself with the yaml structure? A lack of indentation seems to be the issue.

Must say, not really. Hassio runs now some weeks, have setup some things and try to get familar with.
The config for the switch is found with google, copy&paste.
On git looked for some configs, how they do things.
Have read a lot, try with google but didnt see my mistake.

You need to read the docs HERE not do wild google random searches. Follow the docs - that’s what they are for.

right but…
along with this: https://www.home-assistant.io/components/switch.mqtt/

try in config with this:

  • platform: mqtt
    name: “shelly1-25A222”
    command_topic: “shellies/shelly1-25A222/relay/0/command”

result in config check:
Invalid config for [switch.mqtt]: required key not provided @ data[‘command_topic’]. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/switch.mqtt/ Component not found: command_topic Component not found: name

@synack You can use this Shellies Discovery Script

thnx, will give it a try at weekend

your formatting looks incorrect, but since you are not formatting properly for the forum, we cannot be sure you are formatting correctly for your yaml.

Once you start formatting things correctly here, we can easily verify what the issue is. Right now, I say it’s because you are disregarding all the YAML rules and just trying to copy/paste whatever you find, and it’s not pasting correctly.

YAML has rules for a reason. They are easy to follow if you pay attention to them.

Solved!
Yes, problem was formating and in front of the keyboard, delete some spaces and everything went well.
Thanks for pointing!