Question on sequence change of yaml config file

If the yaml code order is not in order like if state_topic and platform has interchange their order/sequence, is it an issue or not?

https://drive.google.com/file/d/1eRq8ZgO600BjD-cJX6Tj6-grfrs2nk9a/view?usp=drivesdk

It should work out of order but good best practice for consistency you should put it at the top.

but it won’t work the way you have it written because there is no domain specified for “outlet 1”

Your example fails to conform to several conventions, for both YAML and Home Assistant.

It should look more like this:

switch:
  - platform: mqtt
    name: "Outlet 1"
    state_topic: "home/light1confirm"
    command_topic: "home/light1"

Just to reinforce, there should be no opening / in the mqtt topics.

And please do not post images of text. That is what copy and paste are for.

Good point. In fact, I unconsciously left it out in my example and only noticed later that it’s in the OP’s screenshot!

@mehul0506
Although not illegal, a leading slash represents a separate, and unnecessary, level in the topic’s hierarchy. See: MQTT Essentials Part 5: MQTT Topics & Best Practices

Never use a leading forward slash
A leading forward slash is permitted in MQTT. For example,
/myhome/groundfloor/livingroom . However, the leading forward slash introduces an unnecessary topic level with a zero character at the front. The zero does not provide any benefit and often leads to confusion.

Hey, thanks for the answer it was just an example it’s not the actual file.:slight_smile:

Sure next time I will new to this community forum, really sorry for the screenshot and thanks for the answer.