MQTT with device dependend topic

I’m integrating several devices of the same model ( into my home assistant environment based on MQTT. The topics (read & write) use device ID and model and there are 12+ topics (even if ignoring uninteresting topics) to integrate with topics like:

state_topic: 'dingz/246F28A76F1C/dz1f-pir/state/light/0'
state_topic: 'dingz/<id>/<model>/state/light/0'

Obviously one or two parameter would help to clean up and simplify sensor and script files:

state_topic: 'dingz/{{ device }}/state/light/0'
state_topic: 'dingz/{{ id }}/{{ model }}/state/light/0'

Whether solved by secret or sensor value, either way would help but I have not yet found a working way.
Any hints or help?

Btw.: Putting the hole topic in a secret is not much of a help because - ignoring id and model - the topic differs for most of the MQTT sensors / scripts.

Is there anything wrong with my question or is there no solution for it?

state_topic doesn’t support templates.

Not the “solution” I was looking for but it will end my search anyway. Thanks!

1 Like