mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-11 17:14:28 +05:00
fix brightness
This commit is contained in:
@@ -430,6 +430,8 @@ class MegaOutPort(MegaPushEntity):
|
|||||||
))
|
))
|
||||||
|
|
||||||
def _calc_brightness(self, brightness):
|
def _calc_brightness(self, brightness):
|
||||||
|
if brightness is None:
|
||||||
|
brightness = 0
|
||||||
pct = brightness / 255
|
pct = brightness / 255
|
||||||
pct = max((0, pct))
|
pct = max((0, pct))
|
||||||
pct = min((pct, 1))
|
pct = min((pct, 1))
|
||||||
@@ -439,6 +441,8 @@ class MegaOutPort(MegaPushEntity):
|
|||||||
return brightness
|
return brightness
|
||||||
|
|
||||||
def _cal_reverse_brightness(self, brightness):
|
def _cal_reverse_brightness(self, brightness):
|
||||||
|
if brightness is None:
|
||||||
|
brightness = 0
|
||||||
l, h = self.range
|
l, h = self.range
|
||||||
d = h - l
|
d = h - l
|
||||||
pct = (brightness - l) / d
|
pct = (brightness - l) / d
|
||||||
|
|||||||
Reference in New Issue
Block a user