Add support for updating bot

This commit is contained in:
Robert Resch 2024-04-13 15:11:24 +02:00 committed by GitHub
parent b778eedf5f
commit 547e6d57a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -345,11 +345,11 @@ def bot_add(sn: str, did: str, dev_class: str, resource: str, company: str) -> N
new_bot.resource = resource new_bot.resource = resource
new_bot.company = company new_bot.company = company
bot = bot_get(did) if (not dev_class) or "@" in sn or "tmp" in sn:
if not bot: # Not existing bot in database # try to prevent bad additions to the bot list
if ( _LOGGER.warning(f"Skipping new bot with DID: {new_bot.did}: {new_bot.asdict()}")
not dev_class == "" or "@" not in sn or "tmp" not in sn return
): # try to prevent bad additions to the bot list
_LOGGER.info(f"Adding new bot with SN: {new_bot.name} DID: {new_bot.did}") _LOGGER.info(f"Adding new bot with SN: {new_bot.name} DID: {new_bot.did}")
bot_full_upsert(new_bot.asdict()) bot_full_upsert(new_bot.asdict())