core: Turn of polling creates error on duplicate unique_id

The problem

Not entirely sure where the problem is but if you for a config entry turn off polling it tries to create entities twice and thereby complaining about not unique id. Therefore services such as update_entity does not work any longer

2022-06-12 17:58:08 DEBUG (SyncWorker_2) [homeassistant.components.sql.config_flow] Return value from query: 8512
2022-06-12 17:58:08 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.sql
2022-06-12 17:58:08 DEBUG (SyncWorker_0) [homeassistant.components.sql.sensor] Query select count(*) as states from states LIMIT 1; result in ROMappingView({'states': 8512})
2022-06-12 17:58:08 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.sql entity: sensor.select_sql_query

Turn off polling from config entry system options

2022-06-12 17:58:25 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.sql
2022-06-12 17:58:25 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.sql
2022-06-12 17:58:25 DEBUG (SyncWorker_3) [homeassistant.components.sql.sensor] Query select count(*) as states from states LIMIT 1; result in ROMappingView({'states': 8513})
2022-06-12 17:58:25 DEBUG (SyncWorker_1) [homeassistant.components.sql.sensor] Query select count(*) as states from states LIMIT 1; result in ROMappingView({'states': 8513})
2022-06-12 17:58:25 ERROR (MainThread) [homeassistant.components.sensor] Platform sql does not generate unique IDs. ID 23adb940c442279b96d879dfcf03c9bb already exists - ignoring sensor.select_sql_query

What version of Home Assistant Core has the issue?

dev

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

core

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

I rebased my dev now with all the last changes and verified the commit from #73387 is included. Still same outcome.