Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
fan.py
Go to the documentation of this file.
1## @file
2## @brief ESPHome fan platform schema and code generation (exterior heating).
3## @ingroup hioc_codegen
4##
5## Defines the experimental IO-Homecontrol exterior-heating integration (a heat level as a fan speed)
6## and wires it to the shared hub. Shared device-binding logic lives in platform_common.py; only
7## fan-specific entity construction/registration stays here.
8
9import esphome.codegen as cg
10import esphome.config_validation as cv
11from esphome.components import fan
12from esphome.const import CONF_ID
13
14from . import home_io_control_ns
15from .platform_common import (
16 create_companion_sensors,
17 inject_companion_sensor_ids,
18 platform_schema_extension,
19 wire_device_binding,
20 CONF_HOME_IO_CONTROL_ID,
21)
22
23DEPENDENCIES = ["home_io_control"]
24
25IOHomeFan = home_io_control_ns.class_("IOHomeFan", fan.Fan, cg.Component)
26
27
29 return inject_companion_sensor_ids(config, CONF_ID)
30
31
32# The entity never restores a saved state: a restored command would be sent to the heater at boot
33# (the same trap the light platform guards against), and the first status poll is the truth.
34CONFIG_SCHEMA = cv.All(
35 fan.fan_schema(IOHomeFan, default_restore_mode="NO_RESTORE")
36 .extend(platform_schema_extension())
37 .extend(cv.COMPONENT_SCHEMA),
38 _inject_companion_ids,
39)
40
41
42async def to_code(config):
43 var = await fan.new_fan(config)
44 await cg.register_component(var, config)
45
46 parent = await cg.get_variable(config[CONF_HOME_IO_CONTROL_ID])
47 await wire_device_binding(var, parent, config)
48 await create_companion_sensors(config, parent)
to_code(config)
Definition fan.py:42
_inject_companion_ids(config)
Definition fan.py:28