Fix loading created_at/modified_at from entity registry store (#122486)

pull/122482/head^2
Robert Resch 2024-07-23 21:15:12 +02:00 committed by GitHub
parent 57c554f516
commit e00f159ebe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View File

@ -1286,7 +1286,7 @@ class EntityRegistry(BaseRegistry):
categories=entity["categories"],
capabilities=entity["capabilities"],
config_entry_id=entity["config_entry_id"],
created_at=entity["created_at"],
created_at=datetime.fromisoformat(entity["created_at"]),
device_class=entity["device_class"],
device_id=entity["device_id"],
disabled_by=RegistryEntryDisabler(entity["disabled_by"])
@ -1303,7 +1303,7 @@ class EntityRegistry(BaseRegistry):
id=entity["id"],
has_entity_name=entity["has_entity_name"],
labels=set(entity["labels"]),
modified_at=entity["modified_at"],
modified_at=datetime.fromisoformat(entity["modified_at"]),
name=entity["name"],
options=entity["options"],
original_device_class=entity["original_device_class"],
@ -1335,10 +1335,10 @@ class EntityRegistry(BaseRegistry):
)
deleted_entities[key] = DeletedRegistryEntry(
config_entry_id=entity["config_entry_id"],
created_at=entity["created_at"],
created_at=datetime.fromisoformat(entity["created_at"]),
entity_id=entity["entity_id"],
id=entity["id"],
modified_at=entity["modified_at"],
modified_at=datetime.fromisoformat(entity["modified_at"]),
orphaned_timestamp=entity["orphaned_timestamp"],
platform=entity["platform"],
unique_id=entity["unique_id"],

View File

@ -19,6 +19,7 @@ from homeassistant.const import (
from homeassistant.core import CoreState, HomeAssistant, callback
from homeassistant.exceptions import MaxLengthExceeded
from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.util.dt import utc_from_timestamp
from tests.common import (
ANY,
@ -442,6 +443,8 @@ async def test_filter_on_load(
assert entry_with_name.name == "registry override"
assert entry_without_name.name is None
assert not entry_with_name.disabled
assert entry_with_name.created_at == utc_from_timestamp(0)
assert entry_with_name.modified_at == utc_from_timestamp(0)
entry_disabled_hass = registry.async_get_or_create(
"test", "super_platform", "disabled-hass"