Generate ID when not provided (#39082)

pull/39091/head
Bram Kragten 2020-08-20 20:01:35 +02:00 committed by GitHub
parent af6ca7a4d3
commit 3182dac1eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -1,6 +1,7 @@
"""The Tag integration."""
import logging
import typing
import uuid
import voluptuous as vol
@ -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])