Yaml file for mqtt devices

I have created a mqtt.yaml file in the same directory than the configuration.yaml file.

What must I write in the configuration.yaml file to run the mqtt.yaml ?

#mqtt.yaml
light:
    name:"Shelly3-ch0"
    unique_id:"shelly3_ch0"
    payload_on:"on"
    payload_off:"off"
    qos:0
    state_topic:"shellies/shellypro3-34987a480e54/relay/0"

    command_topic:"shellies/shellypro3-34987a480e54/relay/0/command"
    json_attributes_topic:"shellies/ shellypro3-34987a480e54/info"

sensor:
    name:"Shelly3-input1"
    unique_id:"shelly3_input1"
    qos:0
    expire_after:86400
    state_topic:"shellies/shellypro3-34987a480e54/input_event/0"

That would be mqtt: !include mqtt.yaml

Thanks for the fast answe. This message is displayed when check the configuraction in developers tool

Configuration warnings
Invalid config for 'mqtt' at configuration.yaml, line 44: expected dict 'mqtt->0->light->0', got None
Invalid config for 'mqtt' at configuration.yaml, line 44: expected dict 'mqtt->0->sensor->0', got None

Hi save,
The MQTT structure is actually a list of dicts.

MQTT breaking changes RC 2022.6 - #70 by Sir_Goodenough.

That’s how I did it.

Inside each of the yaml files I have a dict.

You can see that in my config in the link there.

Not the only way to split this, but it’s very clean and works for me.

Hello

I don´t understand.

If I write the following line (your post) in configuration.yaml, which must be the name where mqtt devices are defined?

Look at the examples. That’s a folder I added, and the yaml files are in those folders.

!include_dir_merge_list looks for files in a folder.

Sorry but, mqtt is a folder you created in the in the root, or in the homeassistant folder?

Regards

the same folder as the configuration.yaml file.

Look at my set-up here for the full picture. Here’s another link to it.
GitHub - SirGoodenough/Home-Assistant-Config: My HA Configuration... This is what I run for production in my house..

I have created these lines in configuration.yaml, following your structure, Could you help me?

mqtt:    
    - switch: !include_dir_merge_list mqtt/switch/
    - binary_sensor: !include_dir_merge_list mqtt/binary_sensor/

And in the file /homeassistant/mqtt/switch/switch.yaml

- name:"Shelly3-example-ch0"
    unique_id:"shelly3_example_0"
    payload_on:"on"
    payload_off:"off"
    state_topic:"shellies/shellypro3-34987a480e54/relay/0"
    command_topic:"shellies/shellypro3-34987a480e54/relay/0/command"
    json_attributes_topic:"shellies/shellypro3-34987a480e54/info"
    retain:false
    payload_available:"true"
    payload_not_available:"false"

This message is displayed when I check the yaml

Invalid config for 'mqtt' at mqtt/switch/switch.yaml, line 1: expected dict 'mqtt->0->switch->0', got 'name:"Shelly3-example-ch0" unique_id:"shelly3_example_0" payload_on:"on" payload_off:"off" state_topic:"shellies/shellypro3-34987a480e54/relay/0" command_topic:"shellies/shellypro3-34987a480e54/relay/0/command" json_attributes_topic:"shellies/shellypro3-34987a480e54/info" retain:false payload_available:"true" payload_not_available:"false"'
 ```

name and unique_id should be at the same indentation level.

Also, put a space after the key, so:

- name: "Shelly3-example-ch0"
-------^

The error message is missing now. But I cannot see the mqtt entitities. How can them be discovered?

Regards

Have you restarted HA?

Once you have, look for, for example, switch.shelly3_example_ch0.

Hi

I have done it 100 times. I have the shelly PRO entities running from Shelly integration, but not from mqtt.
Mqtt_Imagen1

I was going to say the same. After a change to this stuff you need to reload everything.

As I told you. I did it. Also turning off the power. Really I don´t know what I can do.

Well if it looks like this, it should work…
image

Thanks very much, but my level is not enough for this. I don´t see what you mean.
Don´t waste your time. I think I´ll look for a more easy solution than HA to control MQTT devices