Migrating over from StealthChesnut integration (finally) - how to avoid duplicate sensors? #342
-
Finally got around to trying to migrate to this integration, following Dave Foster's directions here. I removed the modbus: !include custom_components/foxess/modbus485.yaml line from my configuration.yaml, as well as the other custom template sensors defined there (see Sensors Removed, below). I left in the utility_meter section, as well as all the integration sensors (each included in their own sections) Once I'd done this I restarted HA, confirmed that the dashboards were all showing "Not available" and then installed foxess_modbus from HACS. The install went fine, but after restarting I found that I had duplicate sensors all over the show with the dreaded "_2" appended. I'd taken a full image back of my HA VM before I started so I've gone back to that for now, but I'm wondering what I did wrong in my process - do I need to delete the old entities somehow before installing the integration from HACS? Sensors Removed
Utility Meters (kept)
Integration sensors (kept)
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 30 replies
-
@calum-mcfarlane Were all the sensors appended with the _2 or just some - do you have any examples of them? Also when setting up did you set a friendly name or leave blank? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Seem to have answered my own second question, it does look like if I just delete the old entity and rename the new one the history sorts itself out... |
Beta Was this translation helpful? Give feedback.
-
@nathanmarlor No I don't believe so - whenever i've seen it happen (on other peoples systems), it's because of either not removing the old modbus include, or HA being blocked from restarting because of modbus timeouts before the new integration is added - and I suspect part of the problem is that once it goes wrong, you have to delete the integration and all of the _2 sensors or the integration will continue to use them next time it's added. It happened to me right at the beginning, but that was a definite case of my HA blocking shutdown, i've built maybe 6 systems since and every one has been fine... confusing.. 🤪 It would certainly be helpful to me to understand the mechanism of registering sensors, and whether using different databases (sqlite, mariadb etc..) might be part of it. |
Beta Was this translation helpful? Give feedback.
-
If you deleted all the old sensors en masse before you installed the new integration from HACS, presumably all the new sensors wouldn't get _2 appended to them, and the whole thing would be an awful lot simpler 🤣 Feels like a note to say "if you have unique IDs in your YAML then you want to do this extra step" would handle it? |
Beta Was this translation helpful? Give feedback.
-
I just tried a quick test with a template sensor, I created a sensor called batt_discharge_w (sensor.battery_discharge*1000) with it's own unique_id, and checked it was reporting ok, I then removed the template, refreshed templates so it was showing as unavailable. Then replaced it with the same sensor name but one digit different in the unique_id and this is what I got - It looks like once the unique_id has been set you can't replace the entity, you have to delete the old entity which removes it's registration entry, then rename the new entity (or manually edit the core.entity_registry in the .storage directory.)
|
Beta Was this translation helpful? Give feedback.
@calum-mcfarlane - The old sensor was a template using the sum of pv1_power + pv2_power as it's source, both of those still exist in the new integration and that's why I said to leave the original PV Power Now template in place as it will continue to provide you with the sum of pv1 + 2 and all your history is intact - also if/when you upgrade the integration everything keeps working.
So just continue to use PV Power Now as you used to, and you've got a 'spare' sensor if in future you decide you want to move to the internally generated PV Power, but other than storage space there is no reason too.
You could remove the integration one from your logger (or disable it) if you want to keep you…