Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yeelight: use and expose the color temp range from specs #1247

Merged
merged 7 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion miio/integrations/yeelight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,10 @@ def set_brightness(self, level, transition=0):
)
def set_color_temp(self, level, transition=500):
"""Set color temp in kelvin."""
if level > 6500 or level < 1700:
color_temp = self._model_info.lamps[
YeelightSubLightType.Main
].color_temp # for now only main light support
rytilahti marked this conversation as resolved.
Show resolved Hide resolved
if level > color_temp.max or level < color_temp.min:
raise YeelightException("Invalid color temperature: %s" % level)
if transition > 0:
return self.send("set_ct_abx", [level, "smooth", transition])
Expand Down
4 changes: 2 additions & 2 deletions miio/integrations/yeelight/specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ yeelink.light.ceiling20:
supports_color: True
yeelink.light.ceiling22:
night_light: True
color_temp: [2700, 6500]
color_temp: [2600, 6100]
rytilahti marked this conversation as resolved.
Show resolved Hide resolved
supports_color: False
yeelink.light.ceiling24:
night_light: True
Expand Down Expand Up @@ -159,7 +159,7 @@ yeelink.light.strip1:
supports_color: True
yeelink.light.strip2:
night_light: False
color_temp: [2700, 6500]
color_temp: [1700, 6500]
supports_color: True
yeelink.light.strip4:
night_light: False
Expand Down
6 changes: 6 additions & 0 deletions miio/integrations/yeelight/tests/test_yeelight.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

from miio.integrations.yeelight.spec_helper import YeelightSpecHelper
from miio.tests.dummies import DummyDevice

from .. import Yeelight, YeelightException, YeelightMode, YeelightStatus
Expand All @@ -25,6 +26,11 @@ def __init__(self, *args, **kwargs):
}

super().__init__(*args, **kwargs)
if Yeelight._spec_helper is None:
Yeelight._spec_helper = YeelightSpecHelper()
Yeelight._supported_models = Yeelight._spec_helper.supported_models

self._model_info = Yeelight._spec_helper.get_model_info(self.model)
rytilahti marked this conversation as resolved.
Show resolved Hide resolved

def set_config(self, x):
key, value = x
Expand Down