diff --git a/custom_components/nhc2/__init__.py b/custom_components/nhc2/__init__.py index 7c33783c..5c758b24 100644 --- a/custom_components/nhc2/__init__.py +++ b/custom_components/nhc2/__init__.py @@ -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__) diff --git a/custom_components/nhc2/light.py b/custom_components/nhc2/light.py index 2718cde9..3475d921 100644 --- a/custom_components/nhc2/light.py +++ b/custom_components/nhc2/light.py @@ -34,7 +34,7 @@ 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 @@ -42,7 +42,7 @@ def __init__(self, nhc2light: CoCoLight, optimistic=True): 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: @@ -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): diff --git a/custom_components/nhc2/manifest.json b/custom_components/nhc2/manifest.json index 2a032f52..1176d8f1 100644 --- a/custom_components/nhc2/manifest.json +++ b/custom_components/nhc2/manifest.json @@ -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",