-
-
Notifications
You must be signed in to change notification settings - Fork 37.5k
Add diagnostics platform to Home Assistant Connect ZBT-2 #170158
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
homeassistant/components/homeassistant_connect_zbt2/diagnostics.py
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,13 @@ | ||
| """Provides diagnostics for the Home Assistant Connect ZBT-2 integration.""" | ||
|
|
||
| from typing import Any | ||
|
|
||
| from homeassistant.config_entries import ConfigEntry | ||
| from homeassistant.core import HomeAssistant | ||
|
|
||
|
|
||
| async def async_get_config_entry_diagnostics( | ||
| hass: HomeAssistant, config_entry: ConfigEntry | ||
| ) -> dict[str, Any]: | ||
| """Return diagnostics for a config entry.""" | ||
| return {"config_entry": config_entry.as_dict()} | ||
32 changes: 32 additions & 0 deletions
32
tests/components/homeassistant_connect_zbt2/snapshots/test_diagnostics.ambr
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,32 @@ | ||
| # serializer version: 1 | ||
| # name: test_diagnostics_for_config_entry | ||
| dict({ | ||
| 'config_entry': dict({ | ||
| 'data': dict({ | ||
| 'device': '/dev/serial/by-id/usb-Nabu_Casa_ZBT-2_80B54EEFAE18-if01-port0', | ||
| 'firmware': 'ezsp', | ||
| 'firmware_version': '7.3.1.0 build 0', | ||
| 'manufacturer': 'Nabu Casa', | ||
| 'pid': '4001', | ||
| 'product': 'ZBT-2', | ||
| 'serial_number': '80B54EEFAE18', | ||
|
Comment on lines
+6
to
+12
|
||
| 'vid': '303A', | ||
| }), | ||
| 'disabled_by': None, | ||
| 'discovery_keys': dict({ | ||
| }), | ||
| 'domain': 'homeassistant_connect_zbt2', | ||
| 'minor_version': 1, | ||
| 'options': dict({ | ||
| }), | ||
| 'pref_disable_new_entities': False, | ||
| 'pref_disable_polling': False, | ||
| 'source': 'user', | ||
| 'subentries': list([ | ||
| ]), | ||
| 'title': 'Mock Title', | ||
| 'unique_id': None, | ||
| 'version': 1, | ||
| }), | ||
| }) | ||
| # --- | ||
51 changes: 51 additions & 0 deletions
51
tests/components/homeassistant_connect_zbt2/test_diagnostics.py
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,51 @@ | ||
| """Tests for the diagnostics data provided by the Home Assistant Connect ZBT-2 integration.""" | ||
|
|
||
| from syrupy.assertion import SnapshotAssertion | ||
| from syrupy.filters import props | ||
|
|
||
| from homeassistant.core import HomeAssistant | ||
| from homeassistant.setup import async_setup_component | ||
|
|
||
| from .common import USB_DATA_ZBT2 | ||
|
|
||
| from tests.common import MockConfigEntry | ||
| from tests.components.diagnostics import get_diagnostics_for_config_entry | ||
| from tests.typing import ClientSessionGenerator | ||
|
|
||
|
|
||
| async def test_diagnostics_for_config_entry( | ||
| hass: HomeAssistant, | ||
| hass_client: ClientSessionGenerator, | ||
| snapshot: SnapshotAssertion, | ||
| ) -> None: | ||
| """Test diagnostics for config entry.""" | ||
| await async_setup_component(hass, "homeassistant", {}) | ||
|
|
||
|
|
||
| # Set up the ZBT-2 integration | ||
| zbt2_config_entry = MockConfigEntry( | ||
| domain="homeassistant_connect_zbt2", | ||
| data={ | ||
| "firmware": "ezsp", | ||
| "firmware_version": "7.3.1.0 build 0", | ||
| "device": USB_DATA_ZBT2.device, | ||
| "manufacturer": USB_DATA_ZBT2.manufacturer, | ||
| "pid": USB_DATA_ZBT2.pid, | ||
| "product": USB_DATA_ZBT2.description, | ||
| "serial_number": USB_DATA_ZBT2.serial_number, | ||
| "vid": USB_DATA_ZBT2.vid, | ||
| }, | ||
| version=1, | ||
| minor_version=1, | ||
| ) | ||
|
Comment on lines
+25
to
+39
|
||
| zbt2_config_entry.add_to_hass(hass) | ||
|
|
||
| assert await hass.config_entries.async_setup(zbt2_config_entry.entry_id) | ||
| await hass.async_block_till_done() | ||
|
|
||
| diagnostics_data = await get_diagnostics_for_config_entry( | ||
| hass, hass_client, zbt2_config_entry | ||
| ) | ||
|
|
||
| assert diagnostics_data == snapshot( | ||
| exclude=props("created_at", "modified_at", "entry_id") | ||
| ) | ||
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.
I don't think we need to redact the unique id, as it doesn't contain any secrets or personal data