Hive Component Release Two (#11053)

* Add boost functionality to climate devices

* Update boost target temperature rounding

* Update with Colour Bulb Support

* colour bulb fix

* Requirements Update and colorsys import

* Add RGB Attribute - ATTR_RGB_COLOR

* Hive release-2

* add boost support for hive climate platform

* Colour Bulb - Varible update

* Boost - Tox error

* Convert colour to color

* Correct over indentation

* update version to 0.2.9 pyhiveapi

* Updated pyhiveapi to version 2.10 and altertered turn_n on fuction to 1 call

* Update climate doc string

* Update to is_aux_heat_on

* update to is_aux_heat_on
This commit is contained in:
Khole 2017-12-18 17:15:41 +00:00 committed by Martin Hjelmare
parent 8742ce035a
commit 05258ea4bf
4 changed files with 69 additions and 15 deletions

View file

@ -6,7 +6,7 @@ https://home-assistant.io/components/climate.hive/
"""
from homeassistant.components.climate import (
ClimateDevice, STATE_AUTO, STATE_HEAT, STATE_OFF, STATE_ON,
SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE)
SUPPORT_AUX_HEAT, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE)
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
from homeassistant.components.hive import DATA_HIVE
@ -16,7 +16,9 @@ HIVE_TO_HASS_STATE = {'SCHEDULE': STATE_AUTO, 'MANUAL': STATE_HEAT,
HASS_TO_HIVE_STATE = {STATE_AUTO: 'SCHEDULE', STATE_HEAT: 'MANUAL',
STATE_ON: 'ON', STATE_OFF: 'OFF'}
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE
SUPPORT_FLAGS = (SUPPORT_TARGET_TEMPERATURE |
SUPPORT_OPERATION_MODE |
SUPPORT_AUX_HEAT)
def setup_platform(hass, config, add_devices, discovery_info=None):
@ -134,6 +136,43 @@ class HiveClimateEntity(ClimateDevice):
for entity in self.session.entities:
entity.handle_update(self.data_updatesource)
@property
def is_aux_heat_on(self):
"""Return true if auxiliary heater is on."""
boost_status = None
if self.device_type == "Heating":
boost_status = self.session.heating.get_boost(self.node_id)
elif self.device_type == "HotWater":
boost_status = self.session.hotwater.get_boost(self.node_id)
return boost_status == "ON"
def turn_aux_heat_on(self):
"""Turn auxiliary heater on."""
target_boost_time = 30
if self.device_type == "Heating":
curtemp = self.session.heating.current_temperature(self.node_id)
curtemp = round(curtemp * 2) / 2
target_boost_temperature = curtemp + 0.5
self.session.heating.turn_boost_on(self.node_id,
target_boost_time,
target_boost_temperature)
elif self.device_type == "HotWater":
self.session.hotwater.turn_boost_on(self.node_id,
target_boost_time)
for entity in self.session.entities:
entity.handle_update(self.data_updatesource)
def turn_aux_heat_off(self):
"""Turn auxiliary heater off."""
if self.device_type == "Heating":
self.session.heating.turn_boost_off(self.node_id)
elif self.device_type == "HotWater":
self.session.hotwater.turn_boost_off(self.node_id)
for entity in self.session.entities:
entity.handle_update(self.data_updatesource)
def update(self):
"""Update all Node data frome Hive."""
self.session.core.update_data(self.node_id)

View file

@ -12,7 +12,7 @@ from homeassistant.const import (CONF_PASSWORD, CONF_SCAN_INTERVAL,
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.discovery import load_platform
REQUIREMENTS = ['pyhiveapi==0.2.5']
REQUIREMENTS = ['pyhiveapi==0.2.10']
_LOGGER = logging.getLogger(__name__)
DOMAIN = 'hive'

View file

@ -4,8 +4,10 @@ Support for the Hive devices.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.hive/
"""
import colorsys
from homeassistant.components.hive import DATA_HIVE
from homeassistant.components.light import (ATTR_BRIGHTNESS, ATTR_COLOR_TEMP,
ATTR_RGB_COLOR,
SUPPORT_BRIGHTNESS,
SUPPORT_COLOR_TEMP,
SUPPORT_RGB_COLOR, Light)
@ -46,19 +48,24 @@ class HiveDeviceLight(Light):
"""Return the display name of this light."""
return self.node_name
@property
def brightness(self):
"""Brightness of the light (an integer in the range 1-255)."""
return self.session.light.get_brightness(self.node_id)
@property
def min_mireds(self):
"""Return the coldest color_temp that this light supports."""
if self.light_device_type == "tuneablelight" \
or self.light_device_type == "colourtuneablelight":
return self.session.light.get_min_colour_temp(self.node_id)
return self.session.light.get_min_color_temp(self.node_id)
@property
def max_mireds(self):
"""Return the warmest color_temp that this light supports."""
if self.light_device_type == "tuneablelight" \
or self.light_device_type == "colourtuneablelight":
return self.session.light.get_max_colour_temp(self.node_id)
return self.session.light.get_max_color_temp(self.node_id)
@property
def color_temp(self):
@ -68,9 +75,10 @@ class HiveDeviceLight(Light):
return self.session.light.get_color_temp(self.node_id)
@property
def brightness(self):
"""Brightness of the light (an integer in the range 1-255)."""
return self.session.light.get_brightness(self.node_id)
def rgb_color(self) -> tuple:
"""Return the RBG color value."""
if self.light_device_type == "colourtuneablelight":
return self.session.light.get_color(self.node_id)
@property
def is_on(self):
@ -81,6 +89,7 @@ class HiveDeviceLight(Light):
"""Instruct the light to turn on."""
new_brightness = None
new_color_temp = None
new_color = None
if ATTR_BRIGHTNESS in kwargs:
tmp_new_brightness = kwargs.get(ATTR_BRIGHTNESS)
percentage_brightness = ((tmp_new_brightness / 255) * 100)
@ -90,13 +99,19 @@ class HiveDeviceLight(Light):
if ATTR_COLOR_TEMP in kwargs:
tmp_new_color_temp = kwargs.get(ATTR_COLOR_TEMP)
new_color_temp = round(1000000 / tmp_new_color_temp)
if ATTR_RGB_COLOR in kwargs:
get_new_color = kwargs.get(ATTR_RGB_COLOR)
tmp_new_color = colorsys.rgb_to_hsv(get_new_color[0],
get_new_color[1],
get_new_color[2])
hue = int(round(tmp_new_color[0] * 360))
saturation = int(round(tmp_new_color[1] * 100))
value = int(round((tmp_new_color[2] / 255) * 100))
new_color = (hue, saturation, value)
if new_brightness is not None:
self.session.light.set_brightness(self.node_id, new_brightness)
elif new_color_temp is not None:
self.session.light.set_colour_temp(self.node_id, new_color_temp)
else:
self.session.light.turn_on(self.node_id)
self.session.light.turn_on(self.node_id, self.light_device_type,
new_brightness, new_color_temp,
new_color)
for entity in self.session.entities:
entity.handle_update(self.data_updatesource)

View file

@ -692,7 +692,7 @@ pyharmony==1.0.18
pyhik==0.1.4
# homeassistant.components.hive
pyhiveapi==0.2.5
pyhiveapi==0.2.10
# homeassistant.components.homematic
pyhomematic==0.1.36