Clean up Z-wave error log when raising in service handlers (#125138)
This commit is contained in:
parent
8e3ad2d1f3
commit
7c15075231
4 changed files with 17 additions and 8 deletions
|
@ -335,5 +335,6 @@ class ZWaveBaseEntity(Entity):
|
||||||
value, new_value, options=options, wait_for_result=wait_for_result
|
value, new_value, options=options, wait_for_result=wait_for_result
|
||||||
)
|
)
|
||||||
except BaseZwaveJSServerError as err:
|
except BaseZwaveJSServerError as err:
|
||||||
LOGGER.error("Unable to set value %s: %s", value.value_id, err)
|
raise HomeAssistantError(
|
||||||
raise HomeAssistantError from err
|
f"Unable to set value {value.value_id}: {err}"
|
||||||
|
) from err
|
||||||
|
|
|
@ -750,10 +750,9 @@ class ZWaveMeterSensor(ZWaveNumericSensor):
|
||||||
CommandClass.METER, "reset", *args, wait_for_result=False
|
CommandClass.METER, "reset", *args, wait_for_result=False
|
||||||
)
|
)
|
||||||
except BaseZwaveJSServerError as err:
|
except BaseZwaveJSServerError as err:
|
||||||
LOGGER.error(
|
raise HomeAssistantError(
|
||||||
"Failed to reset meters on node %s endpoint %s: %s", node, endpoint, err
|
f"Failed to reset meters on node {node} endpoint {endpoint}: {err}"
|
||||||
)
|
) from err
|
||||||
raise HomeAssistantError from err
|
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
"Meters on node %s endpoint %s reset with the following options: %s",
|
"Meters on node %s endpoint %s reset with the following options: %s",
|
||||||
node,
|
node,
|
||||||
|
|
|
@ -522,7 +522,7 @@ async def test_reset_meter(
|
||||||
"test", 1, "test"
|
"test", 1, "test"
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(HomeAssistantError) as err:
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
SERVICE_RESET_METER,
|
SERVICE_RESET_METER,
|
||||||
|
@ -530,6 +530,11 @@ async def test_reset_meter(
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
assert str(err.value) == (
|
||||||
|
"Failed to reset meters on node Node(node_id=102) endpoint 0: "
|
||||||
|
"zwave_error: Z-Wave error 1 - test"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_meter_attributes(
|
async def test_meter_attributes(
|
||||||
hass: HomeAssistant, client, aeon_smart_switch_6, integration
|
hass: HomeAssistant, client, aeon_smart_switch_6, integration
|
||||||
|
|
|
@ -286,7 +286,11 @@ async def test_config_parameter_switch(
|
||||||
client.async_send_command.side_effect = FailedZWaveCommand("test", 1, "test")
|
client.async_send_command.side_effect = FailedZWaveCommand("test", 1, "test")
|
||||||
|
|
||||||
# Test turning off error raises proper exception
|
# Test turning off error raises proper exception
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(HomeAssistantError) as err:
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN, SERVICE_TURN_OFF, {"entity_id": switch_entity_id}, blocking=True
|
DOMAIN, SERVICE_TURN_OFF, {"entity_id": switch_entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
assert str(err.value) == (
|
||||||
|
"Unable to set value 32-112-0-20: zwave_error: Z-Wave error 1 - test"
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue