44IOHomeCover = home_io_control_ns.class_(
"IOHomeCover", cover.Cover, cg.Component)
120 """Declare cover companion entity IDs during schema validation for StaticVector sizing.
122 The favorite and ventilation buttons are cover-only and gated on device capability, so
123 their injection stays here. The always-present companion sensor IDs are delegated to the
124 shared helper. See platform_common.companion_id_base() for the StaticVector rationale.
126 base = companion_id_base(config, CONF_ID)
130 config[CONF_DEVICE_TYPE]
132 config[CONF_FAVORITE_BUTTON_ID] = ID(
133 f
"{base}_favorite_button",
135 type=IOHomeCoverCommandButton,
140 config[CONF_VENT_BUTTON_ID] = ID(
141 f
"{base}_vent_button",
143 type=IOHomeCoverCommandButton,
149 if CONF_SILENT
in config:
150 config[CONF_SILENT_SWITCH_ID] = ID(
151 f
"{base}_silent_switch",
153 type=IOHomeCoverSilentSwitch,
157 return inject_companion_sensor_ids(config, CONF_ID)
172 var = await cover.new_cover(config)
173 await cg.register_component(var, config)
175 parent = await cg.get_variable(config[CONF_HOME_IO_CONTROL_ID])
176 await wire_device_binding(var, parent, config)
178 if CONF_INVERT_POSITION
in config:
179 cg.add(var.set_invert_position(config[CONF_INVERT_POSITION]))
181 cg.add(var.set_optimistic_state(config[CONF_OPTIMISTIC_STATE]))
182 if CONF_SILENT
in config:
183 cg.add(var.set_silent(config[CONF_SILENT]))
185 if CONF_SILENT_SWITCH_ID
in config:
191 silent_config = switch.switch_schema(
192 IOHomeCoverSilentSwitch,
193 default_restore_mode=
"DISABLED",
194 entity_category=ENTITY_CATEGORY_CONFIG,
195 ).extend(cv.COMPONENT_SCHEMA)(
196 inherit_esphome_device(
198 CONF_ID: config[CONF_SILENT_SWITCH_ID],
204 silent_switch = await switch.new_switch(silent_config)
205 await cg.register_component(silent_switch, silent_config)
206 cg.add(silent_switch.set_parent(parent))
207 cg.add(silent_switch.set_device_id(config[CONF_IO_DEVICE_ID]))
209 if CONF_FAVORITE_BUTTON_ID
in config:
210 favorite_config = inherit_esphome_device(
212 CONF_ID: config[CONF_FAVORITE_BUTTON_ID],
214 CONF_DISABLED_BY_DEFAULT:
False,
218 favorite = await button.new_button(favorite_config)
219 await cg.register_component(favorite, favorite_config)
220 cg.add(favorite.set_parent(parent))
221 cg.add(favorite.set_device_id(config[CONF_IO_DEVICE_ID]))
222 cg.add(favorite.set_command(CoverCommand.FAVORITE))
224 if CONF_VENT_BUTTON_ID
in config:
225 vent_config = inherit_esphome_device(
227 CONF_ID: config[CONF_VENT_BUTTON_ID],
229 CONF_DISABLED_BY_DEFAULT:
False,
233 vent = await button.new_button(vent_config)
234 await cg.register_component(vent, vent_config)
235 cg.add(vent.set_parent(parent))
236 cg.add(vent.set_device_id(config[CONF_IO_DEVICE_ID]))
237 cg.add(vent.set_command(CoverCommand.VENT))
239 await create_companion_sensors(config, parent)