Provide a unique entity ID for lgsoundbar (#38494)

The device gives us a UUID, so let's just use that to construct a unique
ID.
This commit is contained in:
Matthew Garrett 2020-08-02 19:51:01 -07:00 committed by GitHub
parent 542c6cce25
commit 76b46b9175
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,6 +35,8 @@ class LGDevice(MediaPlayerEntity):
"""Initialize the LG speakers."""
self._host = discovery_info.get("host")
self._port = discovery_info.get("port")
properties = discovery_info.get("properties")
self._uuid = properties.get("UUID")
self._name = ""
self._volume = 0
@ -128,6 +130,11 @@ class LGDevice(MediaPlayerEntity):
if equaliser >= len(temescal.equalisers):
temescal.equalisers.append("unknown " + str(equaliser))
@property
def unique_id(self):
"""Return the device's unique ID."""
return self._uuid
@property
def name(self):
"""Return the name of the device."""