diff --git a/homeassistant/components/hive/climate.py b/homeassistant/components/hive/climate.py index e6da78d921c..d5b60fa4b95 100644 --- a/homeassistant/components/hive/climate.py +++ b/homeassistant/components/hive/climate.py @@ -1,5 +1,6 @@ """Support for the Hive climate devices.""" from datetime import timedelta +import logging import voluptuous as vol @@ -20,7 +21,12 @@ from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.helpers import config_validation as cv, entity_platform from . import HiveEntity, refresh_system -from .const import ATTR_TIME_PERIOD, DOMAIN, SERVICE_BOOST_HEATING +from .const import ( + ATTR_TIME_PERIOD, + DOMAIN, + SERVICE_BOOST_HEATING_OFF, + SERVICE_BOOST_HEATING_ON, +) HIVE_TO_HASS_STATE = { "SCHEDULE": HVAC_MODE_AUTO, @@ -47,6 +53,7 @@ SUPPORT_HVAC = [HVAC_MODE_AUTO, HVAC_MODE_HEAT, HVAC_MODE_OFF] SUPPORT_PRESET = [PRESET_NONE, PRESET_BOOST] PARALLEL_UPDATES = 0 SCAN_INTERVAL = timedelta(seconds=15) +_LOGGER = logging.getLogger() async def async_setup_entry(hass, entry, async_add_entities): @@ -63,7 +70,7 @@ async def async_setup_entry(hass, entry, async_add_entities): platform = entity_platform.current_platform.get() platform.async_register_entity_service( - SERVICE_BOOST_HEATING, + "boost_heating", { vol.Required(ATTR_TIME_PERIOD): vol.All( cv.time_period, @@ -75,6 +82,25 @@ async def async_setup_entry(hass, entry, async_add_entities): "async_heating_boost", ) + platform.async_register_entity_service( + SERVICE_BOOST_HEATING_ON, + { + vol.Required(ATTR_TIME_PERIOD): vol.All( + cv.time_period, + cv.positive_timedelta, + lambda td: td.total_seconds() // 60, + ), + vol.Optional(ATTR_TEMPERATURE, default="25.0"): vol.Coerce(float), + }, + "async_heating_boost_on", + ) + + platform.async_register_entity_service( + SERVICE_BOOST_HEATING_OFF, + {}, + "async_heating_boost_off", + ) + class HiveClimateEntity(HiveEntity, ClimateEntity): """Hive Climate Device.""" @@ -198,11 +224,23 @@ class HiveClimateEntity(HiveEntity, ClimateEntity): temperature = curtemp + 0.5 await self.hive.heating.setBoostOn(self.device, 30, temperature) - @refresh_system async def async_heating_boost(self, time_period, temperature): + """Handle boost heating service call.""" + _LOGGER.warning( + "Hive Service heating_boost will be removed in 2021.7.0, please update to heating_boost_on" + ) + await self.async_heating_boost_on(time_period, temperature) + + @refresh_system + async def async_heating_boost_on(self, time_period, temperature): """Handle boost heating service call.""" await self.hive.heating.setBoostOn(self.device, time_period, temperature) + @refresh_system + async def async_heating_boost_off(self): + """Handle boost heating service call.""" + await self.hive.heating.setBoostOff(self.device) + async def async_update(self): """Update all Node data from Hive.""" await self.hive.session.updateData(self.device) diff --git a/homeassistant/components/hive/const.py b/homeassistant/components/hive/const.py index ea416fbfe32..9e1d7fc1f80 100644 --- a/homeassistant/components/hive/const.py +++ b/homeassistant/components/hive/const.py @@ -16,5 +16,6 @@ PLATFORM_LOOKUP = { "water_heater": "water_heater", } SERVICE_BOOST_HOT_WATER = "boost_hot_water" -SERVICE_BOOST_HEATING = "boost_heating" +SERVICE_BOOST_HEATING_ON = "boost_heating_on" +SERVICE_BOOST_HEATING_OFF = "boost_heating_off" WATER_HEATER_MODES = ["on", "off"] diff --git a/homeassistant/components/hive/services.yaml b/homeassistant/components/hive/services.yaml index f029af7b0b5..de1439eead4 100644 --- a/homeassistant/components/hive/services.yaml +++ b/homeassistant/components/hive/services.yaml @@ -1,5 +1,24 @@ boost_heating: - name: Boost Heating + name: Boost Heating (To be deprecated) + description: To be deprecated please use boost_heating_on. + fields: + entity_id: + name: Entity ID + description: Select entity_id to boost. + required: true + example: climate.heating + time_period: + name: Time Period + description: Set the time period for the boost. + required: true + example: 01:30:00 + temperature: + name: Temperature + description: Set the target temperature for the boost period. + required: true + example: 20.5 +boost_heating_on: + name: Boost Heating On description: Set the boost mode ON defining the period of time and the desired target temperature for the boost. fields: entity_id: @@ -30,6 +49,19 @@ boost_heating: step: 0.5 unit_of_measurement: degrees mode: slider +boost_heating_off: + name: Boost Heating Off + description: Set the boost mode OFF. + fields: + entity_id: + name: Entity ID + description: Select entity_id to turn boost off. + required: true + example: climate.heating + selector: + entity: + integration: hive + domain: climate boost_hot_water: name: Boost Hotwater description: Set the boost mode ON or OFF defining the period of time for the boost.