Update pyhomematic 1.19 & small cleanups (#5299)

This commit is contained in:
Pascal Vizeli 2017-01-13 21:22:09 +01:00 committed by GitHub
parent 1219ca3c3b
commit a30711f1a0
2 changed files with 14 additions and 16 deletions

View file

@ -23,10 +23,10 @@ from homeassistant.config import load_yaml_config_file
from homeassistant.util import Throttle from homeassistant.util import Throttle
DOMAIN = 'homematic' DOMAIN = 'homematic'
REQUIREMENTS = ["pyhomematic==0.1.18"] REQUIREMENTS = ["pyhomematic==0.1.19"]
MIN_TIME_BETWEEN_UPDATE_HUB = timedelta(seconds=300) MIN_TIME_BETWEEN_UPDATE_HUB = timedelta(seconds=300)
MIN_TIME_BETWEEN_UPDATE_VAR = timedelta(seconds=30) SCAN_INTERVAL = timedelta(seconds=30)
DISCOVER_SWITCHES = 'homematic.switch' DISCOVER_SWITCHES = 'homematic.switch'
DISCOVER_LIGHTS = 'homematic.light' DISCOVER_LIGHTS = 'homematic.light'
@ -54,16 +54,17 @@ SERVICE_SET_DEV_VALUE = 'set_dev_value'
HM_DEVICE_TYPES = { HM_DEVICE_TYPES = {
DISCOVER_SWITCHES: [ DISCOVER_SWITCHES: [
'Switch', 'SwitchPowermeter', 'IOSwitch', 'IPSwitch', 'Switch', 'SwitchPowermeter', 'IOSwitch', 'IPSwitch',
'IPSwitchPowermeter', 'KeyMatic'], 'IPSwitchPowermeter', 'KeyMatic', 'HMWIOSwitch'],
DISCOVER_LIGHTS: ['Dimmer', 'KeyDimmer'], DISCOVER_LIGHTS: ['Dimmer', 'KeyDimmer'],
DISCOVER_SENSORS: [ DISCOVER_SENSORS: [
'SwitchPowermeter', 'Motion', 'MotionV2', 'RemoteMotion', 'SwitchPowermeter', 'Motion', 'MotionV2', 'RemoteMotion', 'MotionIP',
'ThermostatWall', 'AreaThermostat', 'RotaryHandleSensor', 'ThermostatWall', 'AreaThermostat', 'RotaryHandleSensor',
'WaterSensor', 'PowermeterGas', 'LuxSensor', 'WeatherSensor', 'WaterSensor', 'PowermeterGas', 'LuxSensor', 'WeatherSensor',
'WeatherStation', 'ThermostatWall2', 'TemperatureDiffSensor', 'WeatherStation', 'ThermostatWall2', 'TemperatureDiffSensor',
'TemperatureSensor', 'CO2Sensor', 'IPSwitchPowermeter'], 'TemperatureSensor', 'CO2Sensor', 'IPSwitchPowermeter'],
DISCOVER_CLIMATE: [ DISCOVER_CLIMATE: [
'Thermostat', 'ThermostatWall', 'MAXThermostat', 'ThermostatWall2'], 'Thermostat', 'ThermostatWall', 'MAXThermostat', 'ThermostatWall2',
'MAXWallThermostat'],
DISCOVER_BINARY_SENSORS: [ DISCOVER_BINARY_SENSORS: [
'ShutterContact', 'Smoke', 'SmokeV2', 'Motion', 'MotionV2', 'ShutterContact', 'Smoke', 'SmokeV2', 'Motion', 'MotionV2',
'RemoteMotion', 'WeatherSensor', 'TiltSensor', 'IPShutterContact'], 'RemoteMotion', 'WeatherSensor', 'TiltSensor', 'IPShutterContact'],
@ -234,7 +235,7 @@ def setup(hass, config):
"""Setup the Homematic component.""" """Setup the Homematic component."""
from pyhomematic import HMConnection from pyhomematic import HMConnection
component = EntityComponent(_LOGGER, DOMAIN, hass) component = EntityComponent(_LOGGER, DOMAIN, hass, SCAN_INTERVAL)
hass.data[DATA_DELAY] = config[DOMAIN].get(CONF_DELAY) hass.data[DATA_DELAY] = config[DOMAIN].get(CONF_DELAY)
hass.data[DATA_DEVINIT] = {} hass.data[DATA_DEVINIT] = {}
@ -461,9 +462,7 @@ def _get_devices(hass, device_type, keys, proxy):
_LOGGER.debug("Handling %s: %s", param, channels) _LOGGER.debug("Handling %s: %s", param, channels)
for channel in channels: for channel in channels:
name = _create_ha_name( name = _create_ha_name(
name=device.NAME, name=device.NAME, channel=channel, param=param,
channel=channel,
param=param,
count=len(channels) count=len(channels)
) )
device_dict = { device_dict = {
@ -623,7 +622,6 @@ class HMHub(Entity):
state = self._homematic.getServiceMessages(self._name) state = self._homematic.getServiceMessages(self._name)
self._state = STATE_UNKNOWN if state is None else len(state) self._state = STATE_UNKNOWN if state is None else len(state)
@Throttle(MIN_TIME_BETWEEN_UPDATE_VAR)
def _update_variables_state(self): def _update_variables_state(self):
"""Retrive all variable data and update hmvariable states.""" """Retrive all variable data and update hmvariable states."""
if not self._use_variables: if not self._use_variables:
@ -855,11 +853,11 @@ class HMDevice(Entity):
# Set callbacks # Set callbacks
for channel in channels_to_sub: for channel in channels_to_sub:
_LOGGER.debug("Subscribe channel %s from %s", _LOGGER.debug(
str(channel), self._name) "Subscribe channel %s from %s", str(channel), self._name)
self._hmdevice.setEventCallback(callback=self._hm_event_callback, self._hmdevice.setEventCallback(
bequeath=False, callback=self._hm_event_callback, bequeath=False,
channel=channel) channel=channel)
def _load_data_from_hm(self): def _load_data_from_hm(self):
"""Load first value from pyhomematic.""" """Load first value from pyhomematic."""

View file

@ -425,7 +425,7 @@ pyharmony==1.0.12
pyhik==0.0.7 pyhik==0.0.7
# homeassistant.components.homematic # homeassistant.components.homematic
pyhomematic==0.1.18 pyhomematic==0.1.19
# homeassistant.components.device_tracker.icloud # homeassistant.components.device_tracker.icloud
pyicloud==0.9.1 pyicloud==0.9.1