Add matter integration BETA (#83064)
* Add matter base (#79372) Co-authored-by: Marcel van der Veldt <m.vanderveldt@outlook.com> * Add matter server add-on flow (#82698) * Add matter server add-on flow * Fix stale error argument * Clean docstrings * Use localhost as default address * Add matter websocket api foundation (#82848) * Add matter config entry add-on management (#82865) * Use matter refactored server/client library (#83003) Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Bump python-matter-server to 1.0.6 (#83059) * Extend matter websocket api (#82948) * Extend matter websocket api * Finish docstring * Fix pin type * Adjust api after new client * Adjust api to frontend for now Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
845ce5c6ea
commit
e2308fd15c
32 changed files with 4627 additions and 0 deletions
82
tests/components/matter/test_light.py
Normal file
82
tests/components/matter/test_light.py
Normal file
|
@ -0,0 +1,82 @@
|
|||
"""Test Matter lights."""
|
||||
from typing import Any
|
||||
|
||||
from chip.clusters import Objects as clusters
|
||||
from matter_server.common.models.node import MatterNode
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .common import setup_integration_with_node_fixture
|
||||
|
||||
# TEMP: Tests need to be fixed
|
||||
pytestmark = pytest.mark.skip("all tests still WIP")
|
||||
|
||||
|
||||
@pytest.fixture(name="light_node")
|
||||
async def light_node_fixture(
|
||||
hass: HomeAssistant, hass_storage: dict[str, Any]
|
||||
) -> MatterNode:
|
||||
"""Fixture for a light node."""
|
||||
return await setup_integration_with_node_fixture(
|
||||
hass, hass_storage, "lighting-example-app"
|
||||
)
|
||||
|
||||
|
||||
async def test_turn_on(hass: HomeAssistant, light_node: MatterNode) -> None:
|
||||
"""Test turning on a light."""
|
||||
light_node.matter.client.mock_command(clusters.OnOff.Commands.On, None)
|
||||
|
||||
await hass.services.async_call(
|
||||
"light",
|
||||
"turn_on",
|
||||
{
|
||||
"entity_id": "light.my_cool_light",
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
assert len(light_node.matter.client.mock_sent_commands) == 1
|
||||
args = light_node.matter.client.mock_sent_commands[0]
|
||||
assert args["nodeid"] == light_node.node_id
|
||||
assert args["endpoint"] == 1
|
||||
|
||||
light_node.matter.client.mock_command(
|
||||
clusters.LevelControl.Commands.MoveToLevelWithOnOff, None
|
||||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
"light",
|
||||
"turn_on",
|
||||
{
|
||||
"entity_id": "light.my_cool_light",
|
||||
"brightness": 128,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
assert len(light_node.matter.client.mock_sent_commands) == 2
|
||||
args = light_node.matter.client.mock_sent_commands[1]
|
||||
assert args["nodeid"] == light_node.node_id
|
||||
assert args["endpoint"] == 1
|
||||
assert args["payload"].level == 127
|
||||
assert args["payload"].transitionTime == 0
|
||||
|
||||
|
||||
async def test_turn_off(hass: HomeAssistant, light_node: MatterNode) -> None:
|
||||
"""Test turning off a light."""
|
||||
light_node.matter.client.mock_command(clusters.OnOff.Commands.Off, None)
|
||||
|
||||
await hass.services.async_call(
|
||||
"light",
|
||||
"turn_off",
|
||||
{
|
||||
"entity_id": "light.my_cool_light",
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
assert len(light_node.matter.client.mock_sent_commands) == 1
|
||||
args = light_node.matter.client.mock_sent_commands[0]
|
||||
assert args["nodeid"] == light_node.node_id
|
||||
assert args["endpoint"] == 1
|
Loading…
Add table
Add a link
Reference in a new issue