@michaelblight Hi Michael, thanks for your response - that’s very helpful, and I think I understand a little better now. You are saying that it’s the integration itself which sets what is passed as an attribute and what is an entity. This is something I didn’t grasp before (I thought it’s something we as the user prescribed).
“You can always add the unwanted ones to “ignore_attributes” in the influxdb integration if it bothers you.”
I have tried to follow your suggestion, and the best I could do was this messy looking config file:
influxdb:
host: 192.168.0.48
port: 8086
database: homeassistant
username: homeassistant
password: *password*
include:
entities:
- sensor.snzb_02_sensor_1_temperature
- sensor.snzb_02_sensor_2_temperature
- sensor.snzb_02_sensor_1_humidity
- sensor.snzb_02_sensor_2_humidity
- sensor.snzb_02_sensor_1_battery
- sensor.snzb_02_sensor_2_battery
- sensor.snzb_02_sensor_1_linkquality
- sensor.snzb_02_sensor_2_linkquality
- sensor.snzb_02_sensor_1_voltage
- sensor.snzb_02_sensor_2_voltage
component_config_glob:
sensor.snzb_02_sensor_*_temperature:
override_measurement: temperature
ignore_attributes:
- battery
- humidity
- linkquality
- voltage
- device_class
- friendly_name
- state_class
- unit_of_measurement
sensor.snzb_02_sensor_*_humidity:
override_measurement: humidity
ignore_attributes:
- battery
- temperature
- linkquality
- voltage
- device_class
- friendly_name
- state_class
- unit_of_measurement
sensor.snzb_02_sensor_*_battery:
override_measurement: battery
ignore_attributes:
- temperature
- humidity
- linkquality
- voltage
- device_class
- friendly_name
- state_class
- unit_of_measurement
sensor.snzb_02_sensor_*_linkquality:
override_measurement: linkquality
ignore_attributes:
- battery
- temperature
- humidity
- voltage
- device_class
- friendly_name
- state_class
- unit_of_measurement
sensor.snzb_02_sensor_*_voltage:
override_measurement: voltage
ignore_attributes:
- battery
- temperature
- linkquality
- humidity
- device_class
- friendly_name
- state_class
- unit_of_measurement
(note that I decided to include override_measurement
for each, because I actually realised I had both battery and humidity in the “%” measurement, which was what I was trying to avoid). Doing it this way works reasonably well:
“It’s also pretty common where the state is a number for integrations to also have it as an attribute. This is because an entity’s state is always a string value, whereas an attribute can be a number.”
This is very helpful to know - thanks!
“You could choose to add “temperature” to “ignore_attributes”, but having it there as a number is more useful.”
Can you give an example of a situation where the number is more useful than the string in the InfluxDB database? For example, in Grafana, I am able to graph both “value” and “temperature” interchangably (assuming one is a string and one is a float, as you say).
“At the end of the day, does it matter that influx db has a few extra columns?”
Yes, it matters just because the size of the database will grow faster. I have seen this thread, where this issue seemed to have been run into as a result of all the extra attributes.
“However this can be changed to “entity_id” if you want.”
The problem with this is that you can never use the GROUP BY()
function to group the data by tags. You can see in the screenshot below that using GROUPBY(entity_id)
allows you to automatically populate all the graphs in a single query (which can be very useful if you have dozens of sensors). If each measurement was given by its entity_id
, then you would have to individually put the queries in.
I guess one other option would be to actually make use of all the attributes of the temperature entity, and don’t bother sending the other entities (humidity, etc) to InfluxDB. Then call the measurement name something like RHTsensors. Something like this:
influxdb:
host: 192.168.0.48
port: 8086
database: homeassistant
username: homeassistant
password: *password*
include:
entities:
- sensor.snzb_02_sensor_1_temperature
- sensor.snzb_02_sensor_2_temperature
component_config_glob:
sensor.snzb_02_sensor_*_temperature:
override_measurement: RHTsensors
ignore_attributes:
- device_class
- friendly_name
- state_class
- unit_of_measurement
which results in this:
Do you have any other thoughts / suggestions based on this, that might be a good way to go?
Thanks very much for your comments.