Don't create two zwave_js.lock entities for a single device (#68651)

This commit is contained in:
Raman Gupta 2022-03-28 05:15:48 -04:00 committed by GitHub
parent aa7cb087a9
commit 9d14201b13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11508 additions and 6 deletions

View File

@ -209,6 +209,12 @@ def get_config_parameter_discovery_schema(
)
DOOR_LOCK_CURRENT_MODE_SCHEMA = ZWaveValueDiscoverySchema(
command_class={CommandClass.DOOR_LOCK},
property={CURRENT_MODE_PROPERTY},
type={"number"},
)
SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA = ZWaveValueDiscoverySchema(
command_class={CommandClass.SWITCH_MULTILEVEL},
property={CURRENT_VALUE_PROPERTY},
@ -501,16 +507,17 @@ DISCOVERY_SCHEMAS = [
),
# ====== START OF GENERIC MAPPING SCHEMAS =======
# locks
# Door Lock CC
ZWaveDiscoverySchema(platform="lock", primary_value=DOOR_LOCK_CURRENT_MODE_SCHEMA),
# Only discover the Lock CC if the Door Lock CC isn't also present on the node
ZWaveDiscoverySchema(
platform="lock",
primary_value=ZWaveValueDiscoverySchema(
command_class={
CommandClass.LOCK,
CommandClass.DOOR_LOCK,
},
property={CURRENT_MODE_PROPERTY, LOCKED_PROPERTY},
type={"number", "boolean"},
command_class={CommandClass.LOCK},
property={LOCKED_PROPERTY},
type={"boolean"},
),
absent_values=[DOOR_LOCK_CURRENT_MODE_SCHEMA],
),
# door lock door status
ZWaveDiscoverySchema(

View File

@ -515,6 +515,12 @@ def light_express_controls_ezmultipli_state_fixture():
return json.loads(load_fixture("zwave_js/express_controls_ezmultipli_state.json"))
@pytest.fixture(name="lock_home_connect_620_state", scope="session")
def lock_home_connect_620_state_fixture():
"""Load the Home Connect 620 lock node state fixture data."""
return json.loads(load_fixture("zwave_js/lock_home_connect_620_state.json"))
@pytest.fixture(name="client")
def mock_client_fixture(controller_state, version_state, log_config_state):
"""Mock a client."""
@ -1031,3 +1037,11 @@ def express_controls_ezmultipli_fixture(client, express_controls_ezmultipli_stat
node = Node(client, copy.deepcopy(express_controls_ezmultipli_state))
client.driver.controller.nodes[node.node_id] = node
return node
@pytest.fixture(name="lock_home_connect_620")
def lock_home_connect_620_fixture(client, lock_home_connect_620_state):
"""Mock a Home Connect 620 lock node."""
node = Node(client, copy.deepcopy(lock_home_connect_620_state))
client.driver.controller.nodes[node.node_id] = node
return node

File diff suppressed because it is too large Load Diff

View File

@ -222,3 +222,8 @@ async def test_door_lock(hass, client, lock_schlage_be469, integration):
assert node.status == NodeStatus.DEAD
assert hass.states.get(SCHLAGE_BE469_LOCK_ENTITY).state == STATE_UNAVAILABLE
async def test_only_one_lock(hass, client, lock_home_connect_620, integration):
"""Test node with both Door Lock and Lock CC values only gets one lock entity."""
assert len(hass.states.async_entity_ids("lock")) == 1