Skip to content

Commit

Permalink
Add config store test for binary sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
farmio committed Jan 30, 2025
1 parent 0b607f8 commit f67b79e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
27 changes: 27 additions & 0 deletions tests/components/knx/fixtures/config_store_binarysensor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": 1,
"minor_version": 1,
"key": "knx/config_store.json",
"data": {
"entities": {
"light": {},
"binary_sensor": {
"knx_es_01JJP1XDQRXB0W6YYGXW6Y1X10": {
"entity": {
"name": "test",
"device_info": null,
"entity_category": null
},
"knx": {
"ga_sensor": {
"state": "3/2/21",
"passive": []
},
"respond_to_read": false,
"sync_state": true
}
}
}
}
}
}
11 changes: 11 additions & 0 deletions tests/components/knx/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,14 @@ async def test_binary_sensor_ui_create(
await knx.receive_response("2/2/2", not knx_data.get("invert"))
state = hass.states.get("binary_sensor.test")
assert state.state is STATE_ON


async def test_binary_sensor_ui_load(
hass: HomeAssistant,
knx: KNXTestKit,
entity_registry: er.EntityRegistry,
) -> None:
"""Test loading a binary sensor from storage."""
await knx.setup_integration(config_store_fixture="config_store_binarysensor.json")
await knx.assert_read("3/2/21", response=True, ignore_order=True)
knx.assert_state("binary_sensor.test", STATE_ON)
2 changes: 1 addition & 1 deletion tests/components/knx/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async def test_remove_device(
) -> None:
"""Test device removal."""
assert await async_setup_component(hass, "config", {})
await knx.setup_integration(config_store_fixture="config_store.json")
await knx.setup_integration(config_store_fixture="config_store_light_switch.json")
client = await hass_ws_client(hass)

await knx.assert_read("1/0/21", response=True, ignore_order=True) # test light
Expand Down
2 changes: 1 addition & 1 deletion tests/components/knx/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ async def test_light_ui_load(
entity_registry: er.EntityRegistry,
) -> None:
"""Test loading a light from storage."""
await knx.setup_integration(config_store_fixture="config_store.json")
await knx.setup_integration(config_store_fixture="config_store_light_switch.json")

await knx.assert_read("1/0/21", response=True, ignore_order=True)
# unrelated switch in config store
Expand Down

0 comments on commit f67b79e

Please sign in to comment.