Use new zwave_js client (#45872)

* Use new zwave_js client

* Remove client callbacks

* Clean up on connect and on disconnect

* Clean log

* Add stop listen to unsubscribe callbacks

* Fix most tests

* Adapt to new listen interface

* Fix most tests

* Remove stale connection state feature

* Bump zwave-js-server-python to 0.16.0

* Clean up disconnect
This commit is contained in:
Martin Hjelmare 2021-02-02 20:59:56 +01:00 committed by GitHub
parent 2e98cfb9ab
commit 524b9e7b1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 104 additions and 130 deletions

View file

@ -50,17 +50,11 @@ async def test_entry_setup_unload(hass, client, integration):
entry = integration
assert client.connect.call_count == 1
assert client.register_on_initialized.call_count == 1
assert client.register_on_disconnect.call_count == 1
assert client.register_on_connect.call_count == 1
assert entry.state == ENTRY_STATE_LOADED
await hass.config_entries.async_unload(entry.entry_id)
assert client.disconnect.call_count == 1
assert client.register_on_initialized.return_value.call_count == 1
assert client.register_on_disconnect.return_value.call_count == 1
assert client.register_on_connect.return_value.call_count == 1
assert entry.state == ENTRY_STATE_NOT_LOADED
@ -71,38 +65,6 @@ async def test_home_assistant_stop(hass, client, integration):
assert client.disconnect.call_count == 1
async def test_availability_reflect_connection_status(
hass, client, multisensor_6, integration
):
"""Test we handle disconnect and reconnect."""
on_initialized = client.register_on_initialized.call_args[0][0]
on_disconnect = client.register_on_disconnect.call_args[0][0]
state = hass.states.get(AIR_TEMPERATURE_SENSOR)
assert state
assert state.state != STATE_UNAVAILABLE
client.connected = False
await on_disconnect()
await hass.async_block_till_done()
state = hass.states.get(AIR_TEMPERATURE_SENSOR)
assert state
assert state.state == STATE_UNAVAILABLE
client.connected = True
await on_initialized()
await hass.async_block_till_done()
state = hass.states.get(AIR_TEMPERATURE_SENSOR)
assert state
assert state.state != STATE_UNAVAILABLE
async def test_initialized_timeout(hass, client, connect_timeout):
"""Test we handle a timeout during client initialization."""
entry = MockConfigEntry(domain="zwave_js", data={"url": "ws://test.org"})