Add config flow to yeelight (#37191)

This commit is contained in:
Xiaonan Shen authored and GitHub committed 2020-08-31 16:40:56 +02:00
1 parent 3ab6663434
commit 45a927ffb2
15 files changed
+1044 -205

No files matched your search

+15 -2
View File
@@ -9,9 +9,9 @@ from homeassistant.components.yeelight import (
DOMAIN,
NIGHTLIGHT_SWITCH_TYPE_LIGHT,
)
from homeassistant.const import CONF_DEVICES, CONF_NAME
from homeassistant.const import CONF_DEVICES, CONF_ID, CONF_NAME
from tests.async_mock import MagicMock
from tests.async_mock import MagicMock, patch
IP_ADDRESS = "192.168.1.239"
MODEL = "color"
@@ -70,6 +70,10 @@ YAML_CONFIGURATION = {
}
}
CONFIG_ENTRY_DATA = {
CONF_ID: ID,
}
def _mocked_bulb(cannot_connect=False):
bulb = MagicMock()
@@ -85,3 +89,12 @@ def _mocked_bulb(cannot_connect=False):
bulb.music_mode = False
return bulb
def _patch_discovery(prefix, no_device=False):
def _mocked_discovery(timeout=2, interface=False):
if no_device:
return []
return [{"ip": IP_ADDRESS, "port": 55443, "capabilities": CAPABILITIES}]
return patch(f"{prefix}.discover_bulbs", side_effect=_mocked_discovery)