mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix yale_smart_alarm on missing key (#125508)
This commit is contained in:
parent
c0ee12ca41
commit
26ede9a679
@ -154,10 +154,15 @@ class YaleDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||
except YALE_BASE_ERRORS as error:
|
||||
raise UpdateFailed from error
|
||||
|
||||
cycle = data.cycle["data"] if data.cycle else None
|
||||
status = data.status["data"] if data.status else None
|
||||
online = data.online["data"] if data.online else None
|
||||
panel_info = data.panel_info["data"] if data.panel_info else None
|
||||
|
||||
return {
|
||||
"arm_status": arm_status,
|
||||
"cycle": data.cycle,
|
||||
"status": data.status,
|
||||
"online": data.online,
|
||||
"panel_info": data.panel_info,
|
||||
"cycle": cycle,
|
||||
"status": status,
|
||||
"online": online,
|
||||
"panel_info": panel_info,
|
||||
}
|
||||
|
@ -82,10 +82,10 @@ def get_fixture_data() -> dict[str, Any]:
|
||||
def get_update_data(loaded_fixture: dict[str, Any]) -> YaleSmartAlarmData:
|
||||
"""Load update data and return."""
|
||||
|
||||
status = loaded_fixture["STATUS"]
|
||||
cycle = loaded_fixture["CYCLE"]
|
||||
online = loaded_fixture["ONLINE"]
|
||||
panel_info = loaded_fixture["PANEL INFO"]
|
||||
status = {"data": loaded_fixture["STATUS"]}
|
||||
cycle = {"data": loaded_fixture["CYCLE"]}
|
||||
online = {"data": loaded_fixture["ONLINE"]}
|
||||
panel_info = {"data": loaded_fixture["PANEL INFO"]}
|
||||
return YaleSmartAlarmData(
|
||||
status=status,
|
||||
cycle=cycle,
|
||||
@ -98,14 +98,14 @@ def get_update_data(loaded_fixture: dict[str, Any]) -> YaleSmartAlarmData:
|
||||
def get_diag_data(loaded_fixture: dict[str, Any]) -> YaleSmartAlarmData:
|
||||
"""Load all data and return."""
|
||||
|
||||
devices = loaded_fixture["DEVICES"]
|
||||
mode = loaded_fixture["MODE"]
|
||||
status = loaded_fixture["STATUS"]
|
||||
cycle = loaded_fixture["CYCLE"]
|
||||
online = loaded_fixture["ONLINE"]
|
||||
history = loaded_fixture["HISTORY"]
|
||||
panel_info = loaded_fixture["PANEL INFO"]
|
||||
auth_check = loaded_fixture["AUTH CHECK"]
|
||||
devices = {"data": loaded_fixture["DEVICES"]}
|
||||
mode = {"data": loaded_fixture["MODE"]}
|
||||
status = {"data": loaded_fixture["STATUS"]}
|
||||
cycle = {"data": loaded_fixture["CYCLE"]}
|
||||
online = {"data": loaded_fixture["ONLINE"]}
|
||||
history = {"data": loaded_fixture["HISTORY"]}
|
||||
panel_info = {"data": loaded_fixture["PANEL INFO"]}
|
||||
auth_check = {"data": loaded_fixture["AUTH CHECK"]}
|
||||
return YaleSmartAlarmData(
|
||||
devices=devices,
|
||||
mode=mode,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -55,7 +55,7 @@ async def test_lock_service_calls(
|
||||
client = load_config_entry[1]
|
||||
|
||||
data = deepcopy(get_data.cycle)
|
||||
data["data"] = data.pop("device_status")
|
||||
data["data"] = data["data"].pop("device_status")
|
||||
|
||||
client.auth.get_authenticated = Mock(return_value=data)
|
||||
client.auth.post_authenticated = Mock(return_value={"code": "000"})
|
||||
@ -109,7 +109,7 @@ async def test_lock_service_call_fails(
|
||||
client = load_config_entry[1]
|
||||
|
||||
data = deepcopy(get_data.cycle)
|
||||
data["data"] = data.pop("device_status")
|
||||
data["data"] = data["data"].pop("device_status")
|
||||
|
||||
client.auth.get_authenticated = Mock(return_value=data)
|
||||
client.auth.post_authenticated = Mock(side_effect=UnknownError("test_side_effect"))
|
||||
@ -161,7 +161,7 @@ async def test_lock_service_call_fails_with_incorrect_status(
|
||||
client = load_config_entry[1]
|
||||
|
||||
data = deepcopy(get_data.cycle)
|
||||
data["data"] = data.pop("device_status")
|
||||
data["data"] = data["data"].pop("device_status")
|
||||
|
||||
client.auth.get_authenticated = Mock(return_value=data)
|
||||
client.auth.post_authenticated = Mock(return_value={"code": "FFF"})
|
||||
|
Loading…
x
Reference in New Issue
Block a user