Missing sensors in InfluxDB

I’m having some problems with data getting into InfluxDB from homeassistant (0.100.2 using the official docker image). Some stuff is fine, appearing under climate.kitchen absolutely fine. The following query works fine.

    FROM homeassistant climate.landing WHERE SELECT field (current_temperature) mean () GROUP BY time ($__interval) fill (null)

What’s odd is that some sensors seem to be being placed under tables which are named after the units of measurement. For example, the data rates from my router are appearing under kbytes/sec and not sensor.mikrotik_router_kbyte_sec_received:

    FROM homeassistant kbyte/sec WHERE SELECT field (value) mean () GROUP BY time ($__interval) fill (linear)

This is also happening with other components measurements like heating power setting which is being sent to the table %

My YAML for influx DB is very simple:

    influxdb:
        host: localhost
        port: 8086
        database: homeassistant
        max_retries: 3

Am I missing some config to explicitly state how to name tables?

OK, I’ve found out what’s going on. I’m documenting it here so that future people might find this.

If a unit of measurement is defined, then that is used as the measurement name, but entries are tagged with the sensor id. Therefore you need to add a WHERE clause to the query to filter out values. For example:

    SELECT mean("value") FROM "%" WHERE ("entity_id" = 'kitchen_humidity') AND $timeFilter GROUP BY time($__interval) fill(previous)

It seems this has been done so you can, for example, average all temperature measurements in the house, although to my experience that doesn’t really work.

9 Likes

Just wanted to say thank you for documenting this. I’ve been trying to work out where my temperature measurements had been going, as they weren’t under the measurement name.

Excellent, thanks for documenting this. I’ve been trying to fifure this out for a couple of days. Many thanks.
Cheers
Keith.

Resurrecting an old thread to say I’ve created a PR for this so hopefully it should appear in the official docs soon:

yes awesome, thanks! was confused by this myself. anyway to turn the behavior off? i’d prefer consistency where everything is its own measurement as it makes selecting things in grafana much easier.

Look at https://www.home-assistant.io/integrations/influxdb/#measurement_attr
If you set it to entity_id it will never use the unit of measure.

Old thread, but really useful even today. Using this finally allowed Grafana to be able to select the data I was expecting. Updating for the benefit of others as this is still top of the google hits for this.

measurement_attr: entity_id
2 Likes

Yes, thanks this is still catching people out it seems.

measurement_attr: entity_id is what I’d have expected by default.

1 Like