Comments (11)
@bcutter Thanks for the pointer, seems you just have to tell homeassistant as a component that you're ready to delete. I added this. Apologies, I misunderstood you to be asking for me to write code to programmatically change the homeassistant device database files which I'm not really comfortable doing.
I'd like to add that this is github so anyone is able to make a pr. And I promise: If it works I'll merge it.
from pyduofern-hacs.
I added sync_devices
back with reduced functionality. no real need for it anymore with the reload integration facility though. Basically what it was doing was what reload integration is doing now.
I do not really see a v1.0 in the future - there's just too many loose ends
Same for official integration. I can't really provide the service level I'd expect from an official HA integration.
from pyduofern-hacs.
As you have manual access the easiest way to get rid of the ghost devices is likely to:
- stop homeassistant
- make a backup copy of duofern.json
- empty the list of devices (removing everything between the square brakets after devices)
- start homeassistant again
- at first all duofern devices will be disabled/unavailable
- calling clean config a few times will force it to write the config to disc and you can see the number of duofern entries increasing in duofern.json (should be just real devices, no ghosts)
- once all devices are there you can restart homeassistant. If some devices seem to "not come back" moving them (manually with the local controls) makes them send messages for homeassistant to receive and detect them.
- devices are available again
so going from this
"devices": [
{
"id": "409f82",
"name": "409f82"
},
....
{
"id": "7fffec",
"name": "7fffec"
}
]
to this:
"devices": [ ]
I observe the occasional ghost device, but not hundreds of them. Maybe 3 a year or so. It has been like this for me from the very start - not a sudden influx of ghost devices on my side (yet?).
For me it takes a bit of time with homeassistant running for it to re-add all my devices to duofern.json again. I was able to speed it up by moving the devices. In the end a restart made my (previously disabled) devices active again.
Mind you: creating an empty duofern.json is exactly what clean_config should be doing. literally it empties the config copy in ram and saves it immediately. But it seems that the devices are still in memory make back into the memory-version of the config so fast that they get saved again.
I ran the above process to get rid of my two "ghost" devices.
Warning
The above is valid for 0.5.5. With 0.5.6 the clean_config service actually works and you have to call sync_devices to write config instead of the above "clean_config" while re-populating your config.
from pyduofern-hacs.
Regarding where devices come from:
you are mostly right - devices are created by duofernstick when it receives radio messages that appear to be valid by a device id. It occasionally saves the known devices to duofern.json. It also tells homeassitant about new devices and "homeassistant devices" get automatically created for the [physical] devices. I believe that homeassistant may retain its own memory of them so it may be necessary to remove/disable the unwanted devices in homeassistant separately once they are removed from duofern.json. I had that workflow with other integrations that created devices.
from pyduofern-hacs.
I see we already fixed this in april
from pyduofern-hacs.
Warning
The above is valid for 0.5.5. With 0.5.6 the clean_config service actually works and you have to call sync_devices to write config instead of the above "clean_config" while re-populating your config.
Will this be reflected in the docs too?
No we did not fix it @gluap. But I ran the clean procedure right now with the result:
- Cleanup
duofern.json
done - HA restarted, all devices and entities unavailable, duofern.json still clean
- Tried to trigger populating the duofern.json by moving my covers locally/manually, waited, tried again etc. - nothing happend (duofern.json still clean)
- Ran service
duofern.sync_devices
which immediately added all - and ONLY the currently physically really existing - devices again. Devices and entities still unavailable, so step 5 - Restarted HA once again, now devices and entities are back,
duofern.json
still without ghost devices - pretty much exactly as you described the whole process.
Summary:
- 94 ghost devices (according to
duofern.json
) removed successfully 🎉 - Unfortunately I still have two ghost devices in the HA device registry which can not be deleted (deleting devices must be supported by the integration itself):
...and tbh I fear editing the core.device_registry
and core.entity_registry
files manually, that always was a bad idea. So "90 % fixed" (not completely solved) in terms of "duofern.json is clean, but devices still exist in HA".
And as I will integrate few more devices in the next days I'm curious to see if the ghost devices are coming back.
from pyduofern-hacs.
@bcutter Well for me that's all the fixing that needs to be done on the custom component side - providing tools to maintain the device registry really shouldn't have to be done by individual components. Homeassistant decided that disabling dead devices is enough, so that's the same for me.
from pyduofern-hacs.
Homeassistant decided that disabling dead devices is enough, so that's the same for me.
Home Assistant a long time ago decided to offer integrations the possibility to delete devices to even walk that last mile. No need to keep plenty of disabled but dead devices AND entities anymore. Two quick examples:
That whole legacy duofern.json
file handling not in sync with the HA device registry obviously IS an issue. You're the only one able to fix this so it's up to you - just wanted to point out there are ways (and a need).
from pyduofern-hacs.
No need to re-invent things provided natively by HA 😃
Of course it is GH, unfortunately there don't seem to be many users with dev skills around duofern in general. So I'm always counting on you 😆
With https://github.com/gluap/pyduofern-hacs/releases/tag/v0.5.11 it seems you already implemented this? Wow, awesome 👍
I'm curious to test this asap.
Off-topic (but important) on
remove non-working sync device command and document.
that service did not work? Can't actually remember. BUT according to my own device setup and integration chcklist after using duofern.start_pairing
it was actually needed to use that duofern.sync_devices
service for devices / entities to actually get created in HA. Did that change? As mentioned I'm about to integrate few more duoFern devices shortly... so therefore just wondering.
Edit: found d19da54 and really wondering if this is the way to go... I need to restart HA to grab new devices now? Oh well that feels like a step backward TBH. I really prefer a service to take care of that (if not done automatically what is the default behaviour of modern integrations - but I understand pyduofern seems to have a quite rusty base so probably those are workarounds to fit that base into the modern HA, aren't they?). 😲
from pyduofern-hacs.
@bcutter Yeah, I also prefer homeassistant to take care of that but it's not worked for a long time due to changes in how devices are registered in homeassistant. Installing new shutters is something one does only do very rarely, and restarting homeassistant only adds like a minute at most to that procedure, so instead of a non working service with the empty promise that it fixes things I think its best for the documentation to just be honest about it.
from pyduofern-hacs.
due to changes in how devices are registered in homeassistant.
Maybe we should adopt to this change? Otherwise this for sure is a showstopper for a future v1.0 or even becoming an official integration.
I think its best for the documentation to just be honest about it.
I find that service still quite a lot in the docs (readme).
from pyduofern-hacs.
Related Issues (20)
- DUOFERN receives unknown message during setup HOT 7
- [Feature Request] Make five minutes auto update feature configurable (allow enable/disable by user) HOT 14
- Unknown msg: xxxxxxxxxxxxxxxxx in HA log since 0.4.1. HOT 4
- Feature Request: Add Sun Sensor 9478 HOT 5
- v0.5.1 dependency (needs HA Core 2023.3.2) HOT 3
- "er.a is not a valid duofern device" since v0.4.3 HOT 10
- Cover does not accept commands from HA (only one-way communication) HOT 11
- Some covers not closing reliably (commands likely not received) HOT 8
- Service "clean_config" not documented HOT 4
- Using parameter "all" for service "ask_for_update" gives error in v0.5.4 HOT 6
- Tons of log entries HOT 7
- Write queue filling up HOT 6
- duofern component cannot be loaded HOT 14
- duofern.sync_devices throws ‘ConfigEntries’ object has no attribute ‘async_setup_platforms’ HOT 5
- Home Assistant HACS Update duofern from 0.3.2 to 0.5.8 - no control anymore HOT 4
- Removing devices from HA registry fails HOT 2
- Wrong device status after reloading integration HOT 3
- Integration of thermostats HOT 2
- Set running time
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyduofern-hacs.