InfluxDB: renaming sensor name in the influxdb database

Hi,

I have stored a lot of data in the InfluxDB from a sensor called sensor.temperature_158d0002e966d7 . I would like to rename this sensor to a more meaningful name sensor.temperature_livingroom without losing all my already stored data in InfluxDB. How can I do that?

Using the influx client, I’ve tried SQL statements such as:

> SELECT * FROM "homeassistant"."autogen"."°C" WHERE time = 1594530983521684992

time                Measured Measured_str Stationname Stationname_str attribution_str battery_level device_class_str domain entity_id                  friendly_name_str icon_str value voltage
----                -------- ------------ ----------- --------------- --------------- ------------- ---------------- ------ ---------                  ----------------- -------- ----- -------
1594530983521684992                                                                   27            temperature      sensor temperature_158d0002e966d7 Buiten                     11.8  2.94

> UPDATE "homeassistant"."autogen"."°C" SET entity_id=temperature_livingroom WHERE entity_id=temperature_158d0002e966d7
ERR: error parsing query: found UPDATE, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1

But the UPDATE statement is obviously not supported by InfluxDB.

Some background info:

InfluxdB version: 3.7.2

~ $ ha info
arch: armv7
channel: stable

docker: 19.03.8
hassos: "4.11"
homeassistant: 0.112.4
hostname: homeassistant
logging: info
machine: raspberrypi4
supervisor: "228"
supported_arch:
- armv7
- armhf
timezone: Europe/Amsterdam

Configuration.yaml
influxdb:
host: 192.168.103.110
port: 8086
database: homeassistant
username: homeassistant
password: xxxxx
max_retries: 3
default_measurement: state
include:
entities:
- sensor.temperature_158d0002ca033a
- sensor.humidity_158d0002ca033a
- sensor.br_precipitation_2
- sensor.br_temperature_2
- sensor.br_pressure_2
- sensor.temperature_158d0002e966d7
- sensor.humidity_158d0002e966d7
- sensor.humidity
- sensor.tvoc
- sensor.temperature
- sensor.eco2

I’ve been banging my head on this and I’m hoping for someone to put me in the right direction.

Umberto

1 Like

Did you manage to rename the sensor in influxdb?

I’m currently in the same situation, so i’m curious if you managed to solve this?

Same question here… Want to rename an entity but am afraid that I’ll end up with multiple data sets. Therefore I would like to rename the old name in Influx to match the new name.

So I have the same issue. Want to rename sensor. Sensors in InfluxDB are ‘FIELD VALUES’.
I agree UPDATE is not supported. From searching I found this: stackoverflow. From what they said it is not possible in InfluxDB BUT this was 5 years ago. Can anyone please reply with any info on whether it’s possible to rename tag values (sensor names) in InfluxDB? If not, how can we merge two sensor data into one after renaming your sensor. This seems like a very important piece of maintenance. Thank you.

2 Likes