Skip to content

Commit

Permalink
RGB correction tested and implemented. V0.4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidy committed Oct 22, 2021
1 parent 1d72331 commit f773473
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pywizlight/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""PyPi Version."""
__version__ = "0.4.8"
__version__ = "0.4.9"
24 changes: 10 additions & 14 deletions pywizlight/bulb.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@

from pywizlight.bulblibrary import BulbClass, BulbType, Features, KelvinRange
from pywizlight.colormgmt.rgbcw import hs2rgbcw, rgb2rgbcw, rgbcw2hs
from pywizlight.exceptions import (
WizLightConnectionError,
WizLightMethodNotFound,
WizLightNotKnownBulb,
WizLightTimeOutError,
)
from pywizlight.exceptions import (WizLightConnectionError,
WizLightMethodNotFound,
WizLightNotKnownBulb, WizLightTimeOutError)
from pywizlight.scenes import SCENES

_LOGGER = logging.getLogger(__name__)
Expand All @@ -32,7 +29,6 @@ def __init__(
speed=None,
scene: int = None,
rgb: tuple = None,
hs_color: tuple = None,
brightness: int = None,
colortemp: int = None,
state: bool = True,
Expand All @@ -54,8 +50,6 @@ def __init__(
self._set_brightness(brightness)
if colortemp is not None:
self._set_colortemp(colortemp)
if hs_color is not None:
self._set_hs_color(hs_color)

def set_pilot_message(self):
"""Return the pilot message."""
Expand Down Expand Up @@ -113,11 +107,13 @@ def _set_rgb(self, values: tuple):
self.pilot_params["b"] = blue
else:
raise ValueError("Blue is not in range between 0-255.")

# Use the existing set_warm_white function to set the CW values
self._set_warm_white(cw)
# Use the existing set_cold_white function to set the CW values
self._set_cold_white(cw)
if cw is not None:
# Use the existing set_warm_white function to set the CW values
self._set_warm_white(cw)
# Use the existing set_cold_white function to set the CW values
self._set_cold_white(cw)
else:
raise ValueError("CW values must be between 0-255. Calculation error.")

def _set_hs_color(self, values: tuple):
"""Set the HS color state of the bulb."""
Expand Down
2 changes: 1 addition & 1 deletion pywizlight/tests/test_bulb.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def test_PilotBuilder_rgb(self, data):
await pytest.correct_bulb.turn_on(PilotBuilder(rgb=(0, 128, 255)))
state = await pytest.correct_bulb.updateState()

assert state.get_rgb() == (0, 128, 255)
assert state.get_rgb() == (0, 127, 255)

@pytest.mark.asyncio
async def test_PilotBuilder_scene(self, data):
Expand Down

0 comments on commit f773473

Please sign in to comment.