errors could be None in Shelly Wall Display status (#179207)

This commit is contained in:
Maciej Bieniek
2026-08-21 19:55:36 +00:00
committed by Franck Nijhof
parent eeadb563b0
commit dde086e1e3
2 changed files with 23 additions and 2 deletions
+2 -2
View File
@@ -1233,7 +1233,7 @@ RPC_SENSORS: Final = {
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
removal_condition=lambda _, status, key: (
DRIVER_MISSING_ERROR in status[key].get("errors", [])
DRIVER_MISSING_ERROR in (status[key].get("errors") or [])
),
),
"rssi": RpcSensorDescription(
@@ -1264,7 +1264,7 @@ RPC_SENSORS: Final = {
device_class=SensorDeviceClass.HUMIDITY,
state_class=SensorStateClass.MEASUREMENT,
removal_condition=lambda _, status, key: (
DRIVER_MISSING_ERROR in status[key].get("errors", [])
DRIVER_MISSING_ERROR in (status[key].get("errors") or [])
),
),
"battery": RpcSensorDescription(
+21
View File
@@ -2305,3 +2305,24 @@ async def test_rpc_sensor_driver_missing_error(
await hass.async_block_till_done()
assert entity_registry.async_get(entity_id) is None
async def test_rpc_sensor_errors_none(
hass: HomeAssistant,
mock_rpc_device: Mock,
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""RPC sensor with errors set to none."""
status = {
"temperature:0": {
"id": 0,
"tC": 11.1,
"errors": None,
}
}
monkeypatch.setattr(mock_rpc_device, "status", status)
await init_integration(hass, 2)
assert (state := hass.states.get("sensor.test_name_temperature"))
assert state.state == "11.1"