I have my laptop reporting power to HA via MQTT (iot-link) and have a device in the UI with the various sensors listed. I am also using the command functionality in iot-link to suspend the laptop from automations. I have done this by creating an mqtt button in my config that send the appropriate topic.
All of this works fine.
However, what I would like to do is add the button entity to the device so that they both appear in the UI together under the same device with button press listed under controls.
But I have to admit, I am struggling. Can anyone link to any other guides on how to publish MQTT discovery messages to add an extra entity to a device?
It’s done exactly like I explained in the linked topic. In order for the discovery message to add an entity (i e. a button entity) to an existing device, the discovery message must contain the same device parameters as the device.
Go to Settings > Devices & Services > Devices
Click on the device you want to add a button to.
Take note of the device’s parameters displayed in the upper left corner of the first card.
Example:
Here’s one of my devices that was created via MQTT Discovery.
Check if the payload that is published to the availability topic is a retained message. If it is then Home Assistant receives immediately upon connecting to the MQTT broker. If it isn’t then, yes, you would have to wait until it’s published.
let me tell you, manually publishing a discovery message just to add a new entity seems quite laborious to me (this is a message to the mantainers not you).
what if I had to add 100 MQTT entities? wouldn’t it be more straightforward to have a dedicated yaml syntax instead of publishing a specially crafted message for each device?
let me address your sarcasm, 2 years is nothing for a platform which requires hundreds of configurations and man hours to setup.
I setup my cameras as follows just 2 years ago:
and now 2 years later (which feels like 2 days considering how many other devices I have set up), I realize the entity is not appearing anymore in home assistant.
And I should re-read the manual because no upgrade procedure has been setup for those who originally started using home assistant some years ago and didn’t keep reading the forum every day.
what is even more odd is that searching google for:
My two cents of feedback: let’s try to keep configuration options as they are and change them gradually in the span of years while keeping an upgrade guide somewhere to reference in the forum: “check the documentation” for people who already read it years ago and need to re-read it completely because everything has been changed is not an answer.
I don’t know if it’s me but I keep finding forum answers which are at least 1 or 2 years old, and they are not slighly off but completely irrelevant to the current release.
Imagine if any StackOverflow answer were irrelevant just after a year because the software has completely changed and you have to read the manual again.
The fact the home assistant manual is not browsable by version doesn’t help.