Add services for izone airflow min/max (#45727)
* Create airflow_min and airflow_max services for the izone component * Bump pizone library requirement
This commit is contained in:
parent
6b9abfc2c6
commit
027d125617
5 changed files with 83 additions and 3 deletions
|
@ -1,8 +1,10 @@
|
|||
"""Support for the iZone HVAC."""
|
||||
|
||||
import logging
|
||||
from typing import List, Optional
|
||||
|
||||
from pizone import Controller, Zone
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate.const import (
|
||||
|
@ -24,12 +26,14 @@ from homeassistant.components.climate.const import (
|
|||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
CONF_ENTITY_ID,
|
||||
CONF_EXCLUDE,
|
||||
PRECISION_HALVES,
|
||||
PRECISION_TENTHS,
|
||||
TEMP_CELSIUS,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.temperature import display_temp as show_temp
|
||||
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
|
||||
|
@ -54,6 +58,20 @@ _IZONE_FAN_TO_HA = {
|
|||
Controller.Fan.AUTO: FAN_AUTO,
|
||||
}
|
||||
|
||||
ATTR_AIRFLOW = "airflow"
|
||||
|
||||
IZONE_SERVICE_AIRFLOW_MIN = "airflow_min"
|
||||
IZONE_SERVICE_AIRFLOW_MAX = "airflow_max"
|
||||
|
||||
IZONE_SERVICE_AIRFLOW_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_ENTITY_ID): cv.entity_id,
|
||||
vol.Required(ATTR_AIRFLOW): vol.All(
|
||||
vol.Coerce(int), vol.Range(min=0, max=100), msg="invalid airflow"
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistantType, config: ConfigType, async_add_entities
|
||||
|
@ -83,6 +101,18 @@ async def async_setup_entry(
|
|||
# connect to register any further components
|
||||
async_dispatcher_connect(hass, DISPATCH_CONTROLLER_DISCOVERED, init_controller)
|
||||
|
||||
platform = entity_platform.current_platform.get()
|
||||
platform.async_register_entity_service(
|
||||
IZONE_SERVICE_AIRFLOW_MIN,
|
||||
IZONE_SERVICE_AIRFLOW_SCHEMA,
|
||||
"async_set_airflow_min",
|
||||
)
|
||||
platform.async_register_entity_service(
|
||||
IZONE_SERVICE_AIRFLOW_MAX,
|
||||
IZONE_SERVICE_AIRFLOW_SCHEMA,
|
||||
"async_set_airflow_max",
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
@ -572,6 +602,38 @@ class ZoneDevice(ClimateEntity):
|
|||
"""Return the maximum temperature."""
|
||||
return self._controller.max_temp
|
||||
|
||||
@property
|
||||
def airflow_min(self):
|
||||
"""Return the minimum air flow."""
|
||||
return self._zone.airflow_min
|
||||
|
||||
@property
|
||||
def airflow_max(self):
|
||||
"""Return the maximum air flow."""
|
||||
return self._zone.airflow_max
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the optional state attributes."""
|
||||
return {
|
||||
"airflow_min": self._zone.airflow_min,
|
||||
"airflow_max": self._zone.airflow_max,
|
||||
}
|
||||
|
||||
async def async_set_airflow_min(self, **kwargs):
|
||||
"""Set new airflow minimum."""
|
||||
await self._controller.wrap_and_catch(
|
||||
self._zone.set_airflow_min(int(kwargs[ATTR_AIRFLOW]))
|
||||
)
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_airflow_max(self, **kwargs):
|
||||
"""Set new airflow maximum."""
|
||||
await self._controller.wrap_and_catch(
|
||||
self._zone.set_airflow_max(int(kwargs[ATTR_AIRFLOW]))
|
||||
)
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_temperature(self, **kwargs):
|
||||
"""Set new target temperature."""
|
||||
if self._zone.mode != Zone.Mode.AUTO:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"domain": "izone",
|
||||
"name": "iZone",
|
||||
"documentation": "https://www.home-assistant.io/integrations/izone",
|
||||
"requirements": ["python-izone==1.1.3"],
|
||||
"requirements": ["python-izone==1.1.4"],
|
||||
"codeowners": ["@Swamp-Ig"],
|
||||
"config_flow": true,
|
||||
"homekit": {
|
||||
|
|
18
homeassistant/components/izone/services.yaml
Normal file
18
homeassistant/components/izone/services.yaml
Normal file
|
@ -0,0 +1,18 @@
|
|||
airflow_min:
|
||||
description: Set the airflow minimum percent for a zone
|
||||
fields:
|
||||
entity_id:
|
||||
description: iZone Zone entity
|
||||
example: "climate.bed_1"
|
||||
airflow:
|
||||
description: Airflow percent in 5% increments
|
||||
example: "95"
|
||||
airflow_max:
|
||||
description: Set the airflow maximum percent for a zone
|
||||
fields:
|
||||
entity_id:
|
||||
description: iZone Zone entity
|
||||
example: "climate.bed_1"
|
||||
airflow:
|
||||
description: Airflow percent in 5% increments
|
||||
example: "95"
|
|
@ -1784,7 +1784,7 @@ python-gitlab==1.6.0
|
|||
python-hpilo==4.3
|
||||
|
||||
# homeassistant.components.izone
|
||||
python-izone==1.1.3
|
||||
python-izone==1.1.4
|
||||
|
||||
# homeassistant.components.joaoapps_join
|
||||
python-join-api==0.0.6
|
||||
|
|
|
@ -930,7 +930,7 @@ python-ecobee-api==0.2.10
|
|||
python-forecastio==1.4.0
|
||||
|
||||
# homeassistant.components.izone
|
||||
python-izone==1.1.3
|
||||
python-izone==1.1.4
|
||||
|
||||
# homeassistant.components.juicenet
|
||||
python-juicenet==1.0.1
|
||||
|
|
Loading…
Add table
Reference in a new issue