diff --git a/homeassistant/components/homematic/__init__.py b/homeassistant/components/homematic/__init__.py index 4343bcfbc08..d5336217221 100644 --- a/homeassistant/components/homematic/__init__.py +++ b/homeassistant/components/homematic/__init__.py @@ -18,7 +18,7 @@ from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity -REQUIREMENTS = ['pyhomematic==0.1.51'] +REQUIREMENTS = ['pyhomematic==0.1.52'] _LOGGER = logging.getLogger(__name__) @@ -64,8 +64,9 @@ HM_DEVICE_TYPES = { DISCOVER_SWITCHES: [ 'Switch', 'SwitchPowermeter', 'IOSwitch', 'IPSwitch', 'RFSiren', 'IPSwitchPowermeter', 'HMWIOSwitch', 'Rain', 'EcoLogic', - 'IPKeySwitchPowermeter'], - DISCOVER_LIGHTS: ['Dimmer', 'KeyDimmer', 'IPKeyDimmer'], + 'IPKeySwitchPowermeter', 'IPGarage'], + DISCOVER_LIGHTS: ['Dimmer', 'KeyDimmer', 'IPKeyDimmer', 'IPDimmer', + 'ColorEffectLight'], DISCOVER_SENSORS: [ 'SwitchPowermeter', 'Motion', 'MotionV2', 'RemoteMotion', 'MotionIP', 'ThermostatWall', 'AreaThermostat', 'RotaryHandleSensor', @@ -76,7 +77,7 @@ HM_DEVICE_TYPES = { 'IPSmoke', 'RFSiren', 'PresenceIP', 'IPAreaThermostat', 'IPWeatherSensor', 'RotaryHandleSensorIP', 'IPPassageSensor', 'IPKeySwitchPowermeter', 'IPThermostatWall230V', 'IPWeatherSensorPlus', - 'IPWeatherSensorBasic', 'IPBrightnessSensor'], + 'IPWeatherSensorBasic', 'IPBrightnessSensor', 'IPGarage'], DISCOVER_CLIMATE: [ 'Thermostat', 'ThermostatWall', 'MAXThermostat', 'ThermostatWall2', 'MAXWallThermostat', 'IPThermostat', 'IPThermostatWall', diff --git a/homeassistant/components/light/homematic.py b/homeassistant/components/light/homematic.py index 9a7baa713a3..de11c96f8b7 100644 --- a/homeassistant/components/light/homematic.py +++ b/homeassistant/components/light/homematic.py @@ -8,8 +8,8 @@ import logging from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice from homeassistant.components.light import ( - ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light) -from homeassistant.const import STATE_UNKNOWN + ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, ATTR_HS_COLOR, SUPPORT_COLOR, + ATTR_EFFECT, SUPPORT_EFFECT, Light) _LOGGER = logging.getLogger(__name__) @@ -38,7 +38,7 @@ class HMLight(HMDevice, Light): def brightness(self): """Return the brightness of this light between 0..255.""" # Is dimmer? - if self._state == "LEVEL": + if self._state == 'LEVEL': return int(self._hm_get_state() * 255) return None @@ -53,16 +53,47 @@ class HMLight(HMDevice, Light): @property def supported_features(self): """Flag supported features.""" - return SUPPORT_HOMEMATIC + if 'COLOR' in self._hmdevice.WRITENODE: + return SUPPORT_BRIGHTNESS | SUPPORT_COLOR | SUPPORT_EFFECT + return SUPPORT_BRIGHTNESS + + @property + def hs_color(self): + """Return the hue and saturation color value [float, float].""" + if not self.supported_features & SUPPORT_COLOR: + return None + hue, sat = self._hmdevice.get_hs_color() + return hue*360.0, sat*100.0 + + @property + def effect_list(self): + """Return the list of supported effects.""" + if not self.supported_features & SUPPORT_EFFECT: + return None + return self._hmdevice.get_effect_list() + + @property + def effect(self): + """Return the current color change program of the light.""" + if not self.supported_features & SUPPORT_EFFECT: + return None + return self._hmdevice.get_effect() def turn_on(self, **kwargs): - """Turn the light on.""" + """Turn the light on and/or change color or color effect settings.""" if ATTR_BRIGHTNESS in kwargs and self._state == "LEVEL": percent_bright = float(kwargs[ATTR_BRIGHTNESS]) / 255 self._hmdevice.set_level(percent_bright, self._channel) - else: + elif ATTR_HS_COLOR not in kwargs and ATTR_EFFECT not in kwargs: self._hmdevice.on(self._channel) + if ATTR_HS_COLOR in kwargs: + self._hmdevice.set_hs_color( + hue=kwargs[ATTR_HS_COLOR][0]/360.0, + saturation=kwargs[ATTR_HS_COLOR][1]/100.0) + if ATTR_EFFECT in kwargs: + self._hmdevice.set_effect(kwargs[ATTR_EFFECT]) + def turn_off(self, **kwargs): """Turn the light off.""" self._hmdevice.off(self._channel) @@ -71,4 +102,7 @@ class HMLight(HMDevice, Light): """Generate a data dict (self._data) from the Homematic metadata.""" # Use LEVEL self._state = "LEVEL" - self._data.update({self._state: STATE_UNKNOWN}) + self._data[self._state] = None + + if self.supported_features & SUPPORT_COLOR: + self._data.update({"COLOR": None, "PROGRAM": None}) diff --git a/requirements_all.txt b/requirements_all.txt index bd63bf2480f..9e129753dbb 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -965,7 +965,7 @@ pyhik==0.1.8 pyhiveapi==0.2.14 # homeassistant.components.homematic -pyhomematic==0.1.51 +pyhomematic==0.1.52 # homeassistant.components.sensor.hydroquebec pyhydroquebec==2.2.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index f904a96b520..0ff8df5e811 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -162,7 +162,7 @@ pydeconz==47 pydispatcher==2.0.5 # homeassistant.components.homematic -pyhomematic==0.1.51 +pyhomematic==0.1.52 # homeassistant.components.litejet pylitejet==0.1