mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Fix Z-Wave JS cover device class for roller shutter modules (#191825)
This commit is contained in:
@@ -397,6 +397,12 @@ class ZWaveMultilevelSwitchCover(CoverPositionMixin):
|
||||
and self.info.platform_hint.startswith("gate")
|
||||
):
|
||||
self._attr_device_class = CoverDeviceClass.GATE
|
||||
elif (
|
||||
isinstance(self.info, ZwaveDiscoveryInfo)
|
||||
and self.info.platform_hint
|
||||
and self.info.platform_hint.startswith("shade")
|
||||
):
|
||||
self._attr_device_class = CoverDeviceClass.SHADE
|
||||
|
||||
|
||||
class ZWaveTiltCover(ZWaveMultilevelSwitchCover, CoverTiltMixin):
|
||||
|
||||
@@ -312,9 +312,44 @@ DISCOVERY_SCHEMAS = [
|
||||
),
|
||||
),
|
||||
# Fibaro Shutter Fibaro FGR222
|
||||
# Operating mode (10) set to roller blind (0, 1)
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
hint="shutter_tilt",
|
||||
hint="shutter",
|
||||
manufacturer_id={0x010F},
|
||||
product_type={0x0301, 0x0302},
|
||||
primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
|
||||
required_values=[
|
||||
ZWaveValueDiscoverySchema(
|
||||
command_class={CommandClass.CONFIGURATION},
|
||||
property={10},
|
||||
endpoint={0},
|
||||
value={0, 1},
|
||||
)
|
||||
],
|
||||
),
|
||||
# Fibaro Shutter Fibaro FGR222
|
||||
# Operating mode (10) set to gate (3, 4)
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
hint="gate",
|
||||
manufacturer_id={0x010F},
|
||||
product_type={0x0301, 0x0302},
|
||||
primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
|
||||
required_values=[
|
||||
ZWaveValueDiscoverySchema(
|
||||
command_class={CommandClass.CONFIGURATION},
|
||||
property={10},
|
||||
endpoint={0},
|
||||
value={3, 4},
|
||||
)
|
||||
],
|
||||
),
|
||||
# Fibaro Shutter Fibaro FGR222
|
||||
# Operating mode (10) set to venetian blind (2)
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
hint="blind_tilt",
|
||||
manufacturer_id={0x010F},
|
||||
product_id={0x1000, 0x1001},
|
||||
product_type={0x0301, 0x0302},
|
||||
@@ -338,17 +373,39 @@ DISCOVERY_SCHEMAS = [
|
||||
command_class={CommandClass.MANUFACTURER_PROPRIETARY},
|
||||
property={"fibaro"},
|
||||
property_key={"venetianBlindsTilt"},
|
||||
),
|
||||
ZWaveValueDiscoverySchema(
|
||||
command_class={CommandClass.CONFIGURATION},
|
||||
property={10},
|
||||
endpoint={0},
|
||||
value={2},
|
||||
),
|
||||
],
|
||||
),
|
||||
# Fibaro Shutter Fibaro FGR222
|
||||
# Operating mode (10) set to venetian blind (2)
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
hint="blind",
|
||||
manufacturer_id={0x010F},
|
||||
product_type={0x0301, 0x0302},
|
||||
primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
|
||||
required_values=[
|
||||
ZWaveValueDiscoverySchema(
|
||||
command_class={CommandClass.CONFIGURATION},
|
||||
property={10},
|
||||
endpoint={0},
|
||||
value={2},
|
||||
)
|
||||
],
|
||||
),
|
||||
# Fibaro Shutter Fibaro FGR223
|
||||
# Combine both switch_multilevel endpoints into shutter_tilt
|
||||
# Combine both switch_multilevel endpoints into blind_tilt
|
||||
# if operating mode (151) is set to venetian blind (2)
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
hint="shutter_tilt",
|
||||
hint="blind_tilt",
|
||||
manufacturer_id={0x010F},
|
||||
product_id={0x1000, 0x1001},
|
||||
product_type={0x0303},
|
||||
primary_value=ZWaveValueDiscoverySchema(
|
||||
command_class={CommandClass.SWITCH_MULTILEVEL},
|
||||
@@ -378,7 +435,7 @@ DISCOVERY_SCHEMAS = [
|
||||
],
|
||||
),
|
||||
# Fibaro Shutter Fibaro FGR223
|
||||
# Suppress endpoint 2 (slat): it is either combined with endpoint 1 as shutter_tilt
|
||||
# Suppress endpoint 2 (slat): it is either combined with endpoint 1 as blind_tilt
|
||||
# or has no practical function. The value is consumed to block fallthrough to a
|
||||
# generic cover schema, but no entity is created.
|
||||
# CC: Switch_Multilevel
|
||||
@@ -386,7 +443,6 @@ DISCOVERY_SCHEMAS = [
|
||||
platform=Platform.COVER,
|
||||
hint="shutter",
|
||||
manufacturer_id={0x010F},
|
||||
product_id={0x1000, 0x1001},
|
||||
product_type={0x0303},
|
||||
primary_value=ZWaveValueDiscoverySchema(
|
||||
command_class={CommandClass.SWITCH_MULTILEVEL},
|
||||
@@ -396,6 +452,40 @@ DISCOVERY_SCHEMAS = [
|
||||
),
|
||||
discovery_suppressed=True,
|
||||
),
|
||||
# Fibaro Shutter Fibaro FGR223
|
||||
# Operating mode (151) set to roller blind (1, 5, 6)
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
hint="shutter",
|
||||
manufacturer_id={0x010F},
|
||||
product_type={0x0303},
|
||||
primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
|
||||
required_values=[
|
||||
ZWaveValueDiscoverySchema(
|
||||
command_class={CommandClass.CONFIGURATION},
|
||||
property={151},
|
||||
endpoint={0},
|
||||
value={1, 5, 6},
|
||||
)
|
||||
],
|
||||
),
|
||||
# Fibaro Shutter Fibaro FGR223
|
||||
# Operating mode (151) set to gate (3, 4)
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
hint="gate",
|
||||
manufacturer_id={0x010F},
|
||||
product_type={0x0303},
|
||||
primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
|
||||
required_values=[
|
||||
ZWaveValueDiscoverySchema(
|
||||
command_class={CommandClass.CONFIGURATION},
|
||||
property={151},
|
||||
endpoint={0},
|
||||
value={3, 4},
|
||||
)
|
||||
],
|
||||
),
|
||||
# Fibaro Nice BiDi-ZWave (IBT4ZWAVE)
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
@@ -407,13 +497,13 @@ DISCOVERY_SCHEMAS = [
|
||||
required_values=[SWITCH_MULTILEVEL_TARGET_VALUE_SCHEMA],
|
||||
),
|
||||
# Shelly Qubino Wave Shutter QNSH-001P10
|
||||
# Combine both switch_multilevel endpoints into shutter_tilt
|
||||
# Combine both switch_multilevel endpoints into blind_tilt
|
||||
# if operating mode (71) is set to venetian blind (1)
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
hint="shutter_tilt",
|
||||
hint="blind_tilt",
|
||||
manufacturer_id={0x0460},
|
||||
product_id={0x0082, 0x0083},
|
||||
product_id={0x0082, 0x0083, 0x0085},
|
||||
product_type={0x0003},
|
||||
primary_value=ZWaveValueDiscoverySchema(
|
||||
command_class={CommandClass.SWITCH_MULTILEVEL},
|
||||
@@ -443,7 +533,7 @@ DISCOVERY_SCHEMAS = [
|
||||
],
|
||||
),
|
||||
# Shelly Qubino Wave Shutter QNSH-001P10
|
||||
# Suppress endpoint 2 (slat): it is either combined with endpoint 1 as shutter_tilt
|
||||
# Suppress endpoint 2 (slat): it is either combined with endpoint 1 as blind_tilt
|
||||
# or has no practical function. The value is consumed to block fallthrough to a
|
||||
# generic cover schema, but no entity is created.
|
||||
# CC: Switch_Multilevel
|
||||
@@ -451,7 +541,7 @@ DISCOVERY_SCHEMAS = [
|
||||
platform=Platform.COVER,
|
||||
hint="shutter",
|
||||
manufacturer_id={0x0460},
|
||||
product_id={0x0082, 0x0083},
|
||||
product_id={0x0082, 0x0083, 0x0085},
|
||||
product_type={0x0003},
|
||||
primary_value=ZWaveValueDiscoverySchema(
|
||||
command_class={CommandClass.SWITCH_MULTILEVEL},
|
||||
@@ -461,6 +551,24 @@ DISCOVERY_SCHEMAS = [
|
||||
),
|
||||
discovery_suppressed=True,
|
||||
),
|
||||
# Shelly Qubino Wave Shutter QNSH-001P10
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
hint="shutter",
|
||||
manufacturer_id={0x0460},
|
||||
product_id={0x0082, 0x0083, 0x0085},
|
||||
product_type={0x0003},
|
||||
primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
|
||||
),
|
||||
# Aeotec Nano Shutter ZW141
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
hint="shutter",
|
||||
manufacturer_id={0x0371},
|
||||
product_id={0x008D},
|
||||
product_type={0x0003, 0x0103, 0x0203},
|
||||
primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
|
||||
),
|
||||
# Qubino flush shutter
|
||||
ZWaveDiscoverySchema(
|
||||
platform=Platform.COVER,
|
||||
|
||||
@@ -280,7 +280,7 @@ async def test_fibaro_fgr222_shutter_cover(
|
||||
"""Test tilt function of the Fibaro Shutter devices."""
|
||||
state = hass.states.get(FIBARO_FGR_222_SHUTTER_COVER_ENTITY)
|
||||
assert state
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.SHUTTER
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.BLIND
|
||||
|
||||
assert state.state == CoverState.OPEN
|
||||
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 0
|
||||
@@ -384,7 +384,7 @@ async def test_fibaro_fgr223_shutter_cover(
|
||||
"""Test tilt function of the Fibaro Shutter devices."""
|
||||
state = hass.states.get(FIBARO_FGR_223_SHUTTER_COVER_ENTITY)
|
||||
assert state
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.SHUTTER
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.BLIND
|
||||
|
||||
assert state.state == CoverState.OPEN
|
||||
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 0
|
||||
@@ -484,7 +484,7 @@ async def test_shelly_wave_shutter_cover_with_tilt(
|
||||
"""
|
||||
state = hass.states.get(SHELLY_WAVE_SHUTTER_COVER_ENTITY)
|
||||
assert state
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.SHUTTER
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.BLIND
|
||||
|
||||
assert state.state == CoverState.CLOSED
|
||||
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 0
|
||||
@@ -585,7 +585,7 @@ async def test_aeotec_nano_shutter_cover(
|
||||
state = hass.states.get(AEOTEC_SHUTTER_COVER_ENTITY)
|
||||
|
||||
assert state
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.WINDOW
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.SHUTTER
|
||||
|
||||
assert state.state == CoverState.CLOSED
|
||||
assert state.attributes[ATTR_CURRENT_POSITION] == 0
|
||||
@@ -964,16 +964,192 @@ async def test_fibaro_fgr222_shutter_cover_no_tilt(
|
||||
assert ATTR_CURRENT_TILT_POSITION not in state.attributes
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("operating_mode", "device_class"),
|
||||
[
|
||||
pytest.param(0, CoverDeviceClass.SHUTTER, id="roller_blind"),
|
||||
pytest.param(1, CoverDeviceClass.SHUTTER, id="roller_blind_positioning"),
|
||||
pytest.param(3, CoverDeviceClass.GATE, id="gate"),
|
||||
pytest.param(4, CoverDeviceClass.GATE, id="gate_positioning"),
|
||||
],
|
||||
)
|
||||
async def test_fibaro_fgr222_shutter_cover_device_class(
|
||||
hass: HomeAssistant,
|
||||
client: MagicMock,
|
||||
fibaro_fgr222_shutter_state: dict[str, Any],
|
||||
integration: MockConfigEntry,
|
||||
operating_mode: int,
|
||||
device_class: CoverDeviceClass,
|
||||
) -> None:
|
||||
"""Test Fibaro FGR-222 device class follows the operating mode."""
|
||||
node_state = replace_value_of_zwave_value(
|
||||
fibaro_fgr222_shutter_state,
|
||||
[
|
||||
ZwaveValueMatcher(
|
||||
property_=10,
|
||||
command_class=CommandClass.CONFIGURATION,
|
||||
endpoint=0,
|
||||
),
|
||||
],
|
||||
operating_mode,
|
||||
)
|
||||
node = Node(client, node_state)
|
||||
client.driver.controller.emit("node added", {"node": node})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(FIBARO_FGR_222_SHUTTER_COVER_ENTITY)
|
||||
assert state
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == device_class
|
||||
assert ATTR_CURRENT_TILT_POSITION not in state.attributes
|
||||
|
||||
|
||||
async def test_fibaro_fgr222_venetian_blind_without_tilt_value(
|
||||
hass: HomeAssistant,
|
||||
client: MagicMock,
|
||||
fibaro_fgr222_shutter_state: dict[str, Any],
|
||||
integration: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test Fibaro FGR-222 in venetian blind mode without the proprietary tilt value."""
|
||||
node_state = copy.deepcopy(fibaro_fgr222_shutter_state)
|
||||
node_state["values"] = [
|
||||
value
|
||||
for value in node_state["values"]
|
||||
if value["commandClass"] != CommandClass.MANUFACTURER_PROPRIETARY
|
||||
]
|
||||
node = Node(client, node_state)
|
||||
client.driver.controller.emit("node added", {"node": node})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(FIBARO_FGR_222_SHUTTER_COVER_ENTITY)
|
||||
assert state
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.BLIND
|
||||
assert ATTR_CURRENT_TILT_POSITION not in state.attributes
|
||||
|
||||
|
||||
@pytest.mark.parametrize("product_id", [0x0082, 0x0085])
|
||||
async def test_shelly_wave_shutter_cover_venetian(
|
||||
hass: HomeAssistant,
|
||||
client: MagicMock,
|
||||
shelly_europe_ltd_qnsh_001p10_state: dict[str, Any],
|
||||
integration: MockConfigEntry,
|
||||
product_id: int,
|
||||
) -> None:
|
||||
"""Test Shelly Wave Shutter in venetian mode combines both endpoints."""
|
||||
node = Node(
|
||||
client, {**shelly_europe_ltd_qnsh_001p10_state, "productId": product_id}
|
||||
)
|
||||
client.driver.controller.emit("node added", {"node": node})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.async_entity_ids_count("cover") == 1
|
||||
state = hass.states.get("cover.wave_shutter")
|
||||
assert state
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.BLIND
|
||||
assert ATTR_CURRENT_TILT_POSITION in state.attributes
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("operating_mode", "device_class"),
|
||||
[
|
||||
pytest.param(1, CoverDeviceClass.SHUTTER, id="roller_blind"),
|
||||
pytest.param(2, CoverDeviceClass.BLIND, id="venetian_blind"),
|
||||
pytest.param(4, CoverDeviceClass.GATE, id="gate"),
|
||||
],
|
||||
)
|
||||
async def test_fibaro_fgr223_variant_single_cover(
|
||||
hass: HomeAssistant,
|
||||
client: MagicMock,
|
||||
fibaro_fgr223_shutter_state: dict[str, Any],
|
||||
integration: MockConfigEntry,
|
||||
operating_mode: int,
|
||||
device_class: CoverDeviceClass,
|
||||
) -> None:
|
||||
"""Test Fibaro FGR-223 variants expose one cover for the slat endpoint."""
|
||||
node_state = replace_value_of_zwave_value(
|
||||
{**fibaro_fgr223_shutter_state, "productId": 0x3000},
|
||||
[
|
||||
ZwaveValueMatcher(
|
||||
property_=151,
|
||||
command_class=CommandClass.CONFIGURATION,
|
||||
endpoint=0,
|
||||
),
|
||||
],
|
||||
operating_mode,
|
||||
)
|
||||
node = Node(client, node_state)
|
||||
client.driver.controller.emit("node added", {"node": node})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.async_entity_ids_count("cover") == 1
|
||||
state = hass.states.get(FIBARO_FGR_223_SHUTTER_COVER_ENTITY)
|
||||
assert state
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == device_class
|
||||
|
||||
|
||||
@pytest.mark.parametrize("product_id", [0x0082, 0x0085])
|
||||
@pytest.mark.parametrize(
|
||||
"operating_mode",
|
||||
[
|
||||
pytest.param(0, id="shutter"),
|
||||
pytest.param(2, id="manual_time"),
|
||||
],
|
||||
)
|
||||
async def test_shelly_wave_shutter_cover_no_tilt(
|
||||
hass: HomeAssistant,
|
||||
client: MagicMock,
|
||||
shelly_europe_ltd_qnsh_001p10_state: dict[str, Any],
|
||||
integration: MockConfigEntry,
|
||||
operating_mode: int,
|
||||
product_id: int,
|
||||
) -> None:
|
||||
"""Test Shelly Wave Shutter operating modes without tilt."""
|
||||
shelly_europe_ltd_qnsh_001p10_state = {
|
||||
**shelly_europe_ltd_qnsh_001p10_state,
|
||||
"productId": product_id,
|
||||
}
|
||||
node_state = replace_value_of_zwave_value(
|
||||
shelly_europe_ltd_qnsh_001p10_state,
|
||||
[
|
||||
ZwaveValueMatcher(
|
||||
property_=71,
|
||||
command_class=CommandClass.CONFIGURATION,
|
||||
endpoint=0,
|
||||
),
|
||||
],
|
||||
operating_mode,
|
||||
)
|
||||
node = Node(client, node_state)
|
||||
client.driver.controller.emit("node added", {"node": node})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.async_entity_ids_count("cover") == 1
|
||||
state = hass.states.get("cover.wave_shutter")
|
||||
assert state
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.SHUTTER
|
||||
assert ATTR_CURRENT_TILT_POSITION not in state.attributes
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("operating_mode", "device_class"),
|
||||
[
|
||||
pytest.param(1, CoverDeviceClass.SHUTTER, id="roller_blind"),
|
||||
pytest.param(3, CoverDeviceClass.GATE, id="gate_without_positioning"),
|
||||
pytest.param(4, CoverDeviceClass.GATE, id="gate_with_positioning"),
|
||||
pytest.param(5, CoverDeviceClass.SHUTTER, id="roller_blind_built_in_driver"),
|
||||
pytest.param(
|
||||
6, CoverDeviceClass.SHUTTER, id="roller_blind_built_in_driver_impulse"
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_fibaro_fgr223_shutter_cover_no_tilt(
|
||||
hass: HomeAssistant,
|
||||
client: MagicMock,
|
||||
fibaro_fgr223_shutter_state: dict[str, Any],
|
||||
integration: MockConfigEntry,
|
||||
operating_mode: int,
|
||||
device_class: CoverDeviceClass,
|
||||
) -> None:
|
||||
"""Test absence of tilt function for Fibaro Shutter roller blind.
|
||||
|
||||
Fibaro Shutter devices can have operating mode set to roller blind (1).
|
||||
"""
|
||||
"""Test Fibaro Shutter operating modes without tilt."""
|
||||
node_state = replace_value_of_zwave_value(
|
||||
fibaro_fgr223_shutter_state,
|
||||
[
|
||||
@@ -983,7 +1159,7 @@ async def test_fibaro_fgr223_shutter_cover_no_tilt(
|
||||
endpoint=0,
|
||||
),
|
||||
],
|
||||
1,
|
||||
operating_mode,
|
||||
)
|
||||
node = Node(client, node_state)
|
||||
client.driver.controller.emit("node added", {"node": node})
|
||||
@@ -992,6 +1168,7 @@ async def test_fibaro_fgr223_shutter_cover_no_tilt(
|
||||
state = hass.states.get(FIBARO_FGR_223_SHUTTER_COVER_ENTITY)
|
||||
assert state
|
||||
assert state.state == CoverState.OPEN
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == device_class
|
||||
assert ATTR_CURRENT_POSITION in state.attributes
|
||||
assert ATTR_CURRENT_TILT_POSITION not in state.attributes
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ async def test_zvidar_state(hass: HomeAssistant, client, zvidar, integration) ->
|
||||
|
||||
state = hass.states.get("cover.window_blind_controller")
|
||||
assert state
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.SHADE
|
||||
|
||||
|
||||
async def test_simon_io_700_roller_blind(
|
||||
|
||||
Reference in New Issue
Block a user