forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
1,071 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,93 @@ | ||
"""Diagnostics support for Comelit integration.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Any | ||
|
||
from aiocomelit import ( | ||
ComelitSerialBridgeObject, | ||
ComelitVedoAreaObject, | ||
ComelitVedoZoneObject, | ||
) | ||
from aiocomelit.const import BRIDGE | ||
|
||
from homeassistant.components.diagnostics import async_redact_data | ||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.const import CONF_PIN, CONF_TYPE | ||
from homeassistant.core import HomeAssistant | ||
|
||
from .const import DOMAIN | ||
from .coordinator import ComelitBaseCoordinator | ||
|
||
TO_REDACT = {CONF_PIN} | ||
|
||
|
||
async def async_get_config_entry_diagnostics( | ||
hass: HomeAssistant, entry: ConfigEntry | ||
) -> dict[str, Any]: | ||
"""Return diagnostics for a config entry.""" | ||
|
||
coordinator: ComelitBaseCoordinator = hass.data[DOMAIN][entry.entry_id] | ||
|
||
dev_list: list[dict[str, Any]] = [] | ||
dev_type_list: list[dict[int, Any]] = [] | ||
|
||
for dev_type in coordinator.data: | ||
dev_type_list = [] | ||
for sensor_data in coordinator.data[dev_type].values(): | ||
if isinstance(sensor_data, ComelitSerialBridgeObject): | ||
dev_type_list.append( | ||
{ | ||
sensor_data.index: { | ||
"name": sensor_data.name, | ||
"status": sensor_data.status, | ||
"human_status": sensor_data.human_status, | ||
"protected": sensor_data.protected, | ||
"val": sensor_data.val, | ||
"zone": sensor_data.zone, | ||
"power": sensor_data.power, | ||
"power_unit": sensor_data.power_unit, | ||
} | ||
} | ||
) | ||
if isinstance(sensor_data, ComelitVedoAreaObject): | ||
dev_type_list.append( | ||
{ | ||
sensor_data.index: { | ||
"name": sensor_data.name, | ||
"human_status": sensor_data.human_status.value, | ||
"p1": sensor_data.p1, | ||
"p2": sensor_data.p2, | ||
"ready": sensor_data.ready, | ||
"armed": sensor_data.armed, | ||
"alarm": sensor_data.alarm, | ||
"alarm_memory": sensor_data.alarm_memory, | ||
"sabotage": sensor_data.sabotage, | ||
"anomaly": sensor_data.anomaly, | ||
"in_time": sensor_data.in_time, | ||
"out_time": sensor_data.out_time, | ||
} | ||
} | ||
) | ||
if isinstance(sensor_data, ComelitVedoZoneObject): | ||
dev_type_list.append( | ||
{ | ||
sensor_data.index: { | ||
"name": sensor_data.name, | ||
"human_status": sensor_data.human_status.value, | ||
"status": sensor_data.status, | ||
"status_api": sensor_data.status_api, | ||
} | ||
} | ||
) | ||
dev_list.append({dev_type: dev_type_list}) | ||
|
||
return { | ||
"entry": async_redact_data(entry.as_dict(), TO_REDACT), | ||
"type": entry.data.get(CONF_TYPE, BRIDGE), | ||
"device_info": { | ||
"last_update success": coordinator.last_update_success, | ||
"last_exception": repr(coordinator.last_exception), | ||
"devices": dev_list, | ||
}, | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,47 @@ | ||
"""Diagnostics support for Vodafone Station.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Any | ||
|
||
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 .const import DOMAIN | ||
from .coordinator import VodafoneStationRouter | ||
|
||
TO_REDACT = {CONF_USERNAME, CONF_PASSWORD} | ||
|
||
|
||
async def async_get_config_entry_diagnostics( | ||
hass: HomeAssistant, entry: ConfigEntry | ||
) -> dict[str, Any]: | ||
"""Return diagnostics for a config entry.""" | ||
|
||
coordinator: VodafoneStationRouter = hass.data[DOMAIN][entry.entry_id] | ||
|
||
sensors_data = coordinator.data.sensors | ||
return { | ||
"entry": async_redact_data(entry.as_dict(), TO_REDACT), | ||
"device_info": { | ||
"sys_model_name": sensors_data.get("sys_model_name"), | ||
"sys_firmware_version": sensors_data["sys_firmware_version"], | ||
"sys_hardware_version": sensors_data["sys_hardware_version"], | ||
"sys_cpu_usage": sensors_data["sys_cpu_usage"][:-1], | ||
"sys_memory_usage": sensors_data["sys_memory_usage"][:-1], | ||
"sys_reboot_cause": sensors_data["sys_reboot_cause"], | ||
"last_update success": coordinator.last_update_success, | ||
"last_exception": coordinator.last_exception, | ||
"client_devices": [ | ||
{ | ||
"hostname": device_info.device.name, | ||
"connection_type": device_info.device.connection_type, | ||
"connected": device_info.device.connected, | ||
"type": device_info.device.type, | ||
} | ||
for _, device_info in coordinator.data.devices.items() | ||
], | ||
}, | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.