diff --git a/tests/conftest.py b/tests/conftest.py index 92f1d24175e..cbe91fbeb87 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -264,7 +264,7 @@ def _entity_state(entity: er.RegistryEntry) -> dict[str, Any]: state = hacs.hass.states.get(entity.entity_id) return { "state": state.state if state else None, - "attributes": state.attributes if state else None, + "attributes": recursive_remove_key(state.attributes, ("display_precision", "update_percentage")) if state else None, } snapshot.assert_match( diff --git a/tests/test_switch.py b/tests/test_switch.py index 29724fe89e2..d00374c6d71 100644 --- a/tests/test_switch.py +++ b/tests/test_switch.py @@ -64,7 +64,8 @@ async def test_switch_entity_state( MockedResponse(content=data), ) - er.async_update_entity(er.async_get_entity_id("switch", DOMAIN, repo.data.id), disabled_by=None) + er.async_update_entity(er.async_get_entity_id( + "switch", DOMAIN, repo.data.id), disabled_by=None) await hass.config_entries.async_reload(hacs.configuration.config_entry.entry_id) await hass.async_block_till_done() @@ -77,13 +78,15 @@ async def test_switch_entity_state( states[platform]["initial"] = recursive_remove_key( hass.states.get(entity_id).as_dict(), - ("id", "last_changed", "last_reported", "last_updated"), + ("id", "last_changed", "last_reported", "last_updated", + "display_precision", "update_percentage"), ) await hass.services.async_call( domain="switch", service="turn_on", - service_data={"entity_id": er.async_get_entity_id("switch", DOMAIN, repo.data.id)}, + service_data={"entity_id": er.async_get_entity_id( + "switch", DOMAIN, repo.data.id)}, blocking=True, ) @@ -92,7 +95,8 @@ async def test_switch_entity_state( assert entity_id is not None states[platform]["updated"] = recursive_remove_key( hass.states.get(entity_id).as_dict(), - ("id", "last_changed", "last_reported", "last_updated"), + ("id", "last_changed", "last_reported", "last_updated", + "display_precision", "update_percentage"), ) snapshots.assert_match( diff --git a/tests/test_update.py b/tests/test_update.py index 713c0a7bda8..58aaf424d6d 100644 --- a/tests/test_update.py +++ b/tests/test_update.py @@ -53,11 +53,13 @@ async def test_update_entity_state( # Get initial state state = hass.states.get(entity_id) initial_state = recursive_remove_key( - state.as_dict(), ("id", "last_changed", "last_reported", "last_updated"), + state.as_dict(), ("id", "last_changed", "last_reported", "last_updated", + "display_precision", "update_percentage"), ) # Bump version - fixture_file = f"fixtures/proxy/data-v2.hacs.xyz/{category_test_data['category']}/data.json" + fixture_file = f"fixtures/proxy/data-v2.hacs.xyz/{ + category_test_data['category']}/data.json" fp = os.path.join( os.path.dirname(__file__), fixture_file, @@ -83,10 +85,12 @@ async def test_update_entity_state( # Get updated state state = hass.states.get(entity_id) updated_state = recursive_remove_key( - state.as_dict(), ("id", "last_changed", "last_reported", "last_updated"), + state.as_dict(), ("id", "last_changed", "last_reported", "last_updated", + "display_precision", "update_percentage"), ) snapshots.assert_match( - safe_json_dumps({"initial_state": initial_state, "updated_state": updated_state}), + safe_json_dumps({"initial_state": initial_state, + "updated_state": updated_state}), f"{category_test_data['repository']}/test_update_entity_state.json", )