I have a single mqtt topic that contains all my humidity/temperature sensors. Each message is simply a json containing the sensor values, a timestamp and sensor ID.
HA can read the topic just fine, but seems to have problems parsing out the device names. I managed to split humidity and tempature into to sensors (by the magic of defining the sensor twice), but I can’t really distinguish between the different devices.
Is there a way to dynamically parse the device IDs and create sensors based on that? If necessary, I could do a bit of magic in Telegraf, but I assume HA can do that itself?
You mean that you just want to have one configuration entry? I doubt that it’s possible.
What you could do is creating multiple entries, but you need filter within a template.
{% if value_json['tags'].path == '/mnt/hdd' %} {{ (value_json['fields'].used_percent | float(default=0)) | round(2) }} {% else %} {{ states('sensor.disk_use_percent_sdb3') }} {% endif %}
Having had a similar use case, I ended up configuring device specific topics within telegraf.