Skip to content

Commit

Permalink
Merge pull request #2 from astrandb/Diag
Browse files Browse the repository at this point in the history
Add support for diagnostics download
  • Loading branch information
astrandb authored Jan 29, 2022
2 parents 60638c6 + 6423817 commit bd0aaf8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
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

0 comments on commit bd0aaf8

Please sign in to comment.