Skip to content
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

Add support for diagnostics download #2

Merged
merged 3 commits into from
Jan 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__VERSION__ = "0.0.1"
__VERSION__ = "0.0.4"

bump:
bump2version --allow-dirty --current-version $(__VERSION__) patch Makefile custom_components/weatherlink/const.py custom_components/weatherlink/manifest.json
Expand Down
1 change: 1 addition & 0 deletions custom_components/weatherlink/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Constants for the Weatherlink integration."""

DOMAIN = "weatherlink"
VERSION = "0.0.4"

CONF_API_TOKEN = "conf_api_token"
34 changes: 34 additions & 0 deletions custom_components/weatherlink/diagnostics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Diagnostics support for Weatherlink."""
from __future__ import annotations

from homeassistant.components.diagnostics import async_redact_data
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

from .const import CONF_API_TOKEN, DOMAIN

TO_REDACT = {
CONF_PASSWORD,
CONF_USERNAME,
CONF_API_TOKEN,
"apitoken",
"DID",
}


async def async_get_config_entry_diagnostics(
hass: HomeAssistant, config_entry: ConfigEntry
) -> dict:
"""Return diagnostics for a config entry."""
coordinator: DataUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id][
"coordinator"
]

diagnostics_data = {
"info": async_redact_data(config_entry.data, TO_REDACT),
"data": async_redact_data(coordinator.data, TO_REDACT),
}

return diagnostics_data
2 changes: 1 addition & 1 deletion custom_components/weatherlink/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"zeroconf": [],
"homekit": {},
"dependencies": [],
"version": "0.0.1",
"version": "0.0.4",
"codeowners": [
"@strandb"
],
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.0.1
current_version = 0.0.4

[flake8]
exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build
Expand Down