Fix demos (#32086)
* Fixes for demos * Update vacuum.py * Comment * Fix tests
This commit is contained in:
1 parent
7127492767
commit
4c4e5f3fa9
8 files changed
+98
-21
No files matched your search
@@ -23,6 +23,7 @@ COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM = [
|
||||
"media_player",
|
||||
"sensor",
|
||||
"switch",
|
||||
"vacuum",
|
||||
"water_heater",
|
||||
]
|
||||
|
||||
|
||||
@@ -44,9 +44,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||
effect_list=LIGHT_EFFECT_LIST,
|
||||
effect=LIGHT_EFFECT_LIST[0],
|
||||
),
|
||||
DemoLight(
|
||||
"light_2", "Ceiling Lights", True, True, LIGHT_COLORS[0], LIGHT_TEMPS[1]
|
||||
),
|
||||
DemoLight("light_2", "Ceiling Lights", True, True, ct=LIGHT_TEMPS[1]),
|
||||
DemoLight(
|
||||
"light_3", "Kitchen Lights", True, True, LIGHT_COLORS[1], LIGHT_TEMPS[0]
|
||||
),
|
||||
@@ -86,6 +84,10 @@ class DemoLight(Light):
|
||||
self._effect_list = effect_list
|
||||
self._effect = effect
|
||||
self._available = True
|
||||
if ct is not None and hs_color is None:
|
||||
self._color_mode = "ct"
|
||||
else:
|
||||
self._color_mode = "hs"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
@@ -128,12 +130,16 @@ class DemoLight(Light):
|
||||
@property
|
||||
def hs_color(self) -> tuple:
|
||||
"""Return the hs color value."""
|
||||
return self._hs_color
|
||||
if self._color_mode == "hs":
|
||||
return self._hs_color
|
||||
return None
|
||||
|
||||
@property
|
||||
def color_temp(self) -> int:
|
||||
"""Return the CT color temperature."""
|
||||
return self._ct
|
||||
if self._color_mode == "ct":
|
||||
return self._ct
|
||||
return None
|
||||
|
||||
@property
|
||||
def white_value(self) -> int:
|
||||
@@ -165,9 +171,11 @@ class DemoLight(Light):
|
||||
self._state = True
|
||||
|
||||
if ATTR_HS_COLOR in kwargs:
|
||||
self._color_mode = "hs"
|
||||
self._hs_color = kwargs[ATTR_HS_COLOR]
|
||||
|
||||
if ATTR_COLOR_TEMP in kwargs:
|
||||
self._color_mode = "ct"
|
||||
self._ct = kwargs[ATTR_COLOR_TEMP]
|
||||
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
|
||||
@@ -10,7 +10,14 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||
async_add_entities(
|
||||
[
|
||||
DemoSwitch("swith1", "Decorative Lights", True, None, True),
|
||||
DemoSwitch("swith2", "AC", False, "mdi:air-conditioner", False),
|
||||
DemoSwitch(
|
||||
"swith2",
|
||||
"AC",
|
||||
False,
|
||||
"mdi:air-conditioner",
|
||||
False,
|
||||
device_class="outlet",
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@@ -78,12 +78,12 @@ DEMO_VACUUM_STATE = "5_Fifth_floor"
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Demo config entry."""
|
||||
setup_platform(hass, {}, async_add_entities)
|
||||
await async_setup_platform(hass, {}, async_add_entities)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Set up the Demo vacuums."""
|
||||
add_entities(
|
||||
async_add_entities(
|
||||
[
|
||||
DemoVacuum(DEMO_VACUUM_COMPLETE, SUPPORT_ALL_SERVICES),
|
||||
DemoVacuum(DEMO_VACUUM_MOST, SUPPORT_MOST_SERVICES),
|
||||
|
||||
Reference in new issue
Block a user