Avoid keyerror on incomplete api data in myuplink (#136333)
* Avoid keyerror * Inject erroneous value in device point fixture * Update diagnostics snapshotpull/136407/head
parent
1f8129f4b8
commit
4cf1b1a707
|
@ -325,10 +325,10 @@ class MyUplinkEnumSensor(MyUplinkDevicePointSensor):
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> str:
|
def native_value(self) -> str | None:
|
||||||
"""Sensor state value for enum sensor."""
|
"""Sensor state value for enum sensor."""
|
||||||
device_point = self.coordinator.data.points[self.device_id][self.point_id]
|
device_point = self.coordinator.data.points[self.device_id][self.point_id]
|
||||||
return self.options_map[str(int(device_point.value))] # type: ignore[no-any-return]
|
return self.options_map.get(str(int(device_point.value)))
|
||||||
|
|
||||||
|
|
||||||
class MyUplinkEnumRawSensor(MyUplinkDevicePointSensor):
|
class MyUplinkEnumRawSensor(MyUplinkDevicePointSensor):
|
||||||
|
|
|
@ -822,7 +822,7 @@
|
||||||
"parameterUnit": "",
|
"parameterUnit": "",
|
||||||
"writable": false,
|
"writable": false,
|
||||||
"timestamp": "2024-02-08T19:13:05+00:00",
|
"timestamp": "2024-02-08T19:13:05+00:00",
|
||||||
"value": 30,
|
"value": 31,
|
||||||
"strVal": "Heating",
|
"strVal": "Heating",
|
||||||
"smartHomeCategories": [],
|
"smartHomeCategories": [],
|
||||||
"minValue": null,
|
"minValue": null,
|
||||||
|
|
|
@ -883,7 +883,7 @@
|
||||||
"parameterUnit": "",
|
"parameterUnit": "",
|
||||||
"writable": false,
|
"writable": false,
|
||||||
"timestamp": "2024-02-08T19:13:05+00:00",
|
"timestamp": "2024-02-08T19:13:05+00:00",
|
||||||
"value": 30,
|
"value": 31,
|
||||||
"strVal": "Heating",
|
"strVal": "Heating",
|
||||||
"smartHomeCategories": [],
|
"smartHomeCategories": [],
|
||||||
"minValue": null,
|
"minValue": null,
|
||||||
|
@ -2045,7 +2045,7 @@
|
||||||
"parameterUnit": "",
|
"parameterUnit": "",
|
||||||
"writable": false,
|
"writable": false,
|
||||||
"timestamp": "2024-02-08T19:13:05+00:00",
|
"timestamp": "2024-02-08T19:13:05+00:00",
|
||||||
"value": 30,
|
"value": 31,
|
||||||
"strVal": "Heating",
|
"strVal": "Heating",
|
||||||
"smartHomeCategories": [],
|
"smartHomeCategories": [],
|
||||||
"minValue": null,
|
"minValue": null,
|
||||||
|
|
|
@ -3396,7 +3396,7 @@
|
||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_reported': <ANY>,
|
'last_reported': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': 'Heating',
|
'state': 'unknown',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_sensor_states[sensor.gotham_city_priority_2-entry]
|
# name: test_sensor_states[sensor.gotham_city_priority_2-entry]
|
||||||
|
@ -3462,7 +3462,7 @@
|
||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_reported': <ANY>,
|
'last_reported': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': 'Heating',
|
'state': 'unknown',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_sensor_states[sensor.gotham_city_priority_raw-entry]
|
# name: test_sensor_states[sensor.gotham_city_priority_raw-entry]
|
||||||
|
@ -3508,7 +3508,7 @@
|
||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_reported': <ANY>,
|
'last_reported': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': '30',
|
'state': '31',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_sensor_states[sensor.gotham_city_priority_raw_2-entry]
|
# name: test_sensor_states[sensor.gotham_city_priority_raw_2-entry]
|
||||||
|
@ -3554,7 +3554,7 @@
|
||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_reported': <ANY>,
|
'last_reported': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': '30',
|
'state': '31',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_sensor_states[sensor.gotham_city_r_start_diff_additional_heat-entry]
|
# name: test_sensor_states[sensor.gotham_city_r_start_diff_additional_heat-entry]
|
||||||
|
|
Loading…
Reference in New Issue