MQTT - seperate server - no devices

@francisp
May I ask the following questions because I am fully new with HA:

  1. is the folder automatically created when I put it into the config.yaml ?
  2. how do I upload a script then to this folder ?
  3. general question: all configurations I make I would like to have in different *.yaml files for better own documentation like e.g. sensors.yaml, scripts.yaml, automation.yaml and so on or what is the recommended way to do ?

No, it isn’t

Depending on your HA installation. If using HAOS you can use the Samba add-on to access from Windows/Linux/MacOS desktop, or install the file-editor add-on and cut-and-paste in a new file.

or

I use the visual studio code extension. i can make with this i would assume.

Thanks for the links i will study them !

You can also create the sensors and switches manually rather than using discovery scripts. Here’s my immersion heater control switch and a couple of sensors:

mqtt:
  switch:
    - name: "Immersion switch relay"
      command_topic: "shellies/shelly1pm-xxxxxx/relay/0/command"
      payload_on: "on"
      payload_off: "off"
      state_topic: "shellies/shelly1pm-xxxxxx/relay/0"
      state_on: "on"
      state_off: "off"
  sensor:
    - name: "Immersion switch temperature"
      state_topic: "shellies/shelly1pm-xxxxxx/temperature"
      unit_of_measurement: "°C"
      device_class: temperature
    - name: "Immersion switch power"
      state_topic: "shellies/shelly1pm-xxxxxx/relay/0/power"
      unit_of_measurement: "W"
      device_class: power

I cannot work out why you are using MQTT for a Shelly, when they have perfectly usable integration.

History: it wasn’t perfectly usable when I installed the Shelly. MQTT seems simpler and less sensitive to any future bugs in the integration.

Yes i saw this already BUT i dont know where i find the correct template for e.g. an Shelly 1pm because by myself i dont know all the things i need to put in the yaml file !

This is exactly the same for me ! Having it in mqtt everything else is possible to do and i am not “stuck” to an individual integration / addon

Look at my example, and compare with the topics you see in MQTT Explorer. You should just need to replace the xxxxxx in mine with your device IDs.

What I’ve posted above can go straight into configuration.yaml (will need a restart) although in reality mine is split up like this as there is more to my MQTT config:

# configuration.yaml
mqtt:
  sensor: !include_dir_merge_list mqtt/sensors
  binary_sensor: !include_dir_merge_list mqtt/binary_sensors
  switch: !include_dir_merge_list mqtt/switches

then, for example,

# mqtt/switches/immersion.yaml
- name: "Immersion switch relay"
  command_topic: "shellies/shelly1pm-xxxxxx/relay/0/command"
  payload_on: "on"
  payload_off: "off"
  state_topic: "shellies/shelly1pm-xxxxxx/relay/0"
  state_on: "on"
  state_off: "off"

That gives me:

image

Shelly reference here for Gen 1 devices:

https://shelly-api-docs.shelly.cloud/gen1/#shelly1-1pm-mqtt

I tried id now with one 1pm and it worked BUT I get an error in HA which says that CoIoT-Config is not working. But I have it activated.
What do I have to do ?

That is the Shelly integration, not MQTT

Mhhh, did I misunderstood something ?
I activated python scripts and put in the shelly script from link above and then I found the 3 devices.
I connected one shelly 1pm device and this message appears :frowning: What did I do wrong ?

The shelly 1pm device is one of the 3 devices, or a new one ?

No the three devices are connected still to my external mqtt server but not in the mqtt session:

So the shelly integration discovered the shelly 1pm, did not see CoIoT, and warns it needs CoIoT to be able to integrate it.

Yes but in the shelly the ColoT is activated to my external mqtt server so why does HA not see it ?

Do you run the script on HA start ?

I only restarted HA completely. I thought it will do then automatically what has to be done ? If not should I manually do something ?

Read the documentation

if you added the automation in automations.yaml, they should be discovered.


# configuration.yaml file
python_script:

# automations.yaml file
- id: shellies_announce
  alias: 'Shellies Announce'
  trigger:
    - platform: homeassistant
      event: start
    - platform: time_pattern
      hours: "/1"  # Modifying this if you are using Shelly Motion can drain your device's battery quickly.
  action:
    service: mqtt.publish
    data:
      topic: shellies/command
      payload: announce

- id: 'shellies_discovery'
  alias: 'Shellies Discovery'
  mode: queued
  max: 999
  trigger:
    platform: mqtt
    topic: shellies/announce
  condition:
    - condition: template
      value_template: "{{ trigger.payload_json.gen is not defined }}"
  action:
    service: python_script.shellies_discovery
    data:
      id: '{{ trigger.payload_json.id }}'
      mac: '{{ trigger.payload_json.mac }}'
      fw_ver: '{{ trigger.payload_json.fw_ver }}'
      model: '{{ trigger.payload_json.model | default }}'
      mode: '{{ trigger.payload_json.mode | default }}'
      host: '{{ trigger.payload_json.ip }}'

Its not so easy to understand it correctly.
I have to understand first that it is a MUST or mandatory to follow the minimum configuration. But okay I will try it

Still this message after implementing the minimal configuration in the automation.yaml