Skip to content

Commit

Permalink
use ulid instead of uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
farmio committed Feb 21, 2024
1 parent 83fee7c commit 3d7de94
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/knx/storage/config_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.storage import Store
from homeassistant.util.uuid import random_uuid_hex
from homeassistant.util.ulid import ulid_now

from ..const import DOMAIN
from .entity_store_schema import SCHEMA_OPTIONS
Expand Down Expand Up @@ -67,7 +67,7 @@ async def create_entitiy(
"""Create a new entity."""
if platform not in self.async_add_entity:
raise ConfigStoreException(f"Entity platform not ready: {platform}")
unique_id = f"knx_es_{random_uuid_hex()}"
unique_id = f"knx_es_{ulid_now()}"
if unique_id in self.data["entities"].setdefault(platform, {}):
raise ConfigStoreException("Unique id already used.")
self.async_add_entity[platform](unique_id, data)

Check warning on line 73 in homeassistant/components/knx/storage/config_store.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/knx/storage/config_store.py#L68-L73

Added lines #L68 - L73 were not covered by tests
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/knx/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.typing import UNDEFINED
from homeassistant.util.uuid import random_uuid_hex
from homeassistant.util.ulid import ulid_now

from .const import DOMAIN
from .storage.config_store import ConfigStoreException
Expand Down Expand Up @@ -413,7 +413,7 @@ def ws_create_device(
) -> None:
"""Create a new KNX device."""
knx: KNXModule = hass.data[DOMAIN]
identifier = f"knx_vdev_{random_uuid_hex()}"
identifier = f"knx_vdev_{ulid_now()}"
device_registry = dr.async_get(hass)
_device = device_registry.async_get_or_create(

Check warning on line 418 in homeassistant/components/knx/websocket.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/knx/websocket.py#L415-L418

Added lines #L415 - L418 were not covered by tests
config_entry_id=knx.entry.entry_id,
Expand Down

0 comments on commit 3d7de94

Please sign in to comment.