Hey! I am maintaining a service which exposes Unraid OS servers state as mqtt entities for home assistant.
The service exposes each servers:
- Virtual machine entities (turn on/off)
- Docker container buttons (turn on, off, restart)
- Server control buttons (power, array on, etc)
This works properly, a single container can manage multiple Unraid servers. Which is where the problem starts. Until now I would use the Server name as unique_id
and device.name
.
Considering that each server can expose the same container or VM. Now with the latest update I am not sure how I can make it work for multiple servers. Since I would need to set the unique name the server name to be able to differentiate the mqtt devices between two different servers. As of the latest update I get this error:
MQTT device name is equal to entity name in your config
This is how it is setup:
JSON.stringify({
payload_on: "started",
payload_off: "stopped",
value_template: "{{ value_json.status }}",
state_topic: `${env.MQTTBaseTopic}/${serverTitleSanitised}/${docker.name}`,
json_attributes_topic: `${env.MQTTBaseTopic}/${serverTitleSanitised}/${docker.name}`,
name: `${serverTitleSanitised}_docker_${docker.name}`,
unique_id: `${serverTitleSanitised}_${docker.name}`,
device: {
identifiers: [serverTitleSanitised],
name: serverTitleSanitised,
manufacturer: server.serverDetails.motherboard,
model: "Docker"
},
command_topic: `${env.MQTTBaseTopic}/${serverTitleSanitised}/${docker.name}/dockerState`
}),
{ retain: env.RetainMessages }
My question is, how can I setup properly the names so it works for multiple servers and does not bother home assistant