Allow update discovery messages (#1136)

* Allow update discovery messages

* Update __init__.py

* Update __init__.py

* Update __init__.py

* fix lint

* Fix style
This commit is contained in:
Pascal Vizeli 2019-06-24 23:29:42 +02:00 committed by GitHub
parent b8b73cf880
commit ce18183daa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,11 +85,16 @@ class Discovery(CoreSysAttributes, JsonConfig):
message = Message(addon.slug, service, config)
# Already exists?
for old_message in self.list_messages:
if old_message != message:
for exists_msg in self.list_messages:
if exists_msg != message:
continue
_LOGGER.info("Duplicate discovery message from %s", addon.slug)
return old_message
if exists_msg.config != config:
message = exists_msg
message.config = config
else:
_LOGGER.debug("Duplicate discovery message from %s", addon.slug)
return exists_msg
break
_LOGGER.info("Send discovery to Home Assistant %s from %s", service, addon.slug)
self.message_obj[message.uuid] = message