mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
errors could be None in Shelly Wall Display status (#179207)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user