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

Get diagnostics of all devices in ViCare account #102218

Merged
merged 7 commits into from
Oct 18, 2023
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
5 changes: 4 additions & 1 deletion homeassistant/components/vicare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
PLATFORMS,
VICARE_API,
VICARE_DEVICE_CONFIG,
VICARE_DEVICE_CONFIG_LIST,
HeatingType,
)

Expand Down Expand Up @@ -83,7 +84,9 @@ def setup_vicare_api(hass: HomeAssistant, entry: ConfigEntry) -> None:
)

# Currently we only support a single device
device = vicare_api.devices[0]
device_list = vicare_api.devices
device = device_list[0]
hass.data[DOMAIN][entry.entry_id][VICARE_DEVICE_CONFIG_LIST] = device_list
hass.data[DOMAIN][entry.entry_id][VICARE_DEVICE_CONFIG] = device
hass.data[DOMAIN][entry.entry_id][VICARE_API] = getattr(
device,
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/vicare/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
]

VICARE_DEVICE_CONFIG = "device_conf"
VICARE_DEVICE_CONFIG_LIST = "device_config_list"
VICARE_API = "api"
VICARE_NAME = "ViCare"

Expand Down
9 changes: 4 additions & 5 deletions homeassistant/components/vicare/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from homeassistant.const import CONF_CLIENT_ID, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant

from .const import DOMAIN, VICARE_DEVICE_CONFIG
from .const import DOMAIN, VICARE_DEVICE_CONFIG_LIST

TO_REDACT = {CONF_CLIENT_ID, CONF_PASSWORD, CONF_USERNAME}

Expand All @@ -19,10 +19,9 @@ async def async_get_config_entry_diagnostics(
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
# Currently we only support a single device
device = hass.data[DOMAIN][entry.entry_id][VICARE_DEVICE_CONFIG]
data: dict[str, Any] = json.loads(
await hass.async_add_executor_job(device.dump_secure)
)
data = []
for device in hass.data[DOMAIN][entry.entry_id][VICARE_DEVICE_CONFIG_LIST]:
data.append(json.loads(await hass.async_add_executor_job(device.dump_secure)))
return {
"entry": async_redact_data(entry.as_dict(), TO_REDACT),
"data": data,
Expand Down
Loading
Loading