You must look inside the .storage folder → core.config.entries
Unfortunately, in my case it wasn’t there. But I was wrong too, it was inside the database, probably I didn’t search it thoroughly the first time
.
In Lovelace, I clicked on the orphaned binary sensor, then on the cog icon and the message This entity (“binary_sensor.festivi”) doesn’t have an unique ID… addressed me to look for binary_sensor.festivi
in the database. These were the results:
[/share/home-assistant/.storage] # grep -l "binary_sensor.festivi" `find . -type f`
[/share/home-assistant/.storage] # cd ..
[/share/home-assistant] # grep -l "binary_sensor.festivi" `find . -type f`
./home-assistant_v2.db
So the Workday add-in actually saved in the database, not in core.config.entries
. To search for the “offending” tables I used:
[/share/home-assistant] # for X in $(sqlite3 home-assistant_v2.db .tables) ; do sqlite3 home-assistant_v2.db "SELECT * FROM $X;" | grep -q "binary_sensor.festivi" && echo "Found in table: '$X'" ; done
Found in table: 'events'
Found in table: 'states'
Then I did a HA backup, stopped HA, copied the home-assistant_v2.db
file in my PC and used DB Browser for SQLite to open it, as it’s easier to do then from the command-line (as I didn’t know the column names).
For each of the tables, it’s possible to remove the lines with the sensor by choosing the table from the dropdown (#1), typing the sensor name in the search box (#2), selecting each of the line and hitting the delete row button (#3).
Then I clicked on the Write changes button and to really delete the data I chose Tools > Compact database, selected main
and OK.
![DB3](https://community-assets.home-assistant.io/original/4X/f/1/1/f11ab7e65f2ed236649ef3c0bc191b9ddddf719a.png)
Finally I copied the database file to the HA location again, overwriting the previous one, started HA and the orphaned sensor was gone! ![:partying_face: :partying_face:](https://community.home-assistant.io/images/emoji/twitter/partying_face.png?v=12)
Probably a function inside the HA developer toos would have been useful, if existed!