mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
parent
ccca12cf31
commit
d56ad14673
33
homeassistant/components/honeywell/diagnostics.py
Normal file
33
homeassistant/components/honeywell/diagnostics.py
Normal file
@ -0,0 +1,33 @@
|
||||
"""Diagnostics support for Honeywell."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import HoneywellData
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
|
||||
Honeywell: HoneywellData = hass.data[DOMAIN][config_entry.entry_id]
|
||||
diagnostics_data = {}
|
||||
|
||||
for device, module in Honeywell.devices.items():
|
||||
diagnostics_data.update(
|
||||
{
|
||||
f"Device {device}": {
|
||||
"UI Data": module.raw_ui_data,
|
||||
"Fan Data": module.raw_fan_data,
|
||||
"DR Data": module.raw_dr_data,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return diagnostics_data
|
@ -108,6 +108,8 @@ def device():
|
||||
mock_device.heat_away_temp = HEATAWAY
|
||||
mock_device.cool_away_temp = COOLAWAY
|
||||
|
||||
mock_device.raw_dr_data = {"CoolSetpLimit": None, "HeatSetpLimit": None}
|
||||
|
||||
return mock_device
|
||||
|
||||
|
||||
@ -127,6 +129,27 @@ def device_with_outdoor_sensor():
|
||||
mock_device.temperature_unit = "C"
|
||||
mock_device.outdoor_temperature = OUTDOORTEMP
|
||||
mock_device.outdoor_humidity = OUTDOORHUMIDITY
|
||||
mock_device.raw_ui_data = {
|
||||
"SwitchOffAllowed": True,
|
||||
"SwitchAutoAllowed": True,
|
||||
"SwitchCoolAllowed": True,
|
||||
"SwitchHeatAllowed": True,
|
||||
"SwitchEmergencyHeatAllowed": True,
|
||||
"HeatUpperSetptLimit": HEATUPPERSETPOINTLIMIT,
|
||||
"HeatLowerSetptLimit": HEATLOWERSETPOINTLIMIT,
|
||||
"CoolUpperSetptLimit": COOLUPPERSETPOINTLIMIT,
|
||||
"CoolLowerSetptLimit": COOLLOWERSETPOINTLIMIT,
|
||||
"HeatNextPeriod": NEXTHEATPERIOD,
|
||||
"CoolNextPeriod": NEXTCOOLPERIOD,
|
||||
}
|
||||
mock_device.raw_fan_data = {
|
||||
"fanModeOnAllowed": True,
|
||||
"fanModeAutoAllowed": True,
|
||||
"fanModeCirculateAllowed": True,
|
||||
}
|
||||
|
||||
mock_device.raw_dr_data = {"CoolSetpLimit": None, "HeatSetpLimit": None}
|
||||
|
||||
return mock_device
|
||||
|
||||
|
||||
@ -145,6 +168,26 @@ def another_device():
|
||||
mock_device.mac_address = "macaddress1"
|
||||
mock_device.outdoor_temperature = None
|
||||
mock_device.outdoor_humidity = None
|
||||
mock_device.raw_ui_data = {
|
||||
"SwitchOffAllowed": True,
|
||||
"SwitchAutoAllowed": True,
|
||||
"SwitchCoolAllowed": True,
|
||||
"SwitchHeatAllowed": True,
|
||||
"SwitchEmergencyHeatAllowed": True,
|
||||
"HeatUpperSetptLimit": HEATUPPERSETPOINTLIMIT,
|
||||
"HeatLowerSetptLimit": HEATLOWERSETPOINTLIMIT,
|
||||
"CoolUpperSetptLimit": COOLUPPERSETPOINTLIMIT,
|
||||
"CoolLowerSetptLimit": COOLLOWERSETPOINTLIMIT,
|
||||
"HeatNextPeriod": NEXTHEATPERIOD,
|
||||
"CoolNextPeriod": NEXTCOOLPERIOD,
|
||||
}
|
||||
mock_device.raw_fan_data = {
|
||||
"fanModeOnAllowed": True,
|
||||
"fanModeAutoAllowed": True,
|
||||
"fanModeCirculateAllowed": True,
|
||||
}
|
||||
|
||||
mock_device.raw_dr_data = {"CoolSetpLimit": None, "HeatSetpLimit": None}
|
||||
return mock_device
|
||||
|
||||
|
||||
|
53
tests/components/honeywell/snapshots/test_diagnostics.ambr
Normal file
53
tests/components/honeywell/snapshots/test_diagnostics.ambr
Normal file
@ -0,0 +1,53 @@
|
||||
# serializer version: 1
|
||||
# name: test_entry_diagnostics
|
||||
dict({
|
||||
'Device 1234567': dict({
|
||||
'DR Data': dict({
|
||||
'CoolSetpLimit': None,
|
||||
'HeatSetpLimit': None,
|
||||
}),
|
||||
'Fan Data': dict({
|
||||
'fanModeAutoAllowed': True,
|
||||
'fanModeCirculateAllowed': True,
|
||||
'fanModeOnAllowed': True,
|
||||
}),
|
||||
'UI Data': dict({
|
||||
'CoolLowerSetptLimit': 10,
|
||||
'CoolNextPeriod': 10,
|
||||
'CoolUpperSetptLimit': 20,
|
||||
'HeatLowerSetptLimit': 20,
|
||||
'HeatNextPeriod': 10,
|
||||
'HeatUpperSetptLimit': 35,
|
||||
'SwitchAutoAllowed': True,
|
||||
'SwitchCoolAllowed': True,
|
||||
'SwitchEmergencyHeatAllowed': True,
|
||||
'SwitchHeatAllowed': True,
|
||||
'SwitchOffAllowed': True,
|
||||
}),
|
||||
}),
|
||||
'Device 7654321': dict({
|
||||
'DR Data': dict({
|
||||
'CoolSetpLimit': None,
|
||||
'HeatSetpLimit': None,
|
||||
}),
|
||||
'Fan Data': dict({
|
||||
'fanModeAutoAllowed': True,
|
||||
'fanModeCirculateAllowed': True,
|
||||
'fanModeOnAllowed': True,
|
||||
}),
|
||||
'UI Data': dict({
|
||||
'CoolLowerSetptLimit': 10,
|
||||
'CoolNextPeriod': 10,
|
||||
'CoolUpperSetptLimit': 20,
|
||||
'HeatLowerSetptLimit': 20,
|
||||
'HeatNextPeriod': 10,
|
||||
'HeatUpperSetptLimit': 35,
|
||||
'SwitchAutoAllowed': True,
|
||||
'SwitchCoolAllowed': True,
|
||||
'SwitchEmergencyHeatAllowed': True,
|
||||
'SwitchHeatAllowed': True,
|
||||
'SwitchOffAllowed': True,
|
||||
}),
|
||||
}),
|
||||
})
|
||||
# ---
|
35
tests/components/honeywell/test_diagnostics.py
Normal file
35
tests/components/honeywell/test_diagnostics.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""Test Honeywell diagnostics."""
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
YAML_CONFIG = {"username": "test-user", "password": "test-password"}
|
||||
|
||||
|
||||
async def test_entry_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
snapshot: SnapshotAssertion,
|
||||
config_entry: MockConfigEntry,
|
||||
location: MagicMock,
|
||||
another_device: MagicMock,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics for Honeywell."""
|
||||
|
||||
location.devices_by_id[another_device.deviceid] = another_device
|
||||
config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert config_entry.state is ConfigEntryState.LOADED
|
||||
assert hass.states.async_entity_ids_count() == 6
|
||||
|
||||
result = await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
|
||||
|
||||
assert result == snapshot
|
Loading…
x
Reference in New Issue
Block a user