Add services
This commit is contained in:
parent
87581e4654
commit
028760d8d8
5 changed files with 301 additions and 5 deletions
|
@ -1,12 +1,13 @@
|
|||
"""The Renson integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
from renson_endura_delta.renson import RensonVentilation
|
||||
from renson_endura_delta.renson import ManualLevel, RensonVentilation, TimerLevel
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.core import HomeAssistant, ServiceCall
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
@ -37,3 +38,84 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
hass.data[DOMAIN].pop(entry.entry_id)
|
||||
|
||||
return unload_ok
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the Renson platforms."""
|
||||
|
||||
host = hass.config_entries.async_entries(DOMAIN)[0].data[CONF_HOST]
|
||||
renson_api = RensonVentilation(host)
|
||||
|
||||
async def set_timer_level(call: ServiceCall) -> None:
|
||||
"""Set timer level."""
|
||||
level_string = call.data.get("timer_level", "Level1")
|
||||
time = call.data.get("time", 0)
|
||||
level = TimerLevel[level_string.upper()]
|
||||
|
||||
await hass.async_add_executor_job(renson_api.set_timer_level, level, time)
|
||||
|
||||
async def sync_time(call: ServiceCall) -> None:
|
||||
"""Sync time of device."""
|
||||
await hass.async_add_executor_job(renson_api.sync_time)
|
||||
|
||||
async def set_manual_level(call: ServiceCall) -> None:
|
||||
"""Set manual level."""
|
||||
level_string = call.data.get("manual_level", "Off")
|
||||
level = ManualLevel[level_string.upper()]
|
||||
|
||||
await hass.async_add_executor_job(renson_api.set_manual_level, level)
|
||||
|
||||
async def set_breeze(call: ServiceCall) -> None:
|
||||
"""Configure breeze feature."""
|
||||
level = call.data.get("breeze_level", "")
|
||||
temperature = call.data.get("temperature", 0)
|
||||
activated = call.data.get("activate", False)
|
||||
|
||||
await hass.async_add_executor_job(
|
||||
renson_api.set_breeze, level, temperature, activated
|
||||
)
|
||||
|
||||
async def set_day_night_time(call: ServiceCall) -> None:
|
||||
"""Configure day night times."""
|
||||
day = call.data.get("day", "7:00")
|
||||
night = call.data.get("night", "22:00")
|
||||
|
||||
await hass.async_add_executor_job(renson_api.set_time, day, night)
|
||||
|
||||
async def set_pollution_settings(call: ServiceCall) -> None:
|
||||
"""Configure pollutions settings."""
|
||||
day = call.data.get("day_pollution_level", "")
|
||||
night = call.data.get("night_pollution_level", "")
|
||||
humidity_control = call.data.get("humidity_control", "")
|
||||
airquality_control = call.data.get("airquality_control", "")
|
||||
co2_control = call.data.get("co2_control", "")
|
||||
co2_threshold = call.data.get("co2_threshold", 0)
|
||||
co2_hysteresis = call.data.get("co2_hysteresis", 0)
|
||||
|
||||
await renson_api.set_pollution(
|
||||
day,
|
||||
night,
|
||||
humidity_control,
|
||||
airquality_control,
|
||||
co2_control,
|
||||
co2_threshold,
|
||||
co2_hysteresis,
|
||||
)
|
||||
|
||||
async def set_filter_days(call: ServiceCall) -> None:
|
||||
"""Set filter dayes."""
|
||||
days = call.data.get("days", 90)
|
||||
|
||||
await hass.async_add_executor_job(renson_api.set_filter_days, days)
|
||||
|
||||
hass.services.async_register(DOMAIN, "set_manual_level", set_manual_level)
|
||||
hass.services.async_register(DOMAIN, "set_breeze", set_breeze)
|
||||
hass.services.async_register(DOMAIN, "set_day_night_time", set_day_night_time)
|
||||
hass.services.async_register(
|
||||
DOMAIN, "set_pollution_settings", set_pollution_settings
|
||||
)
|
||||
hass.services.async_register(DOMAIN, "set_filter_days", set_filter_days)
|
||||
hass.services.async_register(DOMAIN, "set_timer_level", set_timer_level)
|
||||
hass.services.async_register(DOMAIN, "sync_time", sync_time)
|
||||
|
||||
return True
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "Renson",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/renson",
|
||||
"requirements": ["renson-endura-delta==1.3.2"],
|
||||
"requirements": ["renson-endura-delta==1.3.3"],
|
||||
"dependencies": [],
|
||||
"codeowners": ["@jimmyd-be"],
|
||||
"iot_class": "local_polling"
|
||||
|
|
214
homeassistant/components/renson/services.yaml
Normal file
214
homeassistant/components/renson/services.yaml
Normal file
|
@ -0,0 +1,214 @@
|
|||
set_manual_level:
|
||||
name: Set Manual Level
|
||||
description: Sets manual level
|
||||
fields:
|
||||
manual_level:
|
||||
name: Manual level
|
||||
description: Manual level setting
|
||||
required: true
|
||||
advanced: false
|
||||
default: "Off"
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- "Off"
|
||||
- "Level1"
|
||||
- "Level2"
|
||||
- "Level3"
|
||||
- "Level4"
|
||||
|
||||
sync_time:
|
||||
name: Synchronize time and date
|
||||
description: Synchronize time and date with device
|
||||
|
||||
set_timer_level:
|
||||
name: Set timer
|
||||
description: Set the ventilation timer
|
||||
fields:
|
||||
timer_level:
|
||||
name: Level
|
||||
description: Level setting
|
||||
required: true
|
||||
advanced: false
|
||||
default: "Level1"
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- "Level1"
|
||||
- "Level2"
|
||||
- "Level3"
|
||||
- "Level4"
|
||||
- "Holiday"
|
||||
- "Breeze"
|
||||
time:
|
||||
name: Time
|
||||
description: Time of the timer (0 will disable the timer)
|
||||
required: true
|
||||
advanced: false
|
||||
default: 0
|
||||
selector:
|
||||
number:
|
||||
min: 0
|
||||
max: 1440
|
||||
step: 10
|
||||
unit_of_measurement: "min"
|
||||
mode: slider
|
||||
|
||||
set_breeze:
|
||||
name: Set breeze
|
||||
description: Set the breeze function of the ventilation system
|
||||
fields:
|
||||
breeze_level:
|
||||
name: Level
|
||||
description: Ventilation level when breeze function is activated
|
||||
required: false
|
||||
advanced: false
|
||||
default: "Level3"
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- "Level1"
|
||||
- "Level2"
|
||||
- "Level3"
|
||||
- "Level4"
|
||||
temperature:
|
||||
name: Temperature
|
||||
description: Temperature when the breeze function should be activated
|
||||
required: false
|
||||
advanced: false
|
||||
default: 18
|
||||
selector:
|
||||
number:
|
||||
min: 15
|
||||
max: 35
|
||||
step: 1
|
||||
unit_of_measurement: "°C"
|
||||
mode: slider
|
||||
activate:
|
||||
name: Activate
|
||||
description: Activate or disable the breeze feature
|
||||
required: true
|
||||
advanced: false
|
||||
default: false
|
||||
selector:
|
||||
boolean:
|
||||
|
||||
set_day_night_time:
|
||||
name: Set day and night time
|
||||
description: Set the day and night time of the system
|
||||
fields:
|
||||
day:
|
||||
name: Start day
|
||||
description: Start time of the day
|
||||
required: true
|
||||
advanced: false
|
||||
default: false
|
||||
selector:
|
||||
time:
|
||||
night:
|
||||
name: Start night
|
||||
description: Start time of the night
|
||||
required: true
|
||||
advanced: false
|
||||
default: false
|
||||
selector:
|
||||
time:
|
||||
|
||||
set_pollution_settings:
|
||||
name: Set pollution settings
|
||||
description: Set all the pollution settings of the ventilation system
|
||||
fields:
|
||||
day_pollution_level:
|
||||
name: Day pollution Level
|
||||
description: Ventilation level when pollution is detected in the day
|
||||
required: false
|
||||
advanced: false
|
||||
default: "Level3"
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- "Level1"
|
||||
- "Level2"
|
||||
- "Level3"
|
||||
- "Level4"
|
||||
night_pollution_level:
|
||||
name: Night pollution Level
|
||||
description: Ventilation level when pollution is detected in the night
|
||||
required: false
|
||||
advanced: false
|
||||
default: "Level2"
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- "Level1"
|
||||
- "Level2"
|
||||
- "Level3"
|
||||
- "Level4"
|
||||
humidity_control:
|
||||
name: Enable humidity control
|
||||
description: Activate or disable the humidity control
|
||||
required: false
|
||||
advanced: false
|
||||
default: true
|
||||
selector:
|
||||
boolean:
|
||||
airquality_control:
|
||||
name: Enable air quality control
|
||||
description: Activate or disable the air quality control
|
||||
required: false
|
||||
advanced: false
|
||||
default: true
|
||||
selector:
|
||||
boolean:
|
||||
co2_control:
|
||||
name: Enable CO2 control
|
||||
description: Activate or disable the CO2 control
|
||||
required: false
|
||||
advanced: false
|
||||
default: true
|
||||
selector:
|
||||
boolean:
|
||||
co2_threshold:
|
||||
name: co2 threshold
|
||||
description: Sets the CO2 pollution threshold level in ppm
|
||||
required: false
|
||||
advanced: false
|
||||
default: 600
|
||||
selector:
|
||||
number:
|
||||
min: 400
|
||||
max: 2000
|
||||
step: 50
|
||||
unit_of_measurement: "ppm"
|
||||
mode: slider
|
||||
co2_hysteresis:
|
||||
name: co2 hysteresis
|
||||
description: Sets the CO2 pollution threshold hysteresis level in ppm
|
||||
required: false
|
||||
advanced: false
|
||||
default: 100
|
||||
selector:
|
||||
number:
|
||||
min: 50
|
||||
max: 400
|
||||
step: 50
|
||||
unit_of_measurement: "ppm"
|
||||
mode: slider
|
||||
|
||||
set_filter_days:
|
||||
name: Set filter days
|
||||
description: Indicates the recommended filter remaining time in case of filter change, in days
|
||||
fields:
|
||||
days:
|
||||
name: Days
|
||||
description: Indicates the recommended filter remaining time in case of filter change, in days
|
||||
required: true
|
||||
advanced: false
|
||||
default: 90
|
||||
selector:
|
||||
number:
|
||||
min: 0
|
||||
max: 360
|
||||
step: 1
|
||||
unit_of_measurement: "days"
|
||||
mode: slider
|
|
@ -2100,7 +2100,7 @@ regenmaschine==2022.08.0
|
|||
renault-api==0.1.11
|
||||
|
||||
# homeassistant.components.renson
|
||||
renson-endura-delta==1.3.2
|
||||
renson-endura-delta==1.3.3
|
||||
|
||||
# homeassistant.components.python_script
|
||||
restrictedpython==5.2
|
||||
|
|
|
@ -1436,7 +1436,7 @@ regenmaschine==2022.08.0
|
|||
renault-api==0.1.11
|
||||
|
||||
# homeassistant.components.renson
|
||||
renson-endura-delta==1.3.2
|
||||
renson-endura-delta==1.3.3
|
||||
|
||||
# homeassistant.components.python_script
|
||||
restrictedpython==5.2
|
||||
|
|
Loading…
Add table
Reference in a new issue