Bump zwave-js-server-python to 0.52.0 (#100833)

* Bump zwave-js-server-python to 0.52.0

* remove old function

* fix tests
This commit is contained in:
Raman Gupta 2023-09-26 17:05:54 -04:00 committed by GitHub
parent 59a26010ba
commit 176f5dc2d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 169 additions and 100 deletions

View File

@ -411,15 +411,15 @@ def async_register_api(hass: HomeAssistant) -> None:
websocket_api.async_register_command(hass, websocket_remove_node) websocket_api.async_register_command(hass, websocket_remove_node)
websocket_api.async_register_command(hass, websocket_remove_failed_node) websocket_api.async_register_command(hass, websocket_remove_failed_node)
websocket_api.async_register_command(hass, websocket_replace_failed_node) websocket_api.async_register_command(hass, websocket_replace_failed_node)
websocket_api.async_register_command(hass, websocket_begin_healing_network) websocket_api.async_register_command(hass, websocket_begin_rebuilding_routes)
websocket_api.async_register_command( websocket_api.async_register_command(
hass, websocket_subscribe_heal_network_progress hass, websocket_subscribe_rebuild_routes_progress
) )
websocket_api.async_register_command(hass, websocket_stop_healing_network) websocket_api.async_register_command(hass, websocket_stop_rebuilding_routes)
websocket_api.async_register_command(hass, websocket_refresh_node_info) websocket_api.async_register_command(hass, websocket_refresh_node_info)
websocket_api.async_register_command(hass, websocket_refresh_node_values) websocket_api.async_register_command(hass, websocket_refresh_node_values)
websocket_api.async_register_command(hass, websocket_refresh_node_cc_values) websocket_api.async_register_command(hass, websocket_refresh_node_cc_values)
websocket_api.async_register_command(hass, websocket_heal_node) websocket_api.async_register_command(hass, websocket_rebuild_node_routes)
websocket_api.async_register_command(hass, websocket_set_config_parameter) websocket_api.async_register_command(hass, websocket_set_config_parameter)
websocket_api.async_register_command(hass, websocket_get_config_parameters) websocket_api.async_register_command(hass, websocket_get_config_parameters)
websocket_api.async_register_command(hass, websocket_subscribe_log_updates) websocket_api.async_register_command(hass, websocket_subscribe_log_updates)
@ -511,7 +511,7 @@ async def websocket_network_status(
"supported_function_types": controller.supported_function_types, "supported_function_types": controller.supported_function_types,
"suc_node_id": controller.suc_node_id, "suc_node_id": controller.suc_node_id,
"supports_timers": controller.supports_timers, "supports_timers": controller.supports_timers,
"is_heal_network_active": controller.is_heal_network_active, "is_rebuilding_routes": controller.is_rebuilding_routes,
"inclusion_state": controller.inclusion_state, "inclusion_state": controller.inclusion_state,
"rf_region": controller.rf_region, "rf_region": controller.rf_region,
"status": controller.status, "status": controller.status,
@ -1379,14 +1379,14 @@ async def websocket_remove_failed_node(
@websocket_api.require_admin @websocket_api.require_admin
@websocket_api.websocket_command( @websocket_api.websocket_command(
{ {
vol.Required(TYPE): "zwave_js/begin_healing_network", vol.Required(TYPE): "zwave_js/begin_rebuilding_routes",
vol.Required(ENTRY_ID): str, vol.Required(ENTRY_ID): str,
} }
) )
@websocket_api.async_response @websocket_api.async_response
@async_handle_failed_command @async_handle_failed_command
@async_get_entry @async_get_entry
async def websocket_begin_healing_network( async def websocket_begin_rebuilding_routes(
hass: HomeAssistant, hass: HomeAssistant,
connection: ActiveConnection, connection: ActiveConnection,
msg: dict[str, Any], msg: dict[str, Any],
@ -1394,10 +1394,10 @@ async def websocket_begin_healing_network(
client: Client, client: Client,
driver: Driver, driver: Driver,
) -> None: ) -> None:
"""Begin healing the Z-Wave network.""" """Begin rebuilding Z-Wave routes."""
controller = driver.controller controller = driver.controller
result = await controller.async_begin_healing_network() result = await controller.async_begin_rebuilding_routes()
connection.send_result( connection.send_result(
msg[ID], msg[ID],
result, result,
@ -1407,13 +1407,13 @@ async def websocket_begin_healing_network(
@websocket_api.require_admin @websocket_api.require_admin
@websocket_api.websocket_command( @websocket_api.websocket_command(
{ {
vol.Required(TYPE): "zwave_js/subscribe_heal_network_progress", vol.Required(TYPE): "zwave_js/subscribe_rebuild_routes_progress",
vol.Required(ENTRY_ID): str, vol.Required(ENTRY_ID): str,
} }
) )
@websocket_api.async_response @websocket_api.async_response
@async_get_entry @async_get_entry
async def websocket_subscribe_heal_network_progress( async def websocket_subscribe_rebuild_routes_progress(
hass: HomeAssistant, hass: HomeAssistant,
connection: ActiveConnection, connection: ActiveConnection,
msg: dict[str, Any], msg: dict[str, Any],
@ -1421,7 +1421,7 @@ async def websocket_subscribe_heal_network_progress(
client: Client, client: Client,
driver: Driver, driver: Driver,
) -> None: ) -> None:
"""Subscribe to heal Z-Wave network status updates.""" """Subscribe to rebuild Z-Wave routes status updates."""
controller = driver.controller controller = driver.controller
@callback @callback
@ -1434,30 +1434,39 @@ async def websocket_subscribe_heal_network_progress(
def forward_event(key: str, event: dict) -> None: def forward_event(key: str, event: dict) -> None:
connection.send_message( connection.send_message(
websocket_api.event_message( websocket_api.event_message(
msg[ID], {"event": event["event"], "heal_node_status": event[key]} msg[ID], {"event": event["event"], "rebuild_routes_status": event[key]}
) )
) )
connection.subscriptions[msg["id"]] = async_cleanup connection.subscriptions[msg["id"]] = async_cleanup
msg[DATA_UNSUBSCRIBE] = unsubs = [ msg[DATA_UNSUBSCRIBE] = unsubs = [
controller.on("heal network progress", partial(forward_event, "progress")), controller.on("rebuild routes progress", partial(forward_event, "progress")),
controller.on("heal network done", partial(forward_event, "result")), controller.on("rebuild routes done", partial(forward_event, "result")),
] ]
connection.send_result(msg[ID], controller.heal_network_progress) if controller.rebuild_routes_progress:
connection.send_result(
msg[ID],
{
node.node_id: status
for node, status in controller.rebuild_routes_progress.items()
},
)
else:
connection.send_result(msg[ID], None)
@websocket_api.require_admin @websocket_api.require_admin
@websocket_api.websocket_command( @websocket_api.websocket_command(
{ {
vol.Required(TYPE): "zwave_js/stop_healing_network", vol.Required(TYPE): "zwave_js/stop_rebuilding_routes",
vol.Required(ENTRY_ID): str, vol.Required(ENTRY_ID): str,
} }
) )
@websocket_api.async_response @websocket_api.async_response
@async_handle_failed_command @async_handle_failed_command
@async_get_entry @async_get_entry
async def websocket_stop_healing_network( async def websocket_stop_rebuilding_routes(
hass: HomeAssistant, hass: HomeAssistant,
connection: ActiveConnection, connection: ActiveConnection,
msg: dict[str, Any], msg: dict[str, Any],
@ -1465,9 +1474,9 @@ async def websocket_stop_healing_network(
client: Client, client: Client,
driver: Driver, driver: Driver,
) -> None: ) -> None:
"""Stop healing the Z-Wave network.""" """Stop rebuilding Z-Wave routes."""
controller = driver.controller controller = driver.controller
result = await controller.async_stop_healing_network() result = await controller.async_stop_rebuilding_routes()
connection.send_result( connection.send_result(
msg[ID], msg[ID],
result, result,
@ -1477,14 +1486,14 @@ async def websocket_stop_healing_network(
@websocket_api.require_admin @websocket_api.require_admin
@websocket_api.websocket_command( @websocket_api.websocket_command(
{ {
vol.Required(TYPE): "zwave_js/heal_node", vol.Required(TYPE): "zwave_js/rebuild_node_routes",
vol.Required(DEVICE_ID): str, vol.Required(DEVICE_ID): str,
} }
) )
@websocket_api.async_response @websocket_api.async_response
@async_handle_failed_command @async_handle_failed_command
@async_get_node @async_get_node
async def websocket_heal_node( async def websocket_rebuild_node_routes(
hass: HomeAssistant, hass: HomeAssistant,
connection: ActiveConnection, connection: ActiveConnection,
msg: dict[str, Any], msg: dict[str, Any],
@ -1495,7 +1504,7 @@ async def websocket_heal_node(
assert driver is not None # The node comes from the driver instance. assert driver is not None # The node comes from the driver instance.
controller = driver.controller controller = driver.controller
result = await controller.async_heal_node(node) result = await controller.async_rebuild_node_routes(node)
connection.send_result( connection.send_result(
msg[ID], msg[ID],
result, result,

View File

@ -125,7 +125,6 @@ def get_value_of_zwave_value(value: ZwaveValue | None) -> Any | None:
async def async_enable_statistics(driver: Driver) -> None: async def async_enable_statistics(driver: Driver) -> None:
"""Enable statistics on the driver.""" """Enable statistics on the driver."""
await driver.async_enable_statistics("Home Assistant", HA_VERSION) await driver.async_enable_statistics("Home Assistant", HA_VERSION)
await driver.async_enable_error_reporting()
@callback @callback

View File

@ -9,7 +9,7 @@
"iot_class": "local_push", "iot_class": "local_push",
"loggers": ["zwave_js_server"], "loggers": ["zwave_js_server"],
"quality_scale": "platinum", "quality_scale": "platinum",
"requirements": ["pyserial==3.5", "zwave-js-server-python==0.51.3"], "requirements": ["pyserial==3.5", "zwave-js-server-python==0.52.0"],
"usb": [ "usb": [
{ {
"vid": "0658", "vid": "0658",

View File

@ -62,7 +62,12 @@ class ZWaveNodeFirmwareUpdateExtraStoredData(ExtraStoredData):
@classmethod @classmethod
def from_dict(cls, data: dict[str, Any]) -> ZWaveNodeFirmwareUpdateExtraStoredData: def from_dict(cls, data: dict[str, Any]) -> ZWaveNodeFirmwareUpdateExtraStoredData:
"""Initialize the extra data from a dict.""" """Initialize the extra data from a dict."""
if not (firmware_dict := data[ATTR_LATEST_VERSION_FIRMWARE]): # If there was no firmware info stored, or if it's stale info, we don't restore
# anything.
if (
not (firmware_dict := data[ATTR_LATEST_VERSION_FIRMWARE])
or "normalizedVersion" not in firmware_dict
):
return cls(None) return cls(None)
return cls(NodeFirmwareUpdateInfo.from_dict(firmware_dict)) return cls(NodeFirmwareUpdateInfo.from_dict(firmware_dict))
@ -267,9 +272,7 @@ class ZWaveNodeFirmwareUpdate(UpdateEntity):
) )
try: try:
await self.driver.controller.async_firmware_update_ota( await self.driver.controller.async_firmware_update_ota(self.node, firmware)
self.node, firmware.files
)
except BaseZwaveJSServerError as err: except BaseZwaveJSServerError as err:
self._unsub_firmware_events_and_reset_progress() self._unsub_firmware_events_and_reset_progress()
raise HomeAssistantError(err) from err raise HomeAssistantError(err) from err

View File

@ -2811,7 +2811,7 @@ zigpy==0.57.1
zm-py==0.5.2 zm-py==0.5.2
# homeassistant.components.zwave_js # homeassistant.components.zwave_js
zwave-js-server-python==0.51.3 zwave-js-server-python==0.52.0
# homeassistant.components.zwave_me # homeassistant.components.zwave_me
zwave-me-ws==0.4.3 zwave-me-ws==0.4.3

View File

@ -2096,7 +2096,7 @@ zigpy-znp==0.11.4
zigpy==0.57.1 zigpy==0.57.1
# homeassistant.components.zwave_js # homeassistant.components.zwave_js
zwave-js-server-python==0.51.3 zwave-js-server-python==0.52.0
# homeassistant.components.zwave_me # homeassistant.components.zwave_me
zwave-me-ws==0.4.3 zwave-me-ws==0.4.3

View File

@ -906,7 +906,7 @@ async def test_add_node(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -1179,7 +1179,7 @@ async def test_provision_smart_start_node(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -1283,7 +1283,7 @@ async def test_unprovision_smart_start_node(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -1355,7 +1355,7 @@ async def test_get_provisioning_entries(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -1450,7 +1450,7 @@ async def test_parse_qr_code_string(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -1517,7 +1517,7 @@ async def test_try_parse_dsk_from_qr_code_string(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -1599,7 +1599,7 @@ async def test_cancel_inclusion_exclusion(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test FailedZWaveCommand is caught # Test FailedZWaveCommand is caught
with patch( with patch(
@ -1617,7 +1617,7 @@ async def test_cancel_inclusion_exclusion(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -1736,7 +1736,7 @@ async def test_remove_node(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -2081,7 +2081,7 @@ async def test_replace_failed_node(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -2132,7 +2132,7 @@ async def test_remove_failed_node(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
await ws_client.send_json( await ws_client.send_json(
{ {
@ -2187,13 +2187,13 @@ async def test_remove_failed_node(
assert msg["error"]["code"] == ERR_NOT_LOADED assert msg["error"]["code"] == ERR_NOT_LOADED
async def test_begin_healing_network( async def test_begin_rebuilding_routes(
hass: HomeAssistant, hass: HomeAssistant,
integration, integration,
client, client,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
) -> None: ) -> None:
"""Test the begin_healing_network websocket command.""" """Test the begin_rebuilding_routes websocket command."""
entry = integration entry = integration
ws_client = await hass_ws_client(hass) ws_client = await hass_ws_client(hass)
@ -2202,7 +2202,7 @@ async def test_begin_healing_network(
await ws_client.send_json( await ws_client.send_json(
{ {
ID: 3, ID: 3,
TYPE: "zwave_js/begin_healing_network", TYPE: "zwave_js/begin_rebuilding_routes",
ENTRY_ID: entry.entry_id, ENTRY_ID: entry.entry_id,
} }
) )
@ -2213,13 +2213,13 @@ async def test_begin_healing_network(
# Test FailedZWaveCommand is caught # Test FailedZWaveCommand is caught
with patch( with patch(
f"{CONTROLLER_PATCH_PREFIX}.async_begin_healing_network", f"{CONTROLLER_PATCH_PREFIX}.async_begin_rebuilding_routes",
side_effect=FailedZWaveCommand("failed_command", 1, "error message"), side_effect=FailedZWaveCommand("failed_command", 1, "error message"),
): ):
await ws_client.send_json( await ws_client.send_json(
{ {
ID: 4, ID: 4,
TYPE: "zwave_js/begin_healing_network", TYPE: "zwave_js/begin_rebuilding_routes",
ENTRY_ID: entry.entry_id, ENTRY_ID: entry.entry_id,
} }
) )
@ -2227,7 +2227,7 @@ async def test_begin_healing_network(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -2236,7 +2236,7 @@ async def test_begin_healing_network(
await ws_client.send_json( await ws_client.send_json(
{ {
ID: 5, ID: 5,
TYPE: "zwave_js/begin_healing_network", TYPE: "zwave_js/begin_rebuilding_routes",
ENTRY_ID: entry.entry_id, ENTRY_ID: entry.entry_id,
} }
) )
@ -2246,17 +2246,21 @@ async def test_begin_healing_network(
assert msg["error"]["code"] == ERR_NOT_LOADED assert msg["error"]["code"] == ERR_NOT_LOADED
async def test_subscribe_heal_network_progress( async def test_subscribe_rebuild_routes_progress(
hass: HomeAssistant, integration, client, hass_ws_client: WebSocketGenerator hass: HomeAssistant,
integration,
client,
nortek_thermostat,
hass_ws_client: WebSocketGenerator,
) -> None: ) -> None:
"""Test the subscribe_heal_network_progress command.""" """Test the subscribe_rebuild_routes_progress command."""
entry = integration entry = integration
ws_client = await hass_ws_client(hass) ws_client = await hass_ws_client(hass)
await ws_client.send_json( await ws_client.send_json(
{ {
ID: 3, ID: 3,
TYPE: "zwave_js/subscribe_heal_network_progress", TYPE: "zwave_js/subscribe_rebuild_routes_progress",
ENTRY_ID: entry.entry_id, ENTRY_ID: entry.entry_id,
} }
) )
@ -2265,19 +2269,19 @@ async def test_subscribe_heal_network_progress(
assert msg["success"] assert msg["success"]
assert msg["result"] is None assert msg["result"] is None
# Fire heal network progress # Fire rebuild routes progress
event = Event( event = Event(
"heal network progress", "rebuild routes progress",
{ {
"source": "controller", "source": "controller",
"event": "heal network progress", "event": "rebuild routes progress",
"progress": {67: "pending"}, "progress": {67: "pending"},
}, },
) )
client.driver.controller.receive_event(event) client.driver.controller.receive_event(event)
msg = await ws_client.receive_json() msg = await ws_client.receive_json()
assert msg["event"]["event"] == "heal network progress" assert msg["event"]["event"] == "rebuild routes progress"
assert msg["event"]["heal_node_status"] == {"67": "pending"} assert msg["event"]["rebuild_routes_status"] == {"67": "pending"}
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -2286,7 +2290,7 @@ async def test_subscribe_heal_network_progress(
await ws_client.send_json( await ws_client.send_json(
{ {
ID: 4, ID: 4,
TYPE: "zwave_js/subscribe_heal_network_progress", TYPE: "zwave_js/subscribe_rebuild_routes_progress",
ENTRY_ID: entry.entry_id, ENTRY_ID: entry.entry_id,
} }
) )
@ -2296,21 +2300,25 @@ async def test_subscribe_heal_network_progress(
assert msg["error"]["code"] == ERR_NOT_LOADED assert msg["error"]["code"] == ERR_NOT_LOADED
async def test_subscribe_heal_network_progress_initial_value( async def test_subscribe_rebuild_routes_progress_initial_value(
hass: HomeAssistant, integration, client, hass_ws_client: WebSocketGenerator hass: HomeAssistant,
integration,
client,
nortek_thermostat,
hass_ws_client: WebSocketGenerator,
) -> None: ) -> None:
"""Test subscribe_heal_network_progress command when heal network in progress.""" """Test subscribe_rebuild_routes_progress command when rebuild routes in progress."""
entry = integration entry = integration
ws_client = await hass_ws_client(hass) ws_client = await hass_ws_client(hass)
assert not client.driver.controller.heal_network_progress assert not client.driver.controller.rebuild_routes_progress
# Fire heal network progress before sending heal network progress command # Fire rebuild routes progress before sending rebuild routes progress command
event = Event( event = Event(
"heal network progress", "rebuild routes progress",
{ {
"source": "controller", "source": "controller",
"event": "heal network progress", "event": "rebuild routes progress",
"progress": {67: "pending"}, "progress": {67: "pending"},
}, },
) )
@ -2319,7 +2327,7 @@ async def test_subscribe_heal_network_progress_initial_value(
await ws_client.send_json( await ws_client.send_json(
{ {
ID: 3, ID: 3,
TYPE: "zwave_js/subscribe_heal_network_progress", TYPE: "zwave_js/subscribe_rebuild_routes_progress",
ENTRY_ID: entry.entry_id, ENTRY_ID: entry.entry_id,
} }
) )
@ -2329,13 +2337,13 @@ async def test_subscribe_heal_network_progress_initial_value(
assert msg["result"] == {"67": "pending"} assert msg["result"] == {"67": "pending"}
async def test_stop_healing_network( async def test_stop_rebuilding_routes(
hass: HomeAssistant, hass: HomeAssistant,
integration, integration,
client, client,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
) -> None: ) -> None:
"""Test the stop_healing_network websocket command.""" """Test the stop_rebuilding_routes websocket command."""
entry = integration entry = integration
ws_client = await hass_ws_client(hass) ws_client = await hass_ws_client(hass)
@ -2344,7 +2352,7 @@ async def test_stop_healing_network(
await ws_client.send_json( await ws_client.send_json(
{ {
ID: 3, ID: 3,
TYPE: "zwave_js/stop_healing_network", TYPE: "zwave_js/stop_rebuilding_routes",
ENTRY_ID: entry.entry_id, ENTRY_ID: entry.entry_id,
} }
) )
@ -2355,13 +2363,13 @@ async def test_stop_healing_network(
# Test FailedZWaveCommand is caught # Test FailedZWaveCommand is caught
with patch( with patch(
f"{CONTROLLER_PATCH_PREFIX}.async_stop_healing_network", f"{CONTROLLER_PATCH_PREFIX}.async_stop_rebuilding_routes",
side_effect=FailedZWaveCommand("failed_command", 1, "error message"), side_effect=FailedZWaveCommand("failed_command", 1, "error message"),
): ):
await ws_client.send_json( await ws_client.send_json(
{ {
ID: 4, ID: 4,
TYPE: "zwave_js/stop_healing_network", TYPE: "zwave_js/stop_rebuilding_routes",
ENTRY_ID: entry.entry_id, ENTRY_ID: entry.entry_id,
} }
) )
@ -2369,7 +2377,7 @@ async def test_stop_healing_network(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -2378,7 +2386,7 @@ async def test_stop_healing_network(
await ws_client.send_json( await ws_client.send_json(
{ {
ID: 5, ID: 5,
TYPE: "zwave_js/stop_healing_network", TYPE: "zwave_js/stop_rebuilding_routes",
ENTRY_ID: entry.entry_id, ENTRY_ID: entry.entry_id,
} }
) )
@ -2388,14 +2396,14 @@ async def test_stop_healing_network(
assert msg["error"]["code"] == ERR_NOT_LOADED assert msg["error"]["code"] == ERR_NOT_LOADED
async def test_heal_node( async def test_rebuild_node_routes(
hass: HomeAssistant, hass: HomeAssistant,
multisensor_6, multisensor_6,
integration, integration,
client, client,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
) -> None: ) -> None:
"""Test the heal_node websocket command.""" """Test the rebuild_node_routes websocket command."""
entry = integration entry = integration
ws_client = await hass_ws_client(hass) ws_client = await hass_ws_client(hass)
device = get_device(hass, multisensor_6) device = get_device(hass, multisensor_6)
@ -2405,7 +2413,7 @@ async def test_heal_node(
await ws_client.send_json( await ws_client.send_json(
{ {
ID: 3, ID: 3,
TYPE: "zwave_js/heal_node", TYPE: "zwave_js/rebuild_node_routes",
DEVICE_ID: device.id, DEVICE_ID: device.id,
} }
) )
@ -2416,13 +2424,13 @@ async def test_heal_node(
# Test FailedZWaveCommand is caught # Test FailedZWaveCommand is caught
with patch( with patch(
f"{CONTROLLER_PATCH_PREFIX}.async_heal_node", f"{CONTROLLER_PATCH_PREFIX}.async_rebuild_node_routes",
side_effect=FailedZWaveCommand("failed_command", 1, "error message"), side_effect=FailedZWaveCommand("failed_command", 1, "error message"),
): ):
await ws_client.send_json( await ws_client.send_json(
{ {
ID: 4, ID: 4,
TYPE: "zwave_js/heal_node", TYPE: "zwave_js/rebuild_node_routes",
DEVICE_ID: device.id, DEVICE_ID: device.id,
} }
) )
@ -2430,7 +2438,7 @@ async def test_heal_node(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -2439,7 +2447,7 @@ async def test_heal_node(
await ws_client.send_json( await ws_client.send_json(
{ {
ID: 5, ID: 5,
TYPE: "zwave_js/heal_node", TYPE: "zwave_js/rebuild_node_routes",
DEVICE_ID: device.id, DEVICE_ID: device.id,
} }
) )
@ -2558,7 +2566,7 @@ async def test_refresh_node_info(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -2635,7 +2643,7 @@ async def test_refresh_node_values(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -2729,7 +2737,7 @@ async def test_refresh_node_cc_values(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -2954,7 +2962,7 @@ async def test_set_config_parameter(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -3312,7 +3320,7 @@ async def test_subscribe_log_updates(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -3465,7 +3473,7 @@ async def test_update_log_config(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -3569,13 +3577,10 @@ async def test_data_collection(
result = msg["result"] result = msg["result"]
assert result is None assert result is None
assert len(client.async_send_command.call_args_list) == 2 assert len(client.async_send_command.call_args_list) == 1
args = client.async_send_command.call_args_list[0][0][0] args = client.async_send_command.call_args_list[0][0][0]
assert args["command"] == "driver.enable_statistics" assert args["command"] == "driver.enable_statistics"
assert args["applicationName"] == "Home Assistant" assert args["applicationName"] == "Home Assistant"
args = client.async_send_command.call_args_list[1][0][0]
assert args["command"] == "driver.enable_error_reporting"
assert entry.data[CONF_DATA_COLLECTION_OPTED_IN]
client.async_send_command.reset_mock() client.async_send_command.reset_mock()
@ -3616,7 +3621,7 @@ async def test_data_collection(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test FailedZWaveCommand is caught # Test FailedZWaveCommand is caught
with patch( with patch(
@ -3635,7 +3640,7 @@ async def test_data_collection(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -3710,7 +3715,7 @@ async def test_abort_firmware_update(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -3787,7 +3792,7 @@ async def test_is_node_firmware_update_in_progress(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -4153,7 +4158,7 @@ async def test_get_node_firmware_update_capabilities(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -4224,7 +4229,7 @@ async def test_is_any_ota_firmware_update_in_progress(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -4300,7 +4305,7 @@ async def test_check_for_config_updates(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -4367,7 +4372,7 @@ async def test_install_config_update(
assert not msg["success"] assert not msg["success"]
assert msg["error"]["code"] == "zwave_error" assert msg["error"]["code"] == "zwave_error"
assert msg["error"]["message"] == "Z-Wave error 1: error message" assert msg["error"]["message"] == "zwave_error: Z-Wave error 1 - error message"
# Test sending command with not loaded entry fails # Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)

View File

@ -144,6 +144,7 @@ async def test_if_notification_notification_fires(
"source": "node", "source": "node",
"event": "notification", "event": "notification",
"nodeId": node.node_id, "nodeId": node.node_id,
"endpointIndex": 0,
"ccId": 113, "ccId": 113,
"args": { "args": {
"type": 6, "type": 6,
@ -273,6 +274,7 @@ async def test_if_entry_control_notification_fires(
"source": "node", "source": "node",
"event": "notification", "event": "notification",
"nodeId": node.node_id, "nodeId": node.node_id,
"endpointIndex": 0,
"ccId": 111, "ccId": 111,
"args": { "args": {
"eventType": 5, "eventType": 5,

View File

@ -156,6 +156,7 @@ async def test_notifications(
"source": "node", "source": "node",
"event": "notification", "event": "notification",
"nodeId": 32, "nodeId": 32,
"endpointIndex": 0,
"ccId": 113, "ccId": 113,
"args": { "args": {
"type": 6, "type": 6,
@ -187,6 +188,7 @@ async def test_notifications(
"source": "node", "source": "node",
"event": "notification", "event": "notification",
"nodeId": 32, "nodeId": 32,
"endpointIndex": 0,
"ccId": 111, "ccId": 111,
"args": { "args": {
"eventType": 5, "eventType": 5,
@ -219,6 +221,7 @@ async def test_notifications(
"source": "node", "source": "node",
"event": "notification", "event": "notification",
"nodeId": 32, "nodeId": 32,
"endpointIndex": 0,
"ccId": 38, "ccId": 38,
"args": {"eventType": 4, "eventTypeLabel": "test1", "direction": "up"}, "args": {"eventType": 4, "eventTypeLabel": "test1", "direction": "up"},
}, },
@ -320,6 +323,7 @@ async def test_power_level_notification(
"source": "node", "source": "node",
"event": "notification", "event": "notification",
"nodeId": 7, "nodeId": 7,
"endpointIndex": 0,
"ccId": 115, "ccId": 115,
"args": { "args": {
"commandClassName": "Powerlevel", "commandClassName": "Powerlevel",
@ -363,6 +367,7 @@ async def test_unknown_notification(
"source": "node", "source": "node",
"event": "notification", "event": "notification",
"nodeId": node.node_id, "nodeId": node.node_id,
"endpointIndex": 0,
"ccId": 0, "ccId": 0,
"args": { "args": {
"commandClassName": "No Operation", "commandClassName": "No Operation",

View File

@ -38,24 +38,54 @@ UPDATE_ENTITY = "update.z_wave_thermostat_firmware"
LATEST_VERSION_FIRMWARE = { LATEST_VERSION_FIRMWARE = {
"version": "11.2.4", "version": "11.2.4",
"changelog": "blah 2", "changelog": "blah 2",
"channel": "stable",
"files": [{"target": 0, "url": "https://example2.com", "integrity": "sha2"}], "files": [{"target": 0, "url": "https://example2.com", "integrity": "sha2"}],
"downgrade": True,
"normalizedVersion": "11.2.4",
"device": {
"manufacturerId": 1,
"productType": 2,
"productId": 3,
"firmwareVersion": "0.4.4",
"rfRegion": 1,
},
} }
FIRMWARE_UPDATES = { FIRMWARE_UPDATES = {
"updates": [ "updates": [
{ {
"version": "10.11.1", "version": "10.11.1",
"changelog": "blah 1", "changelog": "blah 1",
"channel": "stable",
"files": [ "files": [
{"target": 0, "url": "https://example1.com", "integrity": "sha1"} {"target": 0, "url": "https://example1.com", "integrity": "sha1"}
], ],
"downgrade": True,
"normalizedVersion": "10.11.1",
"device": {
"manufacturerId": 1,
"productType": 2,
"productId": 3,
"firmwareVersion": "0.4.4",
"rfRegion": 1,
},
}, },
LATEST_VERSION_FIRMWARE, LATEST_VERSION_FIRMWARE,
{ {
"version": "11.1.5", "version": "11.1.5",
"changelog": "blah 3", "changelog": "blah 3",
"channel": "stable",
"files": [ "files": [
{"target": 0, "url": "https://example3.com", "integrity": "sha3"} {"target": 0, "url": "https://example3.com", "integrity": "sha3"}
], ],
"downgrade": True,
"normalizedVersion": "11.1.5",
"device": {
"manufacturerId": 1,
"productType": 2,
"productId": 3,
"firmwareVersion": "0.4.4",
"rfRegion": 1,
},
}, },
] ]
} }
@ -745,7 +775,23 @@ async def test_update_entity_full_restore_data_update_available(
assert client.async_send_command.call_args_list[1][0][0] == { assert client.async_send_command.call_args_list[1][0][0] == {
"command": "controller.firmware_update_ota", "command": "controller.firmware_update_ota",
"nodeId": climate_radio_thermostat_ct100_plus_different_endpoints.node_id, "nodeId": climate_radio_thermostat_ct100_plus_different_endpoints.node_id,
"updates": [{"target": 0, "url": "https://example2.com", "integrity": "sha2"}], "updateInfo": {
"version": "11.2.4",
"changelog": "blah 2",
"channel": "stable",
"files": [
{"target": 0, "url": "https://example2.com", "integrity": "sha2"}
],
"downgrade": True,
"normalizedVersion": "11.2.4",
"device": {
"manufacturerId": 1,
"productType": 2,
"productId": 3,
"firmwareVersion": "0.4.4",
"rfRegion": 1,
},
},
} }
install_task.cancel() install_task.cancel()