-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"New entity_id is already in use" error when renaming any entity #115747
Comments
Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) recorder documentation |
Also getting this. |
I can confirm the warning message has appeared every time I have renamed an entity_id. In all cases, the new entity_id didn't already exist.
|
I have the same issue on latest HA. Since zwave-js-ui doest grab and name/location during interview, I have to manually rename devices and lose past history with this error. |
I am having the same issue on two instances. Not sure if related to using mariadb |
Same here. New entity_id was not existing.
Logger: homeassistant.components.recorder.entity_registry
Source: components/recorder/entity_registry.py:76
integration: Recorder (documentation, issues)
First occurred: 4:35:37 PM (1 occurrences)
Last logged: 4:35:37 PM
Cannot migrate history for entity_id `sensor.envoy_122302045041_inverter_122219084557` to `sensor.inverter_122219084557` because the new entity_id is already in use Tried twice in a dev environment, same issue in both cases. This is the HA log file with Problem seems to be that Stepped through it in dev debug and have screenshots if needed. Still finding when the new id gets inserted. |
Similar to #114559 !? |
Adding some debug log to the issue. Renaming 2024-07-07 14:46:43.284 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140668635779216]
Arie from 172.17.0.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0):
Received {'type': 'config/entity_registry/update',
'entity_id': 'sensor.inverter_482246047880', 'name': None, 'icon': None, 'area_id': None, 'labels': [],
'new_entity_id': 'sensor.inverter_482246047880_added', 'options_domain': 'sensor', 'options': {'display_precision': None}, 'id': 54}
2024-07-07 14:46:43.303 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event entity_registry_updated[L]:
action=update,
entity_id=sensor.inverter_482246047880_added, changes=entity_id=sensor.inverter_482246047880,
old_entity_id=sensor.inverter_482246047880>
2024-07-07 14:46:43.339 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]:
entity_id=sensor.inverter_482246047880,
old_state=<state sensor.inverter_482246047880=0; state_class=measurement, unit_of_measurement=W, device_class=power, icon=mdi:flash, friendly_name=Inverter 482246047880 @ 2024-07-07T16:43:24.116413+02:00>,
new_state=None>
2024-07-07 14:46:43.352 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: <Event state_changed[L]:
entity_id=sensor.inverter_482246047880,
old_state=<state sensor.inverter_482246047880=0; state_class=measurement, unit_of_measurement=W, device_class=power, icon=mdi:flash, friendly_name=Inverter 482246047880 @ 2024-07-07T16:43:24.116413+02:00>,
new_state=None>
2024-07-07 14:46:43.376 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]:
entity_id=sensor.inverter_482246047880_added,
old_state=None,
new_state=<state sensor.inverter_482246047880_added=0; state_class=measurement, unit_of_measurement=W, device_class=power, icon=mdi:flash, friendly_name=Inverter 482246047880 @ 2024-07-07T16:46:43.372239+02:00>>
2024-07-07 14:46:43.384 DEBUG (Recorder) [homeassistant.components.recorder.core]
Processing task: <Event state_changed[L]: entity_id=sensor.inverter_482246047880_added,
old_state=None,
new_state=<state sensor.inverter_482246047880_added=0; state_class=measurement, unit_of_measurement=W, device_class=power, icon=mdi:flash, friendly_name=Inverter 482246047880 @ 2024-07-07T16:46:43.372239+02:00>>
2024-07-07 14:46:43.398 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event entity_registry_updated[L]:
action=update, entity_id=sensor.inverter_482246047880_added, changes=options=conversation=should_expose=False>
2024-07-07 14:46:43.400 DEBUG (Recorder) [homeassistant.components.recorder.pool.RecorderPool] Connection <sqlite3.Connection object at 0x7ff0384ec7c0> checked out from pool
2024-07-07 14:46:43.412 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: UpdateStatisticsMetadataTask(
statistic_id='sensor.inverter_482246047880', new_statistic_id='sensor.inverter_482246047880_added', new_unit_of_measurement=<UndefinedType._singleton: 0>)
2024-07-07 14:46:43.459 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_reported[L]:
entity_id=sensor.inverter_482246047880_added, old_last_reported=2024-07-07T16:46:43.372239+02:00,
new_state=<state sensor.inverter_482246047880_added=0; state_class=measurement, unit_of_measurement=W, device_class=power, icon=mdi:flash, friendly_name=Inverter 482246047880 @ 2024-07-07T16:46:43.372239+02:00>>
2024-07-07 14:46:43.547 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: UpdateStatesMetadataTask(
entity_id='sensor.inverter_482246047880', new_entity_id='sensor.inverter_482246047880_added')
2024-07-07 14:46:43.553 WARNING (Recorder) [homeassistant.components.recorder.entity_registry]
Cannot migrate history for entity_id `sensor.inverter_482246047880` to `sensor.inverter_482246047880_added` because the new entity_id is already in use
2024-07-07 14:46:43.553 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: <Event entity_registry_updated[L]:
action=update, entity_id=sensor.inverter_482246047880_added, changes=entity_id=sensor.inverter_482246047880, old_entity_id=sensor.inverter_482246047880> |
@bdraco Thanks for your work on this integration, as we already found out it started after the 2024.4 release, so this might be in the ballpark where you're looking for: Do you have any idea when this will be fixed? It has become quite a major feature in my opinion, especially with the long-term statistics and such. |
#114559 is also related and there |
Believe some work is needed here in general. Making sure renaming properly
carries over history/logs. Additionally, the ability to merge device data.
If you replace a sensor, and don’t give two hoots about the ID or keeping
separate logs or history and want to merge the data, there should be an
option. These items may go hand in hand and improvements are needed in this
database specific realm.
…On Thu, Jul 11, 2024 at 23:44 rrooggiieerr ***@***.***> wrote:
#114559 <#114559> is also
related and there core-2024.3.3 was used
—
Reply to this email directly, view it on GitHub
<#115747 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKAGRDFOHHYZ6VAAZHFSPNTZL5GI3AVCNFSM6AAAAABGK4W5BOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRUGM3TIOBVGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@polskikrol Let's don't get off track here, merging data is a whole other topic. If this issue is fixed you can replace a device, give it the old entity id and data capture will pick up where it left off. Then, if you didn't use a certain entity ID before and change it to that new ID, it will hold the history data. |
As I needed entity rename for an integration device replacement I tried it again on 2024.9.0.dev202408170220. 2024-08-18 14:08:00.440 WARNING (Recorder) [homeassistant.components.recorder.entity_registry] Cannot migrate history for entity_id `sensor.envoy_123456789003_current_power_production` to `sensor.envoy_123456789004_current_power_production` because the new entity_id is already in use Looking into the states table I see new entity-id is added and takes over state logging, but old entity-id states are not transferred, i.e. old entity_id is not renamed. As mentioned in the log entry, something inserted the new entity-id in state-meta and the recorder found it there already and held back renaming existing entries or so. Entity-id change was at 14:08 Event data: {
"action":"update",
"entity_id":"sensor.envoy_123456789004_current_power_production",
"changes":{"entity_id":"sensor.envoy_123456789003_current_power_production"},
"old_entity_id":"sensor.envoy_123456789003_current_power_production"
}
{
"action":"update",
"entity_id":"sensor.envoy_123456789004_current_power_production",
"changes":{"options":{"sensor.private":{"suggested_unit_of_measurement":"kW"},
"sensor":{"suggested_display_precision":3},
"conversation":{"should_expose":false}}}
} Entries in state table Entries in statistic_short_term table. Here entity-id was updated in the meta. |
Did some more testing to determine what is going on. observations
Analysis
What is happening seems obvious, why not though. Did something change in timing with code changes over time, some race condition introduced. Only state data/history is impacted. Statistics and statistics_short_term as the statistics_meta entry update works fine. EDIT1: version 2024.3.1 shows same issue, behavior and sequence of events/tasks EDIT2: Before 202403.0 other query error occur. Not testing older versions. |
hey, just want to inform that the issue still persists in home assistant 2024.10.3 |
Have this exacly issue renaming new devices with ZHA |
According to the testing of "catsmanac", a temporary solution is obtained: |
Having the same issue in 2024.12.5. Any update on this please? |
Seems to be related to this change: #112718 |
Tried @yangyankui's recipe in a dev and for my case it worked. |
The problem
Whenever an entity is renamed via the UI it generates an error claiming the entity is already in use.
e.g.
Before:
After (there was no sensor that ended in "foobar"):
Result:
What version of Home Assistant Core has the issue?
core-2024.4.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
No response
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: