Bugfix message handling (#735)

This commit is contained in:
Pascal Vizeli 2018-10-01 18:57:31 +02:00 committed by GitHub
parent bf75a8a439
commit 94fd24c251
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,7 +57,7 @@ class Discovery(CoreSysAttributes, JsonConfig):
"""Return list of available discovery messages."""
return list(self.message_obj.values())
def send(self, addon, service, component, platform, config):
def send(self, addon, service, config):
"""Send a discovery message to Home Assistant."""
try:
DISCOVERY_SERVICES[service](config)
@ -67,7 +67,7 @@ class Discovery(CoreSysAttributes, JsonConfig):
raise DiscoveryError() from None
# Create message
message = Message(addon.slug, service, component, platform, config)
message = Message(addon.slug, service, config)
# Already exists?
for old_message in self.list_messages:
@ -115,7 +115,7 @@ class Discovery(CoreSysAttributes, JsonConfig):
@attr.s
class Message:
"""Represent a single Discovery message."""
uuid = attr.ib(factory=lambda: uuid4().hex, cmp=False)
uuid = attr.ib(factory=lambda: uuid4().hex, cmp=False, init=False)
addon = attr.ib()
service = attr.ib()
config = attr.ib(cmp=False)