Add Matter tests for BatVoltage attribute from PowerSource cluster (#125645)

* Add BatVoltage Attribute from PowerSource Cluster

* Update sensor.py

Remove comment

* Update homeassistant/components/matter/sensor.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Fixture for a Eve Door & Window node

Fixture for a Eve Door & Window node to check BatVoltage attribute from PowerSource cluster

* Test battery voltage sensor

* Update test_sensor.py

* ruff-format

* Update test_sensor.py

* Update test_sensor.py

battery_voltage attribute test

* Update test_sensor.py

* Update test_sensor.py

* Update tests/components/matter/test_sensor.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update test_sensor.py

* Adjust values

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
pull/126050/head
Ludovic BOUÉ 2024-09-16 14:16:03 +02:00 committed by GitHub
parent e9364f4c3a
commit e08a94fe1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 27 additions and 0 deletions

View File

@ -251,6 +251,33 @@ async def test_battery_sensor(
assert entry.entity_category == EntityCategory.DIAGNOSTIC
# This tests needs to be adjusted to remove lingering tasks
@pytest.mark.parametrize("expected_lingering_tasks", [True])
async def test_battery_sensor_voltage(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
matter_client: MagicMock,
eve_contact_sensor_node: MatterNode,
) -> None:
"""Test battery voltage sensor."""
entity_id = "sensor.eve_door_voltage"
state = hass.states.get(entity_id)
assert state
assert state.state == "3.558"
set_node_attribute(eve_contact_sensor_node, 1, 47, 11, 4234)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get(entity_id)
assert state
assert state.state == "4.234"
entry = entity_registry.async_get(entity_id)
assert entry
assert entry.entity_category == EntityCategory.DIAGNOSTIC
# This tests needs to be adjusted to remove lingering tasks
@pytest.mark.parametrize("expected_lingering_tasks", [True])
async def test_energy_sensors_custom_cluster(