I’m using several mqtt sensors and influxdb with grafana.
This worked ok for the first sensor: I was able to find it in grafana.
Since that sensore reports temperature, humidities and rotation of a fan, I added more entries, so all of the values are available in lovelace and in grafana.
I added the unit_of_measurement entry to the config, which brings me -literally- the unit of measurement to grafana. I rather expected the name of the sensor to be selectable, not the “g/m^3”.
I read the docs but was unable to find s.th. reasonable. I tried to specify unique_id, but this didn’t help either.
Sort of, I’ve written a small tool that listens on specific mqtt topics and pushed them into influx. Since some processing may be required, it’s pluggable, so that one can adapt the processing by providing one’s own python code.
It’s independent of home-assistant, as it solely interfaces with mqtt and influx.
I’ve developed it against my private git repo, but I can upload it to github, if you’re interested.
Try “Toggling Edit Mode” and then write your own query…I find it works much better and is more precise. Use the grafana docs to get other ideas for constructing your own queries.
I use this query for my sensors (including MQTT) hasn’t failed yet for me this query:
SELECT mean("value") FROM "V" WHERE ("entity_id" = '240_v') AND $timeFilter GROUP BY time($__interval) fill(null)
NOTE "V" = YOUR_unit_of_measurement, WHILE '240_v' = your_entity_ID
What you want to achieve is actually independent of MQTT. You may use the influxdb integration and map the entity_ids to units as below.
In Grafana you can just then use these units to select all entity_ids that output these units. Then delineate them by using GROUP_BY with tag(entity_id) (literally as written here). As Alias you may want to use $tag_entity_id (literally).
Hi,
I had the same problem and I thought I’d share the solution: Home Assistant uses the unit of measurement as the default for measurement_attr and falls back to ‘entity_id’ if no unit is specified. To always use the entity ID just add this to the influxdb config section: