mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 08:07:45 +00:00
Update pyhomematic to 0.1.52 and add features for lights (#18499)
* Update pyhomematic and add features for lights * Lint * Lint * Update homematic.py * Update homematic.py
This commit is contained in:
parent
90f3f2b1e7
commit
fc4dd4e51f
@ -18,7 +18,7 @@ from homeassistant.helpers import discovery
|
|||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
REQUIREMENTS = ['pyhomematic==0.1.51']
|
REQUIREMENTS = ['pyhomematic==0.1.52']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -64,8 +64,9 @@ HM_DEVICE_TYPES = {
|
|||||||
DISCOVER_SWITCHES: [
|
DISCOVER_SWITCHES: [
|
||||||
'Switch', 'SwitchPowermeter', 'IOSwitch', 'IPSwitch', 'RFSiren',
|
'Switch', 'SwitchPowermeter', 'IOSwitch', 'IPSwitch', 'RFSiren',
|
||||||
'IPSwitchPowermeter', 'HMWIOSwitch', 'Rain', 'EcoLogic',
|
'IPSwitchPowermeter', 'HMWIOSwitch', 'Rain', 'EcoLogic',
|
||||||
'IPKeySwitchPowermeter'],
|
'IPKeySwitchPowermeter', 'IPGarage'],
|
||||||
DISCOVER_LIGHTS: ['Dimmer', 'KeyDimmer', 'IPKeyDimmer'],
|
DISCOVER_LIGHTS: ['Dimmer', 'KeyDimmer', 'IPKeyDimmer', 'IPDimmer',
|
||||||
|
'ColorEffectLight'],
|
||||||
DISCOVER_SENSORS: [
|
DISCOVER_SENSORS: [
|
||||||
'SwitchPowermeter', 'Motion', 'MotionV2', 'RemoteMotion', 'MotionIP',
|
'SwitchPowermeter', 'Motion', 'MotionV2', 'RemoteMotion', 'MotionIP',
|
||||||
'ThermostatWall', 'AreaThermostat', 'RotaryHandleSensor',
|
'ThermostatWall', 'AreaThermostat', 'RotaryHandleSensor',
|
||||||
@ -76,7 +77,7 @@ HM_DEVICE_TYPES = {
|
|||||||
'IPSmoke', 'RFSiren', 'PresenceIP', 'IPAreaThermostat',
|
'IPSmoke', 'RFSiren', 'PresenceIP', 'IPAreaThermostat',
|
||||||
'IPWeatherSensor', 'RotaryHandleSensorIP', 'IPPassageSensor',
|
'IPWeatherSensor', 'RotaryHandleSensorIP', 'IPPassageSensor',
|
||||||
'IPKeySwitchPowermeter', 'IPThermostatWall230V', 'IPWeatherSensorPlus',
|
'IPKeySwitchPowermeter', 'IPThermostatWall230V', 'IPWeatherSensorPlus',
|
||||||
'IPWeatherSensorBasic', 'IPBrightnessSensor'],
|
'IPWeatherSensorBasic', 'IPBrightnessSensor', 'IPGarage'],
|
||||||
DISCOVER_CLIMATE: [
|
DISCOVER_CLIMATE: [
|
||||||
'Thermostat', 'ThermostatWall', 'MAXThermostat', 'ThermostatWall2',
|
'Thermostat', 'ThermostatWall', 'MAXThermostat', 'ThermostatWall2',
|
||||||
'MAXWallThermostat', 'IPThermostat', 'IPThermostatWall',
|
'MAXWallThermostat', 'IPThermostat', 'IPThermostatWall',
|
||||||
|
@ -8,8 +8,8 @@ import logging
|
|||||||
|
|
||||||
from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice
|
from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light)
|
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, ATTR_HS_COLOR, SUPPORT_COLOR,
|
||||||
from homeassistant.const import STATE_UNKNOWN
|
ATTR_EFFECT, SUPPORT_EFFECT, Light)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ class HMLight(HMDevice, Light):
|
|||||||
def brightness(self):
|
def brightness(self):
|
||||||
"""Return the brightness of this light between 0..255."""
|
"""Return the brightness of this light between 0..255."""
|
||||||
# Is dimmer?
|
# Is dimmer?
|
||||||
if self._state == "LEVEL":
|
if self._state == 'LEVEL':
|
||||||
return int(self._hm_get_state() * 255)
|
return int(self._hm_get_state() * 255)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -53,16 +53,47 @@ class HMLight(HMDevice, Light):
|
|||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
"""Flag supported features."""
|
"""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):
|
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":
|
if ATTR_BRIGHTNESS in kwargs and self._state == "LEVEL":
|
||||||
percent_bright = float(kwargs[ATTR_BRIGHTNESS]) / 255
|
percent_bright = float(kwargs[ATTR_BRIGHTNESS]) / 255
|
||||||
self._hmdevice.set_level(percent_bright, self._channel)
|
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)
|
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):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn the light off."""
|
"""Turn the light off."""
|
||||||
self._hmdevice.off(self._channel)
|
self._hmdevice.off(self._channel)
|
||||||
@ -71,4 +102,7 @@ class HMLight(HMDevice, Light):
|
|||||||
"""Generate a data dict (self._data) from the Homematic metadata."""
|
"""Generate a data dict (self._data) from the Homematic metadata."""
|
||||||
# Use LEVEL
|
# Use LEVEL
|
||||||
self._state = "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})
|
||||||
|
@ -965,7 +965,7 @@ pyhik==0.1.8
|
|||||||
pyhiveapi==0.2.14
|
pyhiveapi==0.2.14
|
||||||
|
|
||||||
# homeassistant.components.homematic
|
# homeassistant.components.homematic
|
||||||
pyhomematic==0.1.51
|
pyhomematic==0.1.52
|
||||||
|
|
||||||
# homeassistant.components.sensor.hydroquebec
|
# homeassistant.components.sensor.hydroquebec
|
||||||
pyhydroquebec==2.2.2
|
pyhydroquebec==2.2.2
|
||||||
|
@ -162,7 +162,7 @@ pydeconz==47
|
|||||||
pydispatcher==2.0.5
|
pydispatcher==2.0.5
|
||||||
|
|
||||||
# homeassistant.components.homematic
|
# homeassistant.components.homematic
|
||||||
pyhomematic==0.1.51
|
pyhomematic==0.1.52
|
||||||
|
|
||||||
# homeassistant.components.litejet
|
# homeassistant.components.litejet
|
||||||
pylitejet==0.1
|
pylitejet==0.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user