mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Make Z-Wave device IBT4ZWAVE discoverable as a cover (#93946)
* Make Z-Wave device IBT4ZWAVE discoverable as a cover * Test device class
This commit is contained in:
parent
ce9a0059d1
commit
3934f91242
@ -305,8 +305,10 @@ class ZWaveMultilevelSwitchCover(CoverPositionMixin):
|
||||
self._attr_device_class = CoverDeviceClass.WINDOW
|
||||
if self.info.platform_hint and self.info.platform_hint.startswith("shutter"):
|
||||
self._attr_device_class = CoverDeviceClass.SHUTTER
|
||||
if self.info.platform_hint and self.info.platform_hint.startswith("blind"):
|
||||
elif self.info.platform_hint and self.info.platform_hint.startswith("blind"):
|
||||
self._attr_device_class = CoverDeviceClass.BLIND
|
||||
elif self.info.platform_hint and self.info.platform_hint.startswith("gate"):
|
||||
self._attr_device_class = CoverDeviceClass.GATE
|
||||
|
||||
|
||||
class ZWaveTiltCover(ZWaveMultilevelSwitchCover, CoverTiltMixin):
|
||||
|
@ -378,6 +378,16 @@ DISCOVERY_SCHEMAS = [
|
||||
)
|
||||
],
|
||||
),
|
||||
# Fibaro Nice BiDi-ZWave (IBT4ZWAVE)
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
hint="gate",
|
||||
manufacturer_id={0x0441},
|
||||
product_id={0x1000},
|
||||
product_type={0x2400},
|
||||
primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
|
||||
required_values=[SWITCH_MULTILEVEL_TARGET_VALUE_SCHEMA],
|
||||
),
|
||||
# Qubino flush shutter
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
|
@ -636,6 +636,12 @@ def energy_production_state_fixture():
|
||||
return json.loads(load_fixture("zwave_js/energy_production_state.json"))
|
||||
|
||||
|
||||
@pytest.fixture(name="nice_ibt4zwave_state", scope="session")
|
||||
def nice_ibt4zwave_state_fixture():
|
||||
"""Load a Nice IBT4ZWAVE cover node state fixture data."""
|
||||
return json.loads(load_fixture("zwave_js/cover_nice_ibt4zwave_state.json"))
|
||||
|
||||
|
||||
# model fixtures
|
||||
|
||||
|
||||
@ -1214,8 +1220,16 @@ def indicator_test_fixture(client, indicator_test_state):
|
||||
|
||||
|
||||
@pytest.fixture(name="energy_production")
|
||||
def energy_prodution_fixture(client, energy_production_state):
|
||||
def energy_production_fixture(client, energy_production_state):
|
||||
"""Mock a mock node with Energy Production CC."""
|
||||
node = Node(client, copy.deepcopy(energy_production_state))
|
||||
client.driver.controller.nodes[node.node_id] = node
|
||||
return node
|
||||
|
||||
|
||||
@pytest.fixture(name="nice_ibt4zwave")
|
||||
def nice_ibt4zwave_fixture(client, nice_ibt4zwave_state):
|
||||
"""Mock a Nice IBT4ZWAVE cover node."""
|
||||
node = Node(client, copy.deepcopy(nice_ibt4zwave_state))
|
||||
client.driver.controller.nodes[node.node_id] = node
|
||||
return node
|
||||
|
1410
tests/components/zwave_js/fixtures/cover_nice_ibt4zwave_state.json
Normal file
1410
tests/components/zwave_js/fixtures/cover_nice_ibt4zwave_state.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,6 @@
|
||||
"""Test the Z-Wave JS cover platform."""
|
||||
import logging
|
||||
|
||||
from zwave_js_server.const import (
|
||||
CURRENT_STATE_PROPERTY,
|
||||
CURRENT_VALUE_PROPERTY,
|
||||
@ -24,6 +26,7 @@ from homeassistant.components.cover import (
|
||||
CoverDeviceClass,
|
||||
CoverEntityFeature,
|
||||
)
|
||||
from homeassistant.components.zwave_js.const import LOGGER
|
||||
from homeassistant.components.zwave_js.helpers import ZwaveValueMatcher
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
@ -45,6 +48,7 @@ BLIND_COVER_ENTITY = "cover.window_blind_controller"
|
||||
SHUTTER_COVER_ENTITY = "cover.flush_shutter"
|
||||
AEOTEC_SHUTTER_COVER_ENTITY = "cover.nano_shutter_v_3"
|
||||
FIBARO_SHUTTER_COVER_ENTITY = "cover.fgr_222_test_cover"
|
||||
LOGGER.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
async def test_window_cover(
|
||||
@ -795,3 +799,63 @@ async def test_iblinds_v3_cover(
|
||||
assert args["value"] is False
|
||||
|
||||
client.async_send_command.reset_mock()
|
||||
|
||||
|
||||
async def test_nice_ibt4zwave_cover(
|
||||
hass: HomeAssistant, client, nice_ibt4zwave, integration
|
||||
) -> None:
|
||||
"""Test Nice IBT4ZWAVE cover."""
|
||||
entity_id = "cover.portail"
|
||||
state = hass.states.get(entity_id)
|
||||
assert state
|
||||
# This device has no state because there is no position value
|
||||
assert state.state == STATE_CLOSED
|
||||
assert state.attributes[ATTR_SUPPORTED_FEATURES] == (
|
||||
CoverEntityFeature.CLOSE
|
||||
| CoverEntityFeature.OPEN
|
||||
| CoverEntityFeature.SET_POSITION
|
||||
| CoverEntityFeature.STOP
|
||||
)
|
||||
assert ATTR_CURRENT_POSITION in state.attributes
|
||||
assert state.attributes[ATTR_CURRENT_POSITION] == 0
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.GATE
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_CLOSE_COVER,
|
||||
{ATTR_ENTITY_ID: entity_id},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
assert len(client.async_send_command.call_args_list) == 1
|
||||
args = client.async_send_command.call_args[0][0]
|
||||
assert args["command"] == "node.set_value"
|
||||
assert args["nodeId"] == 72
|
||||
assert args["valueId"] == {
|
||||
"endpoint": 0,
|
||||
"commandClass": 38,
|
||||
"property": "targetValue",
|
||||
}
|
||||
assert args["value"] == 0
|
||||
|
||||
client.async_send_command.reset_mock()
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_OPEN_COVER,
|
||||
{ATTR_ENTITY_ID: entity_id},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
assert len(client.async_send_command.call_args_list) == 1
|
||||
args = client.async_send_command.call_args[0][0]
|
||||
assert args["command"] == "node.set_value"
|
||||
assert args["nodeId"] == 72
|
||||
assert args["valueId"] == {
|
||||
"endpoint": 0,
|
||||
"commandClass": 38,
|
||||
"property": "targetValue",
|
||||
}
|
||||
assert args["value"] == 99
|
||||
|
||||
client.async_send_command.reset_mock()
|
||||
|
Loading…
x
Reference in New Issue
Block a user