I got a new thermometer and humidity sensor with display yesterday, which I already added to HA. I would like to replace my existing bathroom sensor (with no display) by the new one, keeping my existing historical data for the bathroom and assigning it to the new sensor, so that the bathroom data continues to flow into the same data sync.
How can this be (easily) accomplished?
I’m not willing to do any ugly database hacks. It should be possible via the web UI, or I will simply forget about it.
They both measure temp and humidity. Is that the same thing? I don’t know. They could be in a different internal format? I have no clue about these internals…
Also, how would I rename the entities? Would that be on the below page, simply entering the new entity ID?
I’d be surprised if that works. There’s a metadata table in the recorder that maps entity ids to metadata_ids. The historical data is attached to the metadata id. It’s setup like this so you can rename an entity and not lose the history.
If you delete the old entity first then rename the new entity that may work.
What I usually do is shut down HA, manually edit the entity registry (.storage/config.entity_registry) and rename the entity ids there and that avoids the rename.
Exactly. Even with my limited experience I could tell that this would likely not work – I’ve renamed sensors a couple of times already, and every time I’ve kept my history…
Editing the registry (it’s an SQLite DB, isn’t it?) is something I don’t want to do. It’s not that I lack the relevant knowledge, it’s simply the risk about inconsistencies I’m not willing to take. This is why I would like to use only capabilities that have been built into HA to be used by end-users…
I think I’ll try deleting the old sensor and renaming the new one to the old entity name – if it fails and I lose my history, it’s not the end of the world… And the risk of “damaging” something seems close to zero…
I can confirm that this is working as I was hoping it would – the new sensor is now called as the old one used to be called, and I still see the historic temp and humidity values…
This is not 100% what I wanted to achieve, but as the historic sensor values of the new sensor are of no use (it’s few days anyway), I’ll consider the case solved.
Thanks, Pete. With my limited knowledge I consider even such “JSON hacking” risky, it could theoretically create inconsistencies anywhere… Maybe I’m “overcautious”, but I don’t want to run into problems later…
Anyway, as I wrote earlier, I’ve accomplished my main goal already…