Skip to content

Commit

Permalink
bump nhc2-coco to 1.1.3 to fix brightness support light
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Van Ham committed Nov 30, 2020
1 parent ff8de5e commit 8c5b7e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/nhc2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .const import DOMAIN, KEY_GATEWAY, CONF_SWITCHES_AS_LIGHTS
from .helpers import extract_versions

REQUIREMENTS = ['nhc2-coco==1.1.2']
REQUIREMENTS = ['nhc2-coco==1.1.3']

_LOGGER = logging.getLogger(__name__)

Expand Down
8 changes: 3 additions & 5 deletions custom_components/nhc2/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ def __init__(self, nhc2light: CoCoLight, optimistic=True):
self._optimistic = optimistic
self._is_on = nhc2light.is_on
if self._nhc2light.support_brightness:
self._brightness = int((self._nhc2light.brightness + 1) * 2.54)
self._brightness = round(self._nhc2light.brightness * 2.55)
else:
self._brightness = None
nhc2light.on_change = self._on_change

def _on_change(self):
self._is_on = self._nhc2light.is_on
if self._nhc2light.support_brightness:
self._brightness = int((self._nhc2light.brightness + 1) * 2.54)
self._brightness = round(self._nhc2light.brightness * 2.55)
self.schedule_update_ha_state()

def turn_off(self, **kwargs) -> None:
Expand All @@ -59,12 +59,10 @@ async def async_turn_on(self, **kwargs):
brightness = kwargs.get(ATTR_BRIGHTNESS)

if self._nhc2light.support_brightness and brightness is not None:
self._nhc2light.brightness(int((brightness / 2.54) - 1))
self._nhc2light.set_brightness(round((brightness) / 2.55))

if self._optimistic:
self._is_on = True
if self._nhc2light.support_brightness and brightness is not None:
self._brightness = int((int((brightness / 2.54) - 1) + 1) * 2.54)
self.schedule_update_ha_state()

async def async_turn_off(self, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/nhc2/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "nhc2",
"name": "Niko Home Control II",
"requirements": ["nhc2-coco==1.1.2"],
"requirements": ["nhc2-coco==1.1.3"],
"config_flow": true,
"issue_tracker": "https://github.com/filipvh/hass-nhc2/issues",
"documentation": "https://github.com/filipvh/hass-nhc2/blob/master/README.md",
Expand Down

0 comments on commit 8c5b7e8

Please sign in to comment.