diff --git a/CODEOWNERS b/CODEOWNERS index b89de457751..6eec61b49e2 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1090,8 +1090,8 @@ homeassistant/components/yamaha_musiccast/* @vigonotion @micha91 tests/components/yamaha_musiccast/* @vigonotion @micha91 homeassistant/components/yandex_transport/* @rishatik92 @devbis tests/components/yandex_transport/* @rishatik92 @devbis -homeassistant/components/yeelight/* @zewelor @shenxn @starkillerOG -tests/components/yeelight/* @zewelor @shenxn @starkillerOG +homeassistant/components/yeelight/* @zewelor @shenxn @starkillerOG @alexyao2015 +tests/components/yeelight/* @zewelor @shenxn @starkillerOG @alexyao2015 homeassistant/components/yeelightsunflower/* @lindsaymarkward homeassistant/components/yi/* @bachya homeassistant/components/youless/* @gjong diff --git a/homeassistant/components/yeelight/light.py b/homeassistant/components/yeelight/light.py index 84b76d98658..0c906b3e268 100644 --- a/homeassistant/components/yeelight/light.py +++ b/homeassistant/components/yeelight/light.py @@ -7,7 +7,8 @@ import math import voluptuous as vol import yeelight -from yeelight import Bulb, Flow, RGBTransition, SleepTransition, flows +from yeelight import Flow, RGBTransition, SleepTransition, flows +from yeelight.aio import AsyncBulb from yeelight.enums import BulbType, LightType, PowerMode, SceneClass from yeelight.main import BulbException @@ -549,7 +550,7 @@ class YeelightGenericLight(YeelightEntity, LightEntity): return self._effect if self.device.is_color_flow_enabled else None @property - def _bulb(self) -> Bulb: + def _bulb(self) -> AsyncBulb: return self.device.bulb @property @@ -608,8 +609,10 @@ class YeelightGenericLight(YeelightEntity, LightEntity): async def _async_set_music_mode(self, music_mode) -> None: """Set the music mode on or off wrapped with _async_cmd.""" bulb = self._bulb - method = bulb.stop_music if not music_mode else bulb.start_music - await self.hass.async_add_executor_job(method) + if music_mode: + await bulb.async_start_music() + else: + await bulb.async_stop_music() @_async_cmd async def async_set_brightness(self, brightness, duration) -> None: diff --git a/homeassistant/components/yeelight/manifest.json b/homeassistant/components/yeelight/manifest.json index 7820e17a978..351cb879da9 100644 --- a/homeassistant/components/yeelight/manifest.json +++ b/homeassistant/components/yeelight/manifest.json @@ -2,8 +2,8 @@ "domain": "yeelight", "name": "Yeelight", "documentation": "https://www.home-assistant.io/integrations/yeelight", - "requirements": ["yeelight==0.7.8", "async-upnp-client==0.23.4"], - "codeowners": ["@zewelor", "@shenxn", "@starkillerOG"], + "requirements": ["yeelight==0.7.9", "async-upnp-client==0.23.4"], + "codeowners": ["@zewelor", "@shenxn", "@starkillerOG", "@alexyao2015"], "config_flow": true, "dependencies": ["network"], "quality_scale": "platinum", diff --git a/requirements_all.txt b/requirements_all.txt index ef3626b011a..d33b08c78ce 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2516,7 +2516,7 @@ yalesmartalarmclient==0.3.7 yalexs==1.1.20 # homeassistant.components.yeelight -yeelight==0.7.8 +yeelight==0.7.9 # homeassistant.components.yeelightsunflower yeelightsunflower==0.0.10 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 73272640802..e62662b7d79 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1550,7 +1550,7 @@ yalesmartalarmclient==0.3.7 yalexs==1.1.20 # homeassistant.components.yeelight -yeelight==0.7.8 +yeelight==0.7.9 # homeassistant.components.youless youless-api==0.16 diff --git a/tests/components/yeelight/__init__.py b/tests/components/yeelight/__init__.py index b48cfc5402a..81972ca4352 100644 --- a/tests/components/yeelight/__init__.py +++ b/tests/components/yeelight/__init__.py @@ -153,7 +153,7 @@ def _mocked_bulb(cannot_connect=False): bulb.async_set_power_mode = AsyncMock() bulb.async_set_scene = AsyncMock() bulb.async_set_default = AsyncMock() - bulb.start_music = MagicMock() + bulb.async_start_music = AsyncMock() return bulb diff --git a/tests/components/yeelight/test_light.py b/tests/components/yeelight/test_light.py index 059a47b53a1..2e37daaf9dd 100644 --- a/tests/components/yeelight/test_light.py +++ b/tests/components/yeelight/test_light.py @@ -219,8 +219,8 @@ async def test_services(hass: HomeAssistant, caplog): power_mode=PowerMode.NORMAL, ) mocked_bulb.async_turn_on.reset_mock() - mocked_bulb.start_music.assert_called_once() - mocked_bulb.start_music.reset_mock() + mocked_bulb.async_start_music.assert_called_once() + mocked_bulb.async_start_music.reset_mock() mocked_bulb.async_set_brightness.assert_called_once_with( brightness / 255 * 100, duration=transition * 1000, light_type=LightType.Main ) @@ -261,8 +261,8 @@ async def test_services(hass: HomeAssistant, caplog): power_mode=PowerMode.NORMAL, ) mocked_bulb.async_turn_on.reset_mock() - mocked_bulb.start_music.assert_called_once() - mocked_bulb.start_music.reset_mock() + mocked_bulb.async_start_music.assert_called_once() + mocked_bulb.async_start_music.reset_mock() mocked_bulb.async_set_brightness.assert_called_once_with( brightness / 255 * 100, duration=transition * 1000, light_type=LightType.Main ) @@ -304,7 +304,7 @@ async def test_services(hass: HomeAssistant, caplog): power_mode=PowerMode.NORMAL, ) mocked_bulb.async_turn_on.reset_mock() - mocked_bulb.start_music.assert_called_once() + mocked_bulb.async_start_music.assert_called_once() mocked_bulb.async_set_brightness.assert_called_once_with( brightness / 255 * 100, duration=transition * 1000, light_type=LightType.Main ) @@ -322,7 +322,7 @@ async def test_services(hass: HomeAssistant, caplog): brightness = 100 color_temp = 200 transition = 1 - mocked_bulb.start_music.reset_mock() + mocked_bulb.async_start_music.reset_mock() mocked_bulb.async_set_brightness.reset_mock() mocked_bulb.async_set_color_temp.reset_mock() mocked_bulb.async_start_flow.reset_mock() @@ -348,7 +348,7 @@ async def test_services(hass: HomeAssistant, caplog): power_mode=PowerMode.NORMAL, ) mocked_bulb.async_turn_on.reset_mock() - mocked_bulb.start_music.assert_called_once() + mocked_bulb.async_start_music.assert_called_once() mocked_bulb.async_set_brightness.assert_called_once_with( brightness / 255 * 100, duration=transition * 1000, light_type=LightType.Main ) @@ -452,7 +452,7 @@ async def test_services(hass: HomeAssistant, caplog): ) # set_music_mode failure enable - mocked_bulb.start_music = MagicMock(side_effect=AssertionError) + mocked_bulb.async_start_music = MagicMock(side_effect=AssertionError) assert "Unable to turn on music mode, consider disabling it" not in caplog.text await hass.services.async_call( DOMAIN, @@ -460,14 +460,14 @@ async def test_services(hass: HomeAssistant, caplog): {ATTR_ENTITY_ID: ENTITY_LIGHT, ATTR_MODE_MUSIC: "true"}, blocking=True, ) - assert mocked_bulb.start_music.mock_calls == [call()] + assert mocked_bulb.async_start_music.mock_calls == [call()] assert "Unable to turn on music mode, consider disabling it" in caplog.text # set_music_mode disable await _async_test_service( SERVICE_SET_MUSIC_MODE, {ATTR_ENTITY_ID: ENTITY_LIGHT, ATTR_MODE_MUSIC: "false"}, - "stop_music", + "async_stop_music", failure_side_effect=None, ) @@ -475,7 +475,7 @@ async def test_services(hass: HomeAssistant, caplog): await _async_test_service( SERVICE_SET_MUSIC_MODE, {ATTR_ENTITY_ID: ENTITY_LIGHT, ATTR_MODE_MUSIC: "true"}, - "start_music", + "async_start_music", failure_side_effect=None, ) # test _cmd wrapper error handler