Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions homeassistant/components/hive/climate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Support for the Hive climate devices."""
from datetime import timedelta
import logging

import voluptuous as vol

Expand All @@ -20,7 +21,12 @@
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,
Expand All @@ -47,6 +53,7 @@
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):
Expand All @@ -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,
Expand All @@ -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."""
Expand Down Expand Up @@ -198,11 +224,23 @@ async def async_set_preset_mode(self, preset_mode):
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)
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/hive/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"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"]
34 changes: 33 additions & 1 deletion homeassistant/components/hive/services.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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.
Expand Down