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,
|
||||
|
@ -2,6 +2,7 @@
|
||||
# name: test_diagnostics
|
||||
dict({
|
||||
'auth_check': dict({
|
||||
'data': dict({
|
||||
'agent': False,
|
||||
'dealer_group': 'yale',
|
||||
'dealer_id': '605',
|
||||
@ -16,7 +17,9 @@
|
||||
'user_id': '**REDACTED**',
|
||||
'xml_version': '2',
|
||||
}),
|
||||
}),
|
||||
'cycle': dict({
|
||||
'data': dict({
|
||||
'alarm_event_latest': None,
|
||||
'capture_latest': None,
|
||||
'device_status': list([
|
||||
@ -650,7 +653,9 @@
|
||||
'utc_event_time': None,
|
||||
}),
|
||||
}),
|
||||
'devices': list([
|
||||
}),
|
||||
'devices': dict({
|
||||
'data': list([
|
||||
dict({
|
||||
'address': '**REDACTED**',
|
||||
'area': '1',
|
||||
@ -1249,7 +1254,9 @@
|
||||
'type_no': '40',
|
||||
}),
|
||||
]),
|
||||
'history': list([
|
||||
}),
|
||||
'history': dict({
|
||||
'data': list([
|
||||
dict({
|
||||
'area': 1,
|
||||
'cid': '18180701000',
|
||||
@ -1391,14 +1398,20 @@
|
||||
'zone': 1,
|
||||
}),
|
||||
]),
|
||||
'mode': list([
|
||||
}),
|
||||
'mode': dict({
|
||||
'data': list([
|
||||
dict({
|
||||
'area': '1',
|
||||
'mode': 'disarm',
|
||||
}),
|
||||
]),
|
||||
'online': 'online',
|
||||
}),
|
||||
'online': dict({
|
||||
'data': 'online',
|
||||
}),
|
||||
'panel_info': dict({
|
||||
'data': dict({
|
||||
'SMS_Balance': '50',
|
||||
'contact': '',
|
||||
'dealer_name': 'Poland',
|
||||
@ -1416,7 +1429,9 @@
|
||||
'zb_version': '4.1.2.6.2',
|
||||
'zw_version': '',
|
||||
}),
|
||||
}),
|
||||
'status': dict({
|
||||
'data': dict({
|
||||
'acfail': 'main.normal',
|
||||
'battery': 'main.normal',
|
||||
'gsm_rssi': '0',
|
||||
@ -1426,5 +1441,6 @@
|
||||
'rssi': '1',
|
||||
'tamper': 'main.normal',
|
||||
}),
|
||||
}),
|
||||
})
|
||||
# ---
|
||||
|
@ -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