Provide yeelight unique_id using ssdp discovery (#35448)

* Provide yeelight unique_id using ssdp discovery

* Fixes

* Comment fix

* Cleanup initialization logic and add unique id to binary sensor

* Update homeassistant/components/yeelight/__init__.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Update homeassistant/components/yeelight/__init__.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Update comment

* Update comment

* Fix wrong model docstring

Co-authored-by: Teemu R. <tpr@iki.fi>
This commit is contained in:
zewelorandTeemu R. authored and GitHub committed 2020-05-14 19:44:32 +02:00
1 parent 9fd6db4b5f
commit 8cf354c042
5 files changed
+57 -11

No files matched your search

@@ -1,5 +1,6 @@
"""Sensor platform support for yeelight."""
import logging
from typing import Optional
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@@ -38,6 +39,14 @@ class YeelightNightlightModeSensor(BinarySensorEntity):
)
)
@property
def unique_id(self) -> Optional[str]:
"""Return a unique ID."""
unique = self._device.unique_id
if unique:
return unique + "-nightlight_sensor"
@property
def should_poll(self):
"""No polling needed."""