Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.template.switch Namespace Reference

Classes

class  SwitchTemplate
 

Functions

def _async_create_entities (hass, config)
 
SwitchTemplate async_create_preview_switch (HomeAssistant hass, str name, dict[str, Any] config)
 
None async_setup_entry (HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
 
None async_setup_platform (HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)
 

Variables

list _VALID_STATES = [STATE_ON, STATE_OFF, "true", "false"]
 
 PLATFORM_SCHEMA
 
 SWITCH_CONFIG_SCHEMA
 
 SWITCH_SCHEMA
 

Detailed Description

Support for switches which integrates with other components.

Function Documentation

◆ _async_create_entities()

def homeassistant.components.template.switch._async_create_entities (   hass,
  config 
)
private
Create the Template switches.

Definition at line 74 of file switch.py.

◆ async_create_preview_switch()

SwitchTemplate homeassistant.components.template.switch.async_create_preview_switch ( HomeAssistant  hass,
str  name,
dict[str, Any]   config 
)
Create a preview switch.

Definition at line 119 of file switch.py.

◆ async_setup_entry()

None homeassistant.components.template.switch.async_setup_entry ( HomeAssistant  hass,
ConfigEntry  config_entry,
AddEntitiesCallback  async_add_entities 
)
Initialize config entry.

Definition at line 104 of file switch.py.

◆ async_setup_platform()

None homeassistant.components.template.switch.async_setup_platform ( HomeAssistant  hass,
ConfigType  config,
AddEntitiesCallback  async_add_entities,
DiscoveryInfoType | None   discovery_info = None 
)
Set up the template switches.

Definition at line 94 of file switch.py.

Variable Documentation

◆ _VALID_STATES

list homeassistant.components.template.switch._VALID_STATES = [STATE_ON, STATE_OFF, "true", "false"]
private

Definition at line 43 of file switch.py.

◆ PLATFORM_SCHEMA

homeassistant.components.template.switch.PLATFORM_SCHEMA
Initial value:
1 = SWITCH_PLATFORM_SCHEMA.extend(
2  {vol.Required(CONF_SWITCHES): cv.schema_with_slug_keys(SWITCH_SCHEMA)}
3 )

Definition at line 59 of file switch.py.

◆ SWITCH_CONFIG_SCHEMA

homeassistant.components.template.switch.SWITCH_CONFIG_SCHEMA
Initial value:
1 = vol.Schema(
2  {
3  vol.Required(CONF_NAME): cv.template,
4  vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
5  vol.Optional(CONF_TURN_ON): cv.SCRIPT_SCHEMA,
6  vol.Optional(CONF_TURN_OFF): cv.SCRIPT_SCHEMA,
7  vol.Optional(CONF_DEVICE_ID): selector.DeviceSelector(),
8  }
9 )

Definition at line 63 of file switch.py.

◆ SWITCH_SCHEMA

homeassistant.components.template.switch.SWITCH_SCHEMA
Initial value:
1 = vol.All(
2  cv.deprecated(ATTR_ENTITY_ID),
3  vol.Schema(
4  {
5  vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
6  vol.Required(CONF_TURN_ON): cv.SCRIPT_SCHEMA,
7  vol.Required(CONF_TURN_OFF): cv.SCRIPT_SCHEMA,
8  vol.Optional(ATTR_FRIENDLY_NAME): cv.string,
9  vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
10  vol.Optional(CONF_UNIQUE_ID): cv.string,
11  }
12  ).extend(TEMPLATE_ENTITY_COMMON_SCHEMA_LEGACY.schema),
13 )

Definition at line 45 of file switch.py.