-
-
Notifications
You must be signed in to change notification settings - Fork 37.2k
Add WattWächter Plus integration #165238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
smartcircuits
wants to merge
33
commits into
home-assistant:dev
Choose a base branch
from
SmartCircuits-GmbH:add-wattwaechter-integration
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add WattWächter Plus integration #165238
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
d19d94d
add wattwaechter integration
smartcircuits 1d78171
fix _attr_in_progress: use None instead of False
smartcircuits 0d9e034
fix codeowner to smartcircuits
smartcircuits 1eee386
slim down PR per review: single platform, no diagnostics/reauth/recon…
smartcircuits d78059b
fix CI: bronze tier, mypy, pylint, test imports
smartcircuits 9f98d10
fix CI: add quality_scale to manifest, requirements, ruff fixes
smartcircuits 56a5a77
address review feedback from joostlek
smartcircuits 50146b3
fix CI: ruff PERF401, generated file ordering, CODEOWNERS
smartcircuits 22eb28e
Merge branch 'dev' into add-wattwaechter-integration
smartcircuits ce041e5
Merge branch 'dev' into add-wattwaechter-integration
smartcircuits dcc3f57
Merge branch 'dev' into add-wattwaechter-integration
smartcircuits 10bb44d
fix ruff import order, prettier JSON sorting, integrations.json format
smartcircuits 5c6e4b7
fix ruff formatting, import sorting, add mypy.ini entry
smartcircuits 8c3a8b4
fix circular import: use TYPE_CHECKING for WattwaechterConfigEntry
smartcircuits 3888be2
fix ruff: remove parentheses from multi-except (python 3.14)
smartcircuits feb385d
fix integrations.json field order to match hassfest generation
smartcircuits 0c6a291
address second round of review feedback
smartcircuits bec90b2
Merge remote-tracking branch 'upstream/dev' into add-wattwaechter-int…
smartcircuits e8b5151
add return type annotations to test fixtures
smartcircuits 39397c2
address third round of review feedback
smartcircuits a2d2b8f
fix except clause syntax for python 3.12 compatibility
smartcircuits 20aac42
raise ConfigEntryNotReady when no meter data available on first poll
smartcircuits 3b0fcf8
remove PARALLEL_UPDATES constant
smartcircuits 1b817b0
import WattwaechterConfigEntry from coordinator instead of package root
smartcircuits 27e6a0d
restore PARALLEL_UPDATES and add None guard for mypy
smartcircuits 1597e2f
raise UpdateFailed on WattwaechterNoDataError to preserve last known …
smartcircuits e21b584
store empty string instead of None for device_name in config entry data
smartcircuits 172231c
remove unused _LOGGER from sensor module
smartcircuits e700542
remove leftover wifi diagnostic sensor icons
smartcircuits 33923f3
use entity registry unique_id lookups instead of hardcoded entity IDs…
smartcircuits d4c5a36
use unknown error instead of cannot_connect when device_id is missing
smartcircuits 1a90ac9
add test for auth error during coordinator first refresh
smartcircuits 6c78fd5
add missing tests for full codecov coverage
smartcircuits File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| """The WattWächter Plus integration.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| from datetime import timedelta | ||
|
|
||
| from homeassistant.config_entries import ConfigEntry | ||
| from homeassistant.const import CONF_HOST, CONF_SCAN_INTERVAL, CONF_TOKEN, Platform | ||
| from homeassistant.core import HomeAssistant | ||
| from homeassistant.exceptions import ConfigEntryNotReady | ||
| from homeassistant.helpers.aiohttp_client import async_get_clientsession | ||
|
|
||
| from aio_wattwaechter import Wattwaechter, WattwaechterConnectionError | ||
| from .const import DEFAULT_SCAN_INTERVAL, DOMAIN | ||
| from .coordinator import WattwaechterCoordinator | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
| PLATFORMS = [Platform.SENSOR, Platform.UPDATE] | ||
|
|
||
| type WattwaechterConfigEntry = ConfigEntry[WattwaechterCoordinator] | ||
|
|
||
|
|
||
| async def async_setup_entry( | ||
| hass: HomeAssistant, entry: WattwaechterConfigEntry | ||
| ) -> bool: | ||
| """Set up WattWächter Plus from a config entry.""" | ||
| host = entry.data[CONF_HOST] | ||
| token = entry.data.get(CONF_TOKEN) | ||
|
|
||
| session = async_get_clientsession(hass) | ||
| client = Wattwaechter(host, token=token, session=session) | ||
|
|
||
| # Verify device is reachable | ||
| try: | ||
| await client.alive() | ||
| except WattwaechterConnectionError as err: | ||
| raise ConfigEntryNotReady( | ||
| translation_domain=DOMAIN, | ||
| translation_key="cannot_connect", | ||
| translation_placeholders={"host": host}, | ||
| ) from err | ||
smartcircuits marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| coordinator = WattwaechterCoordinator(hass, entry, client) | ||
| await coordinator.async_config_entry_first_refresh() | ||
|
|
||
| entry.runtime_data = coordinator | ||
|
|
||
| await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) | ||
|
|
||
| # Update listener for options changes (e.g. scan interval) | ||
| entry.async_on_unload(entry.add_update_listener(_async_update_listener)) | ||
|
|
||
| return True | ||
|
|
||
|
|
||
| async def _async_update_listener( | ||
| hass: HomeAssistant, entry: WattwaechterConfigEntry | ||
| ) -> None: | ||
| """Handle options update - dynamically adjust coordinator interval.""" | ||
| coordinator = entry.runtime_data | ||
| new_interval = entry.options.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL) | ||
| coordinator.update_interval = timedelta(seconds=new_interval) | ||
| await coordinator.async_request_refresh() | ||
|
|
||
|
|
||
| async def async_unload_entry( | ||
| hass: HomeAssistant, entry: WattwaechterConfigEntry | ||
| ) -> bool: | ||
| """Unload a WattWächter Plus config entry.""" | ||
| return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description claims "MQTT conflict detection (prevents duplicate entities)" but there is no MQTT-related code in the integration. This feature is not implemented in the provided code.