57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
"""Test Matter number entities."""
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
from matter_server.client.models.node import MatterNode
|
|
import pytest
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .common import (
|
|
set_node_attribute,
|
|
setup_integration_with_node_fixture,
|
|
trigger_subscription_callback,
|
|
)
|
|
|
|
|
|
@pytest.fixture(name="light_node")
|
|
async def dimmable_light_node_fixture(
|
|
hass: HomeAssistant, matter_client: MagicMock
|
|
) -> MatterNode:
|
|
"""Fixture for a flow sensor node."""
|
|
return await setup_integration_with_node_fixture(
|
|
hass, "dimmable-light", matter_client
|
|
)
|
|
|
|
|
|
# This tests needs to be adjusted to remove lingering tasks
|
|
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
|
async def test_level_control_config_entities(
|
|
hass: HomeAssistant,
|
|
matter_client: MagicMock,
|
|
light_node: MatterNode,
|
|
) -> None:
|
|
"""Test number entities are created for the LevelControl cluster (config) attributes."""
|
|
state = hass.states.get("number.mock_dimmable_light_on_level")
|
|
assert state
|
|
assert state.state == "255"
|
|
|
|
state = hass.states.get("number.mock_dimmable_light_on_transition_time")
|
|
assert state
|
|
assert state.state == "0.0"
|
|
|
|
state = hass.states.get("number.mock_dimmable_light_off_transition_time")
|
|
assert state
|
|
assert state.state == "0.0"
|
|
|
|
state = hass.states.get("number.mock_dimmable_light_on_off_transition_time")
|
|
assert state
|
|
assert state.state == "0.0"
|
|
|
|
set_node_attribute(light_node, 1, 0x00000008, 0x0011, 20)
|
|
await trigger_subscription_callback(hass, matter_client)
|
|
|
|
state = hass.states.get("number.mock_dimmable_light_on_level")
|
|
assert state
|
|
assert state.state == "20"
|