MQTT Buttons: YAML help

Hello guys,

i have a pilldispenser DIY project that executes actions upon mqtt commands.

-it publishes is state to pilldispenser/state
-it executes an action when it receives
dispense_magnesium, dispense_omega or dispense_zinc in pilldispenser/commands.

I want to have 3 buttons to control this in the lovelace.

The config I created is:

mqtt:
  button:
    - name: "Zinc"
      command_topic: "pilldispenser/commands"
      payload_press: "dispense_zinc"
      icon: mdi:pill
      qos: 0
      retain: false
  button:
    - name: "Omega 3"
      command_topic: "pilldispenser/commands"
      payload_press: "dispense_omega"
      icon: mdi:pill
      qos: 0
      retain: false
  button:
    - name: "Magnesium"
      command_topic: "pilldispenser/commands"
      payload_press: "dispense_magnesium"
      icon: mdi:pill
      qos: 0
      retain: false

  sensor:
    - name: "Pilldispenser Status"
      state_topic: "pilldispenser/status"

now I have
-one Zinc entity,
ID button.zinc, Status unavailable
-one Omega 3 entity,
ID button.omega_3, Status unavailable
-three Magnesium entities,
button.magnesium, Status unavailable
button.magnesium2, Status unavailable
button.magnesium3, Available

This is much different from what I expected. What I want is obvious: 1 available entity of each. Where do the ghost entities come from?
Why are they unavailable?

Many thanks in advance!

It would be best if i can add all of them to one device, group them.

Sth. like


  pilldispenser:
    name: "Pilldispenser"
    entities:
      - entity_id: pilldispenser.zinc
      - entity_id: pilldispenser.omega
      - entity_id: pilldispenser.magnesium

Sadly the documentation about YAML is very bad in my opinion. I looked at so much documentation already, but things do not get clearer. Also, a lot of available stuff is outdated.

mqtt:
  button:
    - unique_id: button.zinc
      name: "Zinc"
      command_topic: "pilldispenser/commands"
      payload_press: "dispense_zinc"
      availability:
        - topic: "pilldispenser/status"
          payload_available: "ready"
      icon: mdi:pill
      qos: 0
      retain: false
  button:
    - unique_id: button.omega
      name: "Omega 3"
      command_topic: "pilldispenser/commands"
      payload_press: "dispense_omega"
      icon: mdi:pill
      qos: 0
      retain: false
  button:
    - unique_id: button.magnesium
      name: "Magnesium"
      command_topic: "pilldispenser/commands"
      payload_press: "dispense_magnesium"
      icon: mdi:pill
      qos: 0
      retain: false

  sensor:
    - name: "Pilldispenser Status"
      state_topic: "pilldispenser/status"

issue remains the same

Solution:

mqtt:
  button:
    - unique_id: button_zinc
      name: "Zinc"
      command_topic: "pilldispenser/commands"
      payload_press: "dispense_zinc"
      icon: mdi:pill
      qos: 0
      retain: false
    - unique_id: button_omega
      name: "Omega 3"
      command_topic: "pilldispenser/commands"
      payload_press: "dispense_omega"
      icon: mdi:pill
      qos: 0
      retain: false
    - unique_id: button_magnesium
      name: "Magnesium"
      command_topic: "pilldispenser/commands"
      payload_press: "dispense_magnesium"
      icon: mdi:pill
      qos: 0
      retain: false

If I could, I would delete the post.

The documentation is written by users who volunteer their time. If you believe it doesn’t meet your high standards, improve it. There’s an Edit button at the bottom of every documentation page that awaits your contributions.

I was rude, i agree. This is an open source project, and I am in trouble mainly because my skill is too low. I was just really annoyed yesterday after hours of failed attempts.

Once I improve to a point where I can, I will for sure contribute to the guides and try to ease explanations.

It is so sad that ChatGPT does not know about the new Homeassistant YAML format, otherwise life would be so much easier.