Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate an ID when creating a tag and the id is not provided #39082

Merged
merged 1 commit into from Aug 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions homeassistant/components/tag/__init__.py
@@ -1,6 +1,7 @@
"""The Tag integration."""
import logging
import typing
import uuid

import voluptuous as vol

Expand Down Expand Up @@ -65,6 +66,8 @@ class TagStorageCollection(collection.StorageCollection):
async def _process_create_data(self, data: typing.Dict) -> typing.Dict:
"""Validate the config is valid."""
data = self.CREATE_SCHEMA(data)
if not data[TAG_ID]:
data[TAG_ID] = str(uuid.uuid4())
# make last_scanned JSON serializeable
if LAST_SCANNED in data:
data[LAST_SCANNED] = str(data[LAST_SCANNED])
Expand Down