mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Add more controller-related RainMachine diagnostics (#76409)
This commit is contained in:
parent
7deeea02c2
commit
e89459453b
@ -1,20 +1,38 @@
|
||||
"""Diagnostics support for RainMachine."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from typing import Any
|
||||
|
||||
from regenmaschine.errors import RequestError
|
||||
|
||||
from homeassistant.components.diagnostics import async_redact_data
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_PASSWORD
|
||||
from homeassistant.const import (
|
||||
CONF_ELEVATION,
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
CONF_PASSWORD,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import RainMachineData
|
||||
from .const import DOMAIN
|
||||
|
||||
CONF_STATION_ID = "stationID"
|
||||
CONF_STATION_NAME = "stationName"
|
||||
CONF_STATION_SOURCE = "stationSource"
|
||||
CONF_TIMEZONE = "timezone"
|
||||
|
||||
TO_REDACT = {
|
||||
CONF_ELEVATION,
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
CONF_PASSWORD,
|
||||
CONF_STATION_ID,
|
||||
CONF_STATION_NAME,
|
||||
CONF_STATION_SOURCE,
|
||||
CONF_TIMEZONE,
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +42,14 @@ async def async_get_config_entry_diagnostics(
|
||||
"""Return diagnostics for a config entry."""
|
||||
data: RainMachineData = hass.data[DOMAIN][entry.entry_id]
|
||||
|
||||
controller_tasks = {
|
||||
"versions": data.controller.api.versions(),
|
||||
"current_diagnostics": data.controller.diagnostics.current(),
|
||||
}
|
||||
controller_results = await asyncio.gather(
|
||||
*controller_tasks.values(), return_exceptions=True
|
||||
)
|
||||
|
||||
return {
|
||||
"entry": {
|
||||
"title": entry.title,
|
||||
@ -39,10 +65,9 @@ async def async_get_config_entry_diagnostics(
|
||||
TO_REDACT,
|
||||
),
|
||||
"controller": {
|
||||
"api_version": data.controller.api_version,
|
||||
"hardware_version": data.controller.hardware_version,
|
||||
"name": data.controller.name,
|
||||
"software_version": data.controller.software_version,
|
||||
category: result
|
||||
for category, result in zip(controller_tasks, controller_results)
|
||||
if not isinstance(result, RequestError)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ def config_entry_fixture(hass, config, controller_mac):
|
||||
@pytest.fixture(name="controller")
|
||||
def controller_fixture(
|
||||
controller_mac,
|
||||
data_api_versions,
|
||||
data_diagnostics_current,
|
||||
data_programs,
|
||||
data_provision_settings,
|
||||
data_restrictions_current,
|
||||
@ -55,6 +57,8 @@ def controller_fixture(
|
||||
controller.mac = controller_mac
|
||||
controller.software_version = "4.0.925"
|
||||
|
||||
controller.api.versions.return_value = data_api_versions
|
||||
controller.diagnostics.current.return_value = data_diagnostics_current
|
||||
controller.programs.all.return_value = data_programs
|
||||
controller.provisioning.settings.return_value = data_provision_settings
|
||||
controller.restrictions.current.return_value = data_restrictions_current
|
||||
@ -70,6 +74,18 @@ def controller_mac_fixture():
|
||||
return "aa:bb:cc:dd:ee:ff"
|
||||
|
||||
|
||||
@pytest.fixture(name="data_api_versions", scope="session")
|
||||
def data_api_versions_fixture():
|
||||
"""Define API version data."""
|
||||
return json.loads(load_fixture("api_versions_data.json", "rainmachine"))
|
||||
|
||||
|
||||
@pytest.fixture(name="data_diagnostics_current", scope="session")
|
||||
def data_diagnostics_current_fixture():
|
||||
"""Define current diagnostics data."""
|
||||
return json.loads(load_fixture("diagnostics_current_data.json", "rainmachine"))
|
||||
|
||||
|
||||
@pytest.fixture(name="data_programs", scope="session")
|
||||
def data_programs_fixture():
|
||||
"""Define program data."""
|
||||
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"apiVer": "4.6.1",
|
||||
"hwVer": 3,
|
||||
"swVer": "4.0.1144"
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
{
|
||||
"hasWifi": true,
|
||||
"uptime": "3 days, 18:14:14",
|
||||
"uptimeSeconds": 324854,
|
||||
"memUsage": 16196,
|
||||
"networkStatus": true,
|
||||
"bootCompleted": true,
|
||||
"lastCheckTimestamp": 1659895175,
|
||||
"wizardHasRun": true,
|
||||
"standaloneMode": false,
|
||||
"cpuUsage": 1,
|
||||
"lastCheck": "2022-08-07 11:59:35",
|
||||
"softwareVersion": "4.0.1144",
|
||||
"internetStatus": true,
|
||||
"locationStatus": true,
|
||||
"timeStatus": true,
|
||||
"wifiMode": null,
|
||||
"gatewayAddress": "172.16.20.1",
|
||||
"cloudStatus": 0,
|
||||
"weatherStatus": true
|
||||
}
|
@ -19,6 +19,90 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_rainmach
|
||||
},
|
||||
"data": {
|
||||
"coordinator": {
|
||||
"provision.settings": {
|
||||
"system": {
|
||||
"httpEnabled": True,
|
||||
"rainSensorSnoozeDuration": 0,
|
||||
"uiUnitsMetric": False,
|
||||
"programZonesShowInactive": False,
|
||||
"programSingleSchedule": False,
|
||||
"standaloneMode": False,
|
||||
"masterValveAfter": 0,
|
||||
"touchSleepTimeout": 10,
|
||||
"selfTest": False,
|
||||
"useSoftwareRainSensor": False,
|
||||
"defaultZoneWateringDuration": 300,
|
||||
"maxLEDBrightness": 40,
|
||||
"simulatorHistorySize": 0,
|
||||
"vibration": False,
|
||||
"masterValveBefore": 0,
|
||||
"touchProgramToRun": None,
|
||||
"useRainSensor": False,
|
||||
"wizardHasRun": True,
|
||||
"waterLogHistorySize": 365,
|
||||
"netName": "Home",
|
||||
"softwareRainSensorMinQPF": 5,
|
||||
"touchAdvanced": False,
|
||||
"useBonjourService": True,
|
||||
"hardwareVersion": 3,
|
||||
"touchLongPressTimeout": 3,
|
||||
"showRestrictionsOnLed": False,
|
||||
"parserDataSizeInDays": 6,
|
||||
"programListShowInactive": True,
|
||||
"parserHistorySize": 365,
|
||||
"allowAlexaDiscovery": False,
|
||||
"automaticUpdates": True,
|
||||
"minLEDBrightness": 0,
|
||||
"minWateringDurationThreshold": 0,
|
||||
"localValveCount": 12,
|
||||
"touchAuthAPSeconds": 60,
|
||||
"useCommandLineArguments": False,
|
||||
"databasePath": "/rainmachine-app/DB/Default",
|
||||
"touchCyclePrograms": True,
|
||||
"zoneListShowInactive": True,
|
||||
"rainSensorRainStart": None,
|
||||
"zoneDuration": [
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
],
|
||||
"rainSensorIsNormallyClosed": True,
|
||||
"useCorrectionForPast": True,
|
||||
"useMasterValve": False,
|
||||
"runParsersBeforePrograms": True,
|
||||
"maxWateringCoef": 2,
|
||||
"mixerHistorySize": 365,
|
||||
},
|
||||
"location": {
|
||||
"elevation": REDACTED,
|
||||
"doyDownloaded": True,
|
||||
"zip": None,
|
||||
"windSensitivity": 0.5,
|
||||
"krs": 0.16,
|
||||
"stationID": REDACTED,
|
||||
"stationSource": REDACTED,
|
||||
"et0Average": 6.578,
|
||||
"latitude": REDACTED,
|
||||
"state": "Default",
|
||||
"stationName": REDACTED,
|
||||
"wsDays": 2,
|
||||
"stationDownloaded": True,
|
||||
"address": "Default",
|
||||
"rainSensitivity": 0.8,
|
||||
"timezone": REDACTED,
|
||||
"longitude": REDACTED,
|
||||
"name": "Home",
|
||||
},
|
||||
},
|
||||
"programs": [
|
||||
{
|
||||
"uid": 1,
|
||||
@ -297,90 +381,6 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_rainmach
|
||||
],
|
||||
},
|
||||
],
|
||||
"provision.settings": {
|
||||
"system": {
|
||||
"httpEnabled": True,
|
||||
"rainSensorSnoozeDuration": 0,
|
||||
"uiUnitsMetric": False,
|
||||
"programZonesShowInactive": False,
|
||||
"programSingleSchedule": False,
|
||||
"standaloneMode": False,
|
||||
"masterValveAfter": 0,
|
||||
"touchSleepTimeout": 10,
|
||||
"selfTest": False,
|
||||
"useSoftwareRainSensor": False,
|
||||
"defaultZoneWateringDuration": 300,
|
||||
"maxLEDBrightness": 40,
|
||||
"simulatorHistorySize": 0,
|
||||
"vibration": False,
|
||||
"masterValveBefore": 0,
|
||||
"touchProgramToRun": None,
|
||||
"useRainSensor": False,
|
||||
"wizardHasRun": True,
|
||||
"waterLogHistorySize": 365,
|
||||
"netName": "Home",
|
||||
"softwareRainSensorMinQPF": 5,
|
||||
"touchAdvanced": False,
|
||||
"useBonjourService": True,
|
||||
"hardwareVersion": 3,
|
||||
"touchLongPressTimeout": 3,
|
||||
"showRestrictionsOnLed": False,
|
||||
"parserDataSizeInDays": 6,
|
||||
"programListShowInactive": True,
|
||||
"parserHistorySize": 365,
|
||||
"allowAlexaDiscovery": False,
|
||||
"automaticUpdates": True,
|
||||
"minLEDBrightness": 0,
|
||||
"minWateringDurationThreshold": 0,
|
||||
"localValveCount": 12,
|
||||
"touchAuthAPSeconds": 60,
|
||||
"useCommandLineArguments": False,
|
||||
"databasePath": "/rainmachine-app/DB/Default",
|
||||
"touchCyclePrograms": True,
|
||||
"zoneListShowInactive": True,
|
||||
"rainSensorRainStart": None,
|
||||
"zoneDuration": [
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
300,
|
||||
],
|
||||
"rainSensorIsNormallyClosed": True,
|
||||
"useCorrectionForPast": True,
|
||||
"useMasterValve": False,
|
||||
"runParsersBeforePrograms": True,
|
||||
"maxWateringCoef": 2,
|
||||
"mixerHistorySize": 365,
|
||||
},
|
||||
"location": {
|
||||
"elevation": 1593.45141602,
|
||||
"doyDownloaded": True,
|
||||
"zip": None,
|
||||
"windSensitivity": 0.5,
|
||||
"krs": 0.16,
|
||||
"stationID": 9172,
|
||||
"stationSource": "station",
|
||||
"et0Average": 6.578,
|
||||
"latitude": REDACTED,
|
||||
"state": "Default",
|
||||
"stationName": "MY STATION",
|
||||
"wsDays": 2,
|
||||
"stationDownloaded": True,
|
||||
"address": "Default",
|
||||
"rainSensitivity": 0.8,
|
||||
"timezone": "America/Los Angeles",
|
||||
"longitude": REDACTED,
|
||||
"name": "Home",
|
||||
},
|
||||
},
|
||||
"restrictions.current": {
|
||||
"hourly": False,
|
||||
"freeze": False,
|
||||
@ -583,10 +583,32 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_rainmach
|
||||
],
|
||||
},
|
||||
"controller": {
|
||||
"api_version": "4.5.0",
|
||||
"hardware_version": 3,
|
||||
"name": 12345,
|
||||
"software_version": "4.0.925",
|
||||
"versions": {
|
||||
"apiVer": "4.6.1",
|
||||
"hwVer": 3,
|
||||
"swVer": "4.0.1144",
|
||||
},
|
||||
"current_diagnostics": {
|
||||
"hasWifi": True,
|
||||
"uptime": "3 days, 18:14:14",
|
||||
"uptimeSeconds": 324854,
|
||||
"memUsage": 16196,
|
||||
"networkStatus": True,
|
||||
"bootCompleted": True,
|
||||
"lastCheckTimestamp": 1659895175,
|
||||
"wizardHasRun": True,
|
||||
"standaloneMode": False,
|
||||
"cpuUsage": 1,
|
||||
"lastCheck": "2022-08-07 11:59:35",
|
||||
"softwareVersion": "4.0.1144",
|
||||
"internetStatus": True,
|
||||
"locationStatus": True,
|
||||
"timeStatus": True,
|
||||
"wifiMode": None,
|
||||
"gatewayAddress": "172.16.20.1",
|
||||
"cloudStatus": 0,
|
||||
"weatherStatus": True,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user