Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Z-Wave JS cover stop support #78723

Merged
merged 2 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions homeassistant/components/zwave_js/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
from zwave_js_server.const import TARGET_STATE_PROPERTY, TARGET_VALUE_PROPERTY
from zwave_js_server.const.command_class.barrier_operator import BarrierState
from zwave_js_server.const.command_class.multilevel_switch import (
COVER_CLOSE_PROPERTY,
COVER_DOWN_PROPERTY,
COVER_OFF_PROPERTY,
COVER_ON_PROPERTY,
COVER_OPEN_PROPERTY,
COVER_UP_PROPERTY,
Expand Down Expand Up @@ -156,23 +153,14 @@ async def async_close_cover(self, **kwargs: Any) -> None:

async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop cover."""
open_value = (
cover_property = (
self.get_zwave_value(COVER_OPEN_PROPERTY)
or self.get_zwave_value(COVER_UP_PROPERTY)
or self.get_zwave_value(COVER_ON_PROPERTY)
)
if open_value:
# Stop the cover if it's opening
await self.info.node.async_set_value(open_value, False)

close_value = (
self.get_zwave_value(COVER_CLOSE_PROPERTY)
or self.get_zwave_value(COVER_DOWN_PROPERTY)
or self.get_zwave_value(COVER_OFF_PROPERTY)
)
if close_value:
# Stop the cover if it's closing
await self.info.node.async_set_value(close_value, False)
if cover_property:
# Stop the cover, will stop regardless of the actual direction of travel.
await self.info.node.async_set_value(cover_property, False)


class ZWaveTiltCover(ZWaveCover):
Expand Down
48 changes: 4 additions & 44 deletions tests/components/zwave_js/test_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async def test_window_cover(hass, client, chain_actuator_zws12, integration):
blocking=True,
)

assert len(client.async_send_command.call_args_list) == 2
assert len(client.async_send_command.call_args_list) == 1
open_args = client.async_send_command.call_args_list[0][0][0]
assert open_args["command"] == "node.set_value"
assert open_args["nodeId"] == 6
Expand All @@ -127,16 +127,6 @@ async def test_window_cover(hass, client, chain_actuator_zws12, integration):
}
assert not open_args["value"]

close_args = client.async_send_command.call_args_list[1][0][0]
assert close_args["command"] == "node.set_value"
assert close_args["nodeId"] == 6
assert close_args["valueId"] == {
"commandClass": 38,
"endpoint": 0,
"property": "Close",
}
assert not close_args["value"]

# Test position update from value updated event
event = Event(
type="value updated",
Expand Down Expand Up @@ -189,7 +179,7 @@ async def test_window_cover(hass, client, chain_actuator_zws12, integration):
blocking=True,
)

assert len(client.async_send_command.call_args_list) == 2
assert len(client.async_send_command.call_args_list) == 1
open_args = client.async_send_command.call_args_list[0][0][0]
assert open_args["command"] == "node.set_value"
assert open_args["nodeId"] == 6
Expand All @@ -200,16 +190,6 @@ async def test_window_cover(hass, client, chain_actuator_zws12, integration):
}
assert not open_args["value"]

close_args = client.async_send_command.call_args_list[1][0][0]
assert close_args["command"] == "node.set_value"
assert close_args["nodeId"] == 6
assert close_args["valueId"] == {
"commandClass": 38,
"endpoint": 0,
"property": "Close",
}
assert not close_args["value"]

client.async_send_command.reset_mock()

event = Event(
Expand Down Expand Up @@ -329,7 +309,7 @@ async def test_aeotec_nano_shutter_cover(
blocking=True,
)

assert len(client.async_send_command.call_args_list) == 2
assert len(client.async_send_command.call_args_list) == 1
open_args = client.async_send_command.call_args_list[0][0][0]
assert open_args["command"] == "node.set_value"
assert open_args["nodeId"] == 3
Expand All @@ -340,16 +320,6 @@ async def test_aeotec_nano_shutter_cover(
}
assert not open_args["value"]

close_args = client.async_send_command.call_args_list[1][0][0]
assert close_args["command"] == "node.set_value"
assert close_args["nodeId"] == 3
assert close_args["valueId"] == {
"commandClass": 38,
"endpoint": 0,
"property": "Off",
}
assert not close_args["value"]

# Test position update from value updated event
event = Event(
type="value updated",
Expand Down Expand Up @@ -403,7 +373,7 @@ async def test_aeotec_nano_shutter_cover(
blocking=True,
)

assert len(client.async_send_command.call_args_list) == 2
assert len(client.async_send_command.call_args_list) == 1
open_args = client.async_send_command.call_args_list[0][0][0]
assert open_args["command"] == "node.set_value"
assert open_args["nodeId"] == 3
Expand All @@ -414,16 +384,6 @@ async def test_aeotec_nano_shutter_cover(
}
assert not open_args["value"]

close_args = client.async_send_command.call_args_list[1][0][0]
assert close_args["command"] == "node.set_value"
assert close_args["nodeId"] == 3
assert close_args["valueId"] == {
"commandClass": 38,
"endpoint": 0,
"property": "Off",
}
assert not close_args["value"]


async def test_blind_cover(hass, client, iblinds_v2, integration):
"""Test a blind cover entity."""
Expand Down