2021-02-20 18:52:23 +00:00
|
|
|
"""Test discovery of entities for device-specific schemas for the Z-Wave JS integration."""
|
2021-05-09 19:28:35 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from homeassistant.components.zwave_js.discovery import (
|
|
|
|
FirmwareVersionRange,
|
|
|
|
ZWaveDiscoverySchema,
|
|
|
|
ZWaveValueDiscoverySchema,
|
|
|
|
)
|
2021-09-26 18:22:41 +00:00
|
|
|
from homeassistant.components.zwave_js.discovery_data_template import (
|
|
|
|
DynamicCurrentTempClimateDataTemplate,
|
|
|
|
)
|
2023-02-08 18:10:53 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2023-03-01 05:47:47 +00:00
|
|
|
from homeassistant.helpers import entity_registry as er
|
2021-02-20 18:52:23 +00:00
|
|
|
|
|
|
|
|
2023-02-18 13:59:26 +00:00
|
|
|
async def test_iblinds_v2(hass: HomeAssistant, client, iblinds_v2, integration) -> None:
|
2021-02-20 18:52:23 +00:00
|
|
|
"""Test that an iBlinds v2.0 multilevel switch value is discovered as a cover."""
|
|
|
|
node = iblinds_v2
|
2021-02-24 20:59:06 +00:00
|
|
|
assert node.device_class.specific.label == "Unused"
|
2021-02-20 18:52:23 +00:00
|
|
|
|
|
|
|
state = hass.states.get("light.window_blind_controller")
|
|
|
|
assert not state
|
|
|
|
|
|
|
|
state = hass.states.get("cover.window_blind_controller")
|
|
|
|
assert state
|
2021-02-22 18:56:23 +00:00
|
|
|
|
|
|
|
|
2023-02-18 13:59:26 +00:00
|
|
|
async def test_ge_12730(hass: HomeAssistant, client, ge_12730, integration) -> None:
|
2021-02-22 18:56:23 +00:00
|
|
|
"""Test GE 12730 Fan Controller v2.0 multilevel switch is discovered as a fan."""
|
|
|
|
node = ge_12730
|
2021-02-24 20:59:06 +00:00
|
|
|
assert node.device_class.specific.label == "Multilevel Power Switch"
|
2021-02-22 18:56:23 +00:00
|
|
|
|
|
|
|
state = hass.states.get("light.in_wall_smart_fan_control")
|
|
|
|
assert not state
|
|
|
|
|
|
|
|
state = hass.states.get("fan.in_wall_smart_fan_control")
|
|
|
|
assert state
|
2021-03-03 23:32:37 +00:00
|
|
|
|
|
|
|
|
2023-02-18 13:59:26 +00:00
|
|
|
async def test_inovelli_lzw36(
|
|
|
|
hass: HomeAssistant, client, inovelli_lzw36, integration
|
|
|
|
) -> None:
|
2021-03-03 23:32:37 +00:00
|
|
|
"""Test LZW36 Fan Controller multilevel switch endpoint 2 is discovered as a fan."""
|
|
|
|
node = inovelli_lzw36
|
|
|
|
assert node.device_class.specific.label == "Unused"
|
|
|
|
|
|
|
|
state = hass.states.get("light.family_room_combo")
|
|
|
|
assert state.state == "off"
|
|
|
|
|
|
|
|
state = hass.states.get("fan.family_room_combo_2")
|
|
|
|
assert state
|
2021-04-28 08:22:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_vision_security_zl7432(
|
2023-02-18 13:59:26 +00:00
|
|
|
hass: HomeAssistant, client, vision_security_zl7432, integration
|
|
|
|
) -> None:
|
2021-04-28 08:22:54 +00:00
|
|
|
"""Test Vision Security ZL7432 is caught by the device specific discovery."""
|
|
|
|
for entity_id in (
|
|
|
|
"switch.in_wall_dual_relay_switch",
|
|
|
|
"switch.in_wall_dual_relay_switch_2",
|
|
|
|
):
|
|
|
|
state = hass.states.get(entity_id)
|
|
|
|
assert state
|
|
|
|
assert state.attributes["assumed_state"]
|
2021-05-09 19:28:35 +00:00
|
|
|
|
|
|
|
|
2021-08-17 11:34:00 +00:00
|
|
|
async def test_lock_popp_electric_strike_lock_control(
|
2023-02-18 13:59:26 +00:00
|
|
|
hass: HomeAssistant, client, lock_popp_electric_strike_lock_control, integration
|
|
|
|
) -> None:
|
2021-08-17 11:34:00 +00:00
|
|
|
"""Test that the Popp Electric Strike Lock Control gets discovered correctly."""
|
|
|
|
assert hass.states.get("lock.node_62") is not None
|
|
|
|
assert (
|
|
|
|
hass.states.get("binary_sensor.node_62_the_current_status_of_the_door")
|
|
|
|
is not None
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-02-18 13:59:26 +00:00
|
|
|
async def test_fortrez_ssa3_siren(
|
|
|
|
hass: HomeAssistant, client, fortrezz_ssa3_siren, integration
|
|
|
|
) -> None:
|
2021-12-25 09:33:20 +00:00
|
|
|
"""Test Fortrezz SSA3 siren gets discovered correctly."""
|
|
|
|
assert hass.states.get("select.siren_and_strobe_alarm") is not None
|
|
|
|
|
|
|
|
|
2023-02-08 18:10:53 +00:00
|
|
|
async def test_firmware_version_range_exception(hass: HomeAssistant) -> None:
|
2021-05-09 19:28:35 +00:00
|
|
|
"""Test FirmwareVersionRange exception."""
|
|
|
|
with pytest.raises(ValueError):
|
|
|
|
ZWaveDiscoverySchema(
|
|
|
|
"test",
|
|
|
|
ZWaveValueDiscoverySchema(command_class=1),
|
|
|
|
firmware_version_range=FirmwareVersionRange(),
|
|
|
|
)
|
2021-09-26 18:22:41 +00:00
|
|
|
|
|
|
|
|
2023-02-18 13:59:26 +00:00
|
|
|
async def test_dynamic_climate_data_discovery_template_failure(
|
|
|
|
hass: HomeAssistant, multisensor_6
|
|
|
|
) -> None:
|
2021-09-26 18:22:41 +00:00
|
|
|
"""Test that initing a DynamicCurrentTempClimateDataTemplate with no data raises."""
|
|
|
|
node = multisensor_6
|
|
|
|
with pytest.raises(ValueError):
|
|
|
|
DynamicCurrentTempClimateDataTemplate().resolve_data(
|
|
|
|
node.values[f"{node.node_id}-49-0-Ultraviolet"]
|
|
|
|
)
|
2023-03-01 05:47:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_merten_507801(hass, client, merten_507801, integration):
|
|
|
|
"""Test that Merten 507801 multilevel switch value is discovered as a cover."""
|
|
|
|
node = merten_507801
|
|
|
|
assert node.device_class.specific.label == "Unused"
|
|
|
|
|
|
|
|
state = hass.states.get("light.connect_roller_shutter")
|
|
|
|
assert not state
|
|
|
|
|
|
|
|
state = hass.states.get("cover.connect_roller_shutter")
|
|
|
|
assert state
|
|
|
|
|
|
|
|
|
|
|
|
async def test_merten_507801_disabled_enitites(
|
|
|
|
hass, client, merten_507801, integration
|
|
|
|
):
|
|
|
|
"""Test that Merten 507801 entities created by endpoint 2 are disabled."""
|
|
|
|
registry = er.async_get(hass)
|
|
|
|
entity_ids = [
|
|
|
|
"cover.connect_roller_shutter_2",
|
|
|
|
"select.connect_roller_shutter_local_protection_state_2",
|
|
|
|
"select.connect_roller_shutter_rf_protection_state_2",
|
|
|
|
]
|
|
|
|
for entity_id in entity_ids:
|
|
|
|
state = hass.states.get(entity_id)
|
|
|
|
assert state is None
|
|
|
|
entry = registry.async_get(entity_id)
|
|
|
|
assert entry
|
|
|
|
assert entry.disabled
|
|
|
|
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
|
|
|
|
|
|
|
# Test enabling entity
|
|
|
|
updated_entry = registry.async_update_entity(
|
|
|
|
entry.entity_id, **{"disabled_by": None}
|
|
|
|
)
|
|
|
|
assert updated_entry != entry
|
|
|
|
assert updated_entry.disabled is False
|