mirror of
https://github.com/home-assistant/core.git
synced 2026-12-05 21:29:58 -04:00
Move renson service registration to services module (#184604)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
de68f036d6
commit
e07df2a291
@@ -5,8 +5,12 @@ from renson_endura_delta.renson import RensonVentilation
|
||||
from homeassistant.const import CONF_HOST, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import RensonConfigEntry, RensonCoordinator, RensonData
|
||||
from .services import async_setup_services
|
||||
|
||||
PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
@@ -19,6 +23,15 @@ PLATFORMS = [
|
||||
]
|
||||
|
||||
|
||||
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the Renson integration."""
|
||||
async_setup_services(hass)
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: RensonConfigEntry) -> bool:
|
||||
"""Set up Renson from a config entry."""
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import logging
|
||||
import math
|
||||
from typing import Any, override
|
||||
|
||||
import probatio
|
||||
from renson_endura_delta.field_enum import (
|
||||
BREEZE_LEVEL_FIELD,
|
||||
BREEZE_TEMPERATURE_FIELD,
|
||||
@@ -15,9 +14,7 @@ from renson_endura_delta.renson import Level, RensonVentilation
|
||||
|
||||
from homeassistant.components.fan import FanEntity, FanEntityFeature
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.helpers.typing import VolDictType
|
||||
from homeassistant.util.percentage import (
|
||||
percentage_to_ranged_value,
|
||||
ranged_value_to_percentage,
|
||||
@@ -47,35 +44,6 @@ SPEED_MAPPING = {
|
||||
Level.LEVEL4.value: 4,
|
||||
}
|
||||
|
||||
SET_TIMER_LEVEL_SCHEMA: VolDictType = {
|
||||
probatio.Required("timer_level"): probatio.In(
|
||||
["level1", "level2", "level3", "level4", "holiday", "breeze"]
|
||||
),
|
||||
probatio.Required("minutes"): cv.positive_int,
|
||||
}
|
||||
|
||||
SET_BREEZE_SCHEMA: VolDictType = {
|
||||
probatio.Required("breeze_level"): probatio.In(
|
||||
["level1", "level2", "level3", "level4"]
|
||||
),
|
||||
probatio.Required("temperature"): cv.positive_int,
|
||||
probatio.Required("activate"): bool,
|
||||
}
|
||||
|
||||
SET_POLLUTION_SETTINGS_SCHEMA: VolDictType = {
|
||||
probatio.Required("day_pollution_level"): probatio.In(
|
||||
["level1", "level2", "level3", "level4"]
|
||||
),
|
||||
probatio.Required("night_pollution_level"): probatio.In(
|
||||
["level1", "level2", "level3", "level4"]
|
||||
),
|
||||
probatio.Optional("humidity_control", default=True): bool,
|
||||
probatio.Optional("airquality_control", default=True): bool,
|
||||
probatio.Optional("co2_control", default=True): bool,
|
||||
probatio.Optional("co2_threshold", default=600): cv.positive_int,
|
||||
probatio.Optional("co2_hysteresis", default=100): cv.positive_int,
|
||||
}
|
||||
|
||||
|
||||
SPEED_RANGE: tuple[float, float] = (1, 4)
|
||||
|
||||
@@ -92,24 +60,6 @@ async def async_setup_entry(
|
||||
|
||||
async_add_entities([RensonFan(api, coordinator)])
|
||||
|
||||
platform = entity_platform.async_get_current_platform()
|
||||
|
||||
platform.async_register_entity_service(
|
||||
"set_timer_level",
|
||||
SET_TIMER_LEVEL_SCHEMA,
|
||||
"set_timer_level",
|
||||
)
|
||||
|
||||
platform.async_register_entity_service(
|
||||
"set_breeze", SET_BREEZE_SCHEMA, "set_breeze"
|
||||
)
|
||||
|
||||
platform.async_register_entity_service(
|
||||
"set_pollution_settings",
|
||||
SET_POLLUTION_SETTINGS_SCHEMA,
|
||||
"set_pollution_settings",
|
||||
)
|
||||
|
||||
|
||||
class RensonFan(RensonEntity, FanEntity):
|
||||
"""Representation of the Renson fan platform."""
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
"""Services for the Renson integration."""
|
||||
|
||||
import probatio
|
||||
|
||||
from homeassistant.components.fan import DOMAIN as FAN_DOMAIN
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import config_validation as cv, service
|
||||
from homeassistant.helpers.typing import VolDictType
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
SET_TIMER_LEVEL_SCHEMA: VolDictType = {
|
||||
probatio.Required("timer_level"): probatio.In(
|
||||
["level1", "level2", "level3", "level4", "holiday", "breeze"]
|
||||
),
|
||||
probatio.Required("minutes"): cv.positive_int,
|
||||
}
|
||||
SET_BREEZE_SCHEMA: VolDictType = {
|
||||
probatio.Required("breeze_level"): probatio.In(
|
||||
["level1", "level2", "level3", "level4"]
|
||||
),
|
||||
probatio.Required("temperature"): cv.positive_int,
|
||||
probatio.Required("activate"): bool,
|
||||
}
|
||||
SET_POLLUTION_SETTINGS_SCHEMA: VolDictType = {
|
||||
probatio.Required("day_pollution_level"): probatio.In(
|
||||
["level1", "level2", "level3", "level4"]
|
||||
),
|
||||
probatio.Required("night_pollution_level"): probatio.In(
|
||||
["level1", "level2", "level3", "level4"]
|
||||
),
|
||||
probatio.Optional("humidity_control", default=True): bool,
|
||||
probatio.Optional("airquality_control", default=True): bool,
|
||||
probatio.Optional("co2_control", default=True): bool,
|
||||
probatio.Optional("co2_threshold", default=600): cv.positive_int,
|
||||
probatio.Optional("co2_hysteresis", default=100): cv.positive_int,
|
||||
}
|
||||
|
||||
|
||||
@callback
|
||||
def async_setup_services(hass: HomeAssistant) -> None:
|
||||
"""Set up the services for the Renson integration."""
|
||||
|
||||
service.async_register_platform_entity_service(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"set_timer_level",
|
||||
entity_domain=FAN_DOMAIN,
|
||||
schema=SET_TIMER_LEVEL_SCHEMA,
|
||||
func="set_timer_level",
|
||||
)
|
||||
|
||||
service.async_register_platform_entity_service(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"set_breeze",
|
||||
entity_domain=FAN_DOMAIN,
|
||||
schema=SET_BREEZE_SCHEMA,
|
||||
func="set_breeze",
|
||||
)
|
||||
|
||||
service.async_register_platform_entity_service(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"set_pollution_settings",
|
||||
entity_domain=FAN_DOMAIN,
|
||||
schema=SET_POLLUTION_SETTINGS_SCHEMA,
|
||||
func="set_pollution_settings",
|
||||
)
|
||||
Reference in New Issue
Block a user