Skip to content

Commit

Permalink
Fix light turn_on on Hass 2021.4.0 #444
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Apr 8, 2021
1 parent f58ee5a commit a28d69f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@

__pycache__/

.homeassistant/

.idea/
24 changes: 14 additions & 10 deletions custom_components/sonoff/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import logging

from homeassistant.components.light import SUPPORT_BRIGHTNESS, \
ATTR_BRIGHTNESS, SUPPORT_COLOR, ATTR_HS_COLOR, \
SUPPORT_EFFECT, ATTR_EFFECT, ATTR_EFFECT_LIST, SUPPORT_COLOR_TEMP, \
ATTR_COLOR_TEMP, ATTR_MIN_MIREDS, ATTR_MAX_MIREDS
ATTR_BRIGHTNESS, SUPPORT_COLOR, ATTR_HS_COLOR, SUPPORT_EFFECT, \
ATTR_EFFECT, ATTR_EFFECT_LIST, SUPPORT_COLOR_TEMP, \
ATTR_COLOR_TEMP, ATTR_MIN_MIREDS, ATTR_MAX_MIREDS, LightEntity
from homeassistant.util import color

# noinspection PyUnresolvedReferences
Expand Down Expand Up @@ -50,10 +50,14 @@ async def async_setup_platform(hass, config, add_entities,
elif channels and len(channels) >= 2:
add_entities([EWeLinkLightGroup(registry, deviceid, channels)])
else:
add_entities([EWeLinkToggle(registry, deviceid, channels)])
add_entities([EWeLinkLight(registry, deviceid, channels)])


class SonoffD1(EWeLinkToggle):
class EWeLinkLight(EWeLinkToggle, LightEntity):
pass


class SonoffD1(EWeLinkLight):
_brightness = 0

def _update_handler(self, state: dict, attrs: dict):
Expand Down Expand Up @@ -124,7 +128,7 @@ async def async_turn_on(self, **kwargs) -> None:
]


class SonoffLED(EWeLinkToggle):
class SonoffLED(EWeLinkLight):
_brightness = 0
_hs_color = None
_mode = 0
Expand Down Expand Up @@ -212,7 +216,7 @@ async def async_turn_on(self, **kwargs) -> None:
await self.registry.send(self.deviceid, payload)


class SonoffB1(EWeLinkToggle):
class SonoffB1(EWeLinkLight):
_brightness = None
_hs_color = None
_temp = None
Expand Down Expand Up @@ -384,7 +388,7 @@ async def async_turn_on(self, **kwargs) -> None:
DIFFUSER_EFFECTS = ["Color Light", "RGB Color", "Night Light"]


class SonoffDiffuserLight(EWeLinkToggle):
class SonoffDiffuserLight(EWeLinkLight):
_brightness = 0
_hs_color = None
_mode = 0
Expand Down Expand Up @@ -525,7 +529,7 @@ async def async_turn_off(self, **kwargs) -> None:
}


class Sonoff103(EWeLinkToggle):
class Sonoff103(EWeLinkLight):
_brightness = None
_mode = None
_temp = None
Expand Down Expand Up @@ -667,7 +671,7 @@ async def async_turn_on(self, **kwargs) -> None:
}


class SonoffB05(EWeLinkToggle):
class SonoffB05(EWeLinkLight):
_brightness = None
_hs_color = None
_mode = None
Expand Down
2 changes: 1 addition & 1 deletion custom_components/sonoff/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"requirements": [
"pycryptodome>=3.6.6"
],
"version": "v2.4.2"
"version": "v2.4.3"
}

0 comments on commit a28d69f

Please sign in to comment.