Skip to content

Commit

Permalink
Improvement of KNX climate component (#10388)
Browse files Browse the repository at this point in the history
* Added myself to codeowners

* Improved climate support with setpoint shift for KNX. (XKNX/xknx#48)

* requirements_all.txt

* typo

* flake

* Changes requested by @pvizeli
  • Loading branch information
Julius2342 authored and pvizeli committed Nov 9, 2017
1 parent 9297a9c commit ee26539
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ homeassistant/components/xiaomi_aqara.py @danielhiversen @syssi

homeassistant/components/*/broadlink.py @danielhiversen
homeassistant/components/*/rfxtrx.py @danielhiversen
homeassistant/components/velux.py @Julius2342
homeassistant/components/*/velux.py @Julius2342
homeassistant/components/knx.py @Julius2342
homeassistant/components/*/knx.py @Julius2342
homeassistant/components/tesla.py @zabuldon
homeassistant/components/*/tesla.py @zabuldon
homeassistant/components/*/tradfri.py @ggravlingen
Expand Down
55 changes: 33 additions & 22 deletions homeassistant/components/climate/knx.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv

CONF_SETPOINT_ADDRESS = 'setpoint_address'
CONF_SETPOINT_SHIFT_ADDRESS = 'setpoint_shift_address'
CONF_SETPOINT_SHIFT_STATE_ADDRESS = 'setpoint_shift_state_address'
CONF_SETPOINT_SHIFT_STEP = 'setpoint_shift_step'
CONF_SETPOINT_SHIFT_MAX = 'setpoint_shift_max'
CONF_SETPOINT_SHIFT_MIN = 'setpoint_shift_min'
CONF_TEMPERATURE_ADDRESS = 'temperature_address'
CONF_TARGET_TEMPERATURE_ADDRESS = 'target_temperature_address'
CONF_OPERATION_MODE_ADDRESS = 'operation_mode_address'
Expand All @@ -28,15 +30,24 @@
CONF_OPERATION_MODE_COMFORT_ADDRESS = 'operation_mode_comfort_address'

DEFAULT_NAME = 'KNX Climate'
DEFAULT_SETPOINT_SHIFT_STEP = 0.5
DEFAULT_SETPOINT_SHIFT_MAX = 6
DEFAULT_SETPOINT_SHIFT_MIN = -6
DEPENDENCIES = ['knx']

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Required(CONF_SETPOINT_ADDRESS): cv.string,
vol.Required(CONF_TEMPERATURE_ADDRESS): cv.string,
vol.Required(CONF_TARGET_TEMPERATURE_ADDRESS): cv.string,
vol.Optional(CONF_SETPOINT_SHIFT_ADDRESS): cv.string,
vol.Optional(CONF_SETPOINT_SHIFT_STATE_ADDRESS): cv.string,
vol.Optional(CONF_SETPOINT_SHIFT_STEP,
default=DEFAULT_SETPOINT_SHIFT_STEP): vol.All(
float, vol.Range(min=0, max=2)),
vol.Optional(CONF_SETPOINT_SHIFT_MAX, default=DEFAULT_SETPOINT_SHIFT_MAX):
vol.All(int, vol.Range(min=-32, max=0)),
vol.Optional(CONF_SETPOINT_SHIFT_MIN, default=DEFAULT_SETPOINT_SHIFT_MIN):
vol.All(int, vol.Range(min=0, max=32)),
vol.Optional(CONF_OPERATION_MODE_ADDRESS): cv.string,
vol.Optional(CONF_OPERATION_MODE_STATE_ADDRESS): cv.string,
vol.Optional(CONF_CONTROLLER_STATUS_ADDRESS): cv.string,
Expand Down Expand Up @@ -77,19 +88,24 @@ def async_add_devices_discovery(hass, discovery_info, async_add_devices):
def async_add_devices_config(hass, config, async_add_devices):
"""Set up climate for KNX platform configured within plattform."""
import xknx

climate = xknx.devices.Climate(
hass.data[DATA_KNX].xknx,
name=config.get(CONF_NAME),
group_address_temperature=config.get(
CONF_TEMPERATURE_ADDRESS),
group_address_target_temperature=config.get(
CONF_TARGET_TEMPERATURE_ADDRESS),
group_address_setpoint=config.get(
CONF_SETPOINT_ADDRESS),
group_address_setpoint_shift=config.get(
CONF_SETPOINT_SHIFT_ADDRESS),
group_address_setpoint_shift_state=config.get(
CONF_SETPOINT_SHIFT_STATE_ADDRESS),
setpoint_shift_step=config.get(
CONF_SETPOINT_SHIFT_STEP),
setpoint_shift_max=config.get(
CONF_SETPOINT_SHIFT_MAX),
setpoint_shift_min=config.get(
CONF_SETPOINT_SHIFT_MIN),
group_address_operation_mode=config.get(
CONF_OPERATION_MODE_ADDRESS),
group_address_operation_mode_state=config.get(
Expand Down Expand Up @@ -118,8 +134,6 @@ def __init__(self, hass, device):
self.async_register_callbacks()

self._unit_of_measurement = TEMP_CELSIUS
self._away = False # not yet supported
self._is_fan_on = False # not yet supported

def async_register_callbacks(self):
"""Register callbacks to update hass after device was changed."""
Expand Down Expand Up @@ -150,36 +164,33 @@ def current_temperature(self):
"""Return the current temperature."""
return self.device.temperature.value

@property
def target_temperature_step(self):
"""Return the supported step of target temperature."""
return self.device.setpoint_shift_step

@property
def target_temperature(self):
"""Return the temperature we try to reach."""
return self.device.target_temperature_comfort
return self.device.target_temperature.value

@property
def target_temperature_high(self):
"""Return the highbound target temperature we try to reach."""
if self.device.target_temperature_comfort:
return max(
self.device.target_temperature_comfort,
self.device.target_temperature.value)
return None
def min_temp(self):
"""Return the minimum temperature."""
return self.device.target_temperature_min

@property
def target_temperature_low(self):
"""Return the lowbound target temperature we try to reach."""
if self.device.target_temperature_comfort:
return min(
self.device.target_temperature_comfort,
self.device.target_temperature.value)
return None
def max_temp(self):
"""Return the maximum temperature."""
return self.device.target_temperature_max

@asyncio.coroutine
def async_set_temperature(self, **kwargs):
"""Set new target temperature."""
temperature = kwargs.get(ATTR_TEMPERATURE)
if temperature is None:
return
yield from self.device.set_target_temperature_comfort(temperature)
yield from self.device.set_target_temperature(temperature)
yield from self.async_update_ha_state()

@property
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/knx.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

_LOGGER = logging.getLogger(__name__)

REQUIREMENTS = ['xknx==0.7.16']
REQUIREMENTS = ['xknx==0.7.18']

TUNNELING_SCHEMA = vol.Schema({
vol.Required(CONF_HOST): cv.string,
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ xbee-helper==0.0.7
xboxapi==0.1.1

# homeassistant.components.knx
xknx==0.7.16
xknx==0.7.18

# homeassistant.components.media_player.bluesound
# homeassistant.components.sensor.swiss_hydrological_data
Expand Down

0 comments on commit ee26539

Please sign in to comment.