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:
Nick Adams 2021-03-02 22:58:41 +10:00 committed by GitHub
parent 6b9abfc2c6
commit 027d125617
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 3 deletions

View File

@ -1,8 +1,10 @@
"""Support for the iZone HVAC.""" """Support for the iZone HVAC."""
import logging import logging
from typing import List, Optional from typing import List, Optional
from pizone import Controller, Zone from pizone import Controller, Zone
import voluptuous as vol
from homeassistant.components.climate import ClimateEntity from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate.const import ( from homeassistant.components.climate.const import (
@ -24,12 +26,14 @@ from homeassistant.components.climate.const import (
) )
from homeassistant.const import ( from homeassistant.const import (
ATTR_TEMPERATURE, ATTR_TEMPERATURE,
CONF_ENTITY_ID,
CONF_EXCLUDE, CONF_EXCLUDE,
PRECISION_HALVES, PRECISION_HALVES,
PRECISION_TENTHS, PRECISION_TENTHS,
TEMP_CELSIUS, TEMP_CELSIUS,
) )
from homeassistant.core import callback 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.dispatcher import async_dispatcher_connect
from homeassistant.helpers.temperature import display_temp as show_temp from homeassistant.helpers.temperature import display_temp as show_temp
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType, HomeAssistantType
@ -54,6 +58,20 @@ _IZONE_FAN_TO_HA = {
Controller.Fan.AUTO: FAN_AUTO, 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( async def async_setup_entry(
hass: HomeAssistantType, config: ConfigType, async_add_entities hass: HomeAssistantType, config: ConfigType, async_add_entities
@ -83,6 +101,18 @@ async def async_setup_entry(
# connect to register any further components # connect to register any further components
async_dispatcher_connect(hass, DISPATCH_CONTROLLER_DISCOVERED, init_controller) 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 return True
@ -572,6 +602,38 @@ class ZoneDevice(ClimateEntity):
"""Return the maximum temperature.""" """Return the maximum temperature."""
return self._controller.max_temp 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): async def async_set_temperature(self, **kwargs):
"""Set new target temperature.""" """Set new target temperature."""
if self._zone.mode != Zone.Mode.AUTO: if self._zone.mode != Zone.Mode.AUTO:

View File

@ -2,7 +2,7 @@
"domain": "izone", "domain": "izone",
"name": "iZone", "name": "iZone",
"documentation": "https://www.home-assistant.io/integrations/izone", "documentation": "https://www.home-assistant.io/integrations/izone",
"requirements": ["python-izone==1.1.3"], "requirements": ["python-izone==1.1.4"],
"codeowners": ["@Swamp-Ig"], "codeowners": ["@Swamp-Ig"],
"config_flow": true, "config_flow": true,
"homekit": { "homekit": {

View 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"

View File

@ -1784,7 +1784,7 @@ python-gitlab==1.6.0
python-hpilo==4.3 python-hpilo==4.3
# homeassistant.components.izone # homeassistant.components.izone
python-izone==1.1.3 python-izone==1.1.4
# homeassistant.components.joaoapps_join # homeassistant.components.joaoapps_join
python-join-api==0.0.6 python-join-api==0.0.6

View File

@ -930,7 +930,7 @@ python-ecobee-api==0.2.10
python-forecastio==1.4.0 python-forecastio==1.4.0
# homeassistant.components.izone # homeassistant.components.izone
python-izone==1.1.3 python-izone==1.1.4
# homeassistant.components.juicenet # homeassistant.components.juicenet
python-juicenet==1.0.1 python-juicenet==1.0.1