- Python 100%
|
All checks were successful
## Summary Closes [MateoGreil/homeassistant-comwatt#22](https://github.com/MateoGreil/homeassistant-comwatt/issues/22). When a device is deleted on the Comwatt side, its entities and the device itself currently stay in HA's registries forever. This PR adds a prune pass that runs after `async_config_entry_first_refresh` succeeds: walk the entity registry and device registry for this config entry and drop anything whose unique_id / identifier is no longer present in the fresh topology snapshot. The prune only runs at setup (HA startup and integration reload), so a transient API hiccup during normal polling can never accidentally remove a real device — the first-refresh has to succeed, which means the topology we compare against is reliable. Device removal uses `async_update_device(remove_config_entry_id=...)` so HA removes the device only if no other integration still references it. ## Test plan - [x] New `test_setup_prunes_stale_entities_and_devices` in `test_init.py`: seeds a stale device + entity, runs setup with an API response that doesn't mention them, asserts they've been removed. - [x] `pytest tests/` — 25 passed. - [ ] Hands-on: on your HA, add a device in Comwatt app, reload the integration, confirm the new entities appear. Then remove that device from the Comwatt app, reload the integration, confirm the entity and device disappear from Settings → Devices & services → Comwatt. Reviewed-on: #17 |
||
|---|---|---|
| .github | ||
| custom_components/comwatt | ||
| tests | ||
| .gitignore | ||
| hacs.json | ||
| info.md | ||
| mypy.ini | ||
| pyproject.toml | ||
| pytest.ini | ||
| README-fr.md | ||
| README.md | ||
| requirements-test.txt | ||
Comwatt Integration for Home Assistant
Control your Comwatt energy monitoring system via the Comwatt API with Home Assistant. This integration work only with Comwatt Gen 4 (energy.comwatt.com). If you use go.comwatt.com, you need to use the ComwattIndepbox integration
Disclaimer
This Comwatt Integration for Home Assistant is not affiliated with, endorsed by, or in any way officially connected to Comwatt or its parent company. The integration is provided as-is and is not guaranteed to be suitable for any particular purpose. The use of this integration is at your own risk, and the author(s) of this integration will not be liable for any damages arising from the use or misuse of this integration.
Installation
- Install this integration using HACS by adding this repository or manually copy the files to your Home Assistant installation.
- Restart Home Assistant to load the integration.
Configuration
After installation, search and add component Comwatt in Home Assistant integrations page.
Usage
Once the integration is set up and configured, you will have access to sensors representing energy consumption and power consumption from your Comwatt devices. These entities can be added to your Home Assistant dashboard for monitoring and automation purposes.
Features
This integration can handle :
- Power consumption of device
- Energy consumption of device
- Power consumption of network in/out
- Energy consumption of network in/out
- Switch capacity of device
Contributions
Contributions and feedback are welcome! If you encounter any issues, have suggestions for improvement, or would like to contribute new features, please open an issue or submit a pull request on the GitHub repository.
If you find this integration useful, consider supporting the development by adding a star !