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

Namespaces

 const
 
 device_action
 
 device_condition
 
 device_trigger
 
 light
 
 reproduce_state
 
 significant_change
 

Classes

class  SwitchDeviceClass
 
class  SwitchEntity
 
class  SwitchEntityDescription
 

Functions

bool async_setup (HomeAssistant hass, ConfigType config)
 
bool async_setup_entry (HomeAssistant hass, ConfigEntry entry)
 
bool async_unload_entry (HomeAssistant hass, ConfigEntry entry)
 
bool is_on (HomeAssistant hass, str entity_id)
 

Variables

 __all__ = all_with_deprecated_constants(globals())
 
 __dir__
 
 __getattr__ = partial(check_if_deprecated_constant, module_globals=globals())
 
 _DEPRECATED_DEVICE_CLASS_OUTLET
 
 _DEPRECATED_DEVICE_CLASS_SWITCH
 
 _LOGGER = logging.getLogger(__name__)
 
dictionary CACHED_PROPERTIES_WITH_ATTR_
 
list DEVICE_CLASSES = [cls.value for cls in SwitchDeviceClass]
 
 DEVICE_CLASSES_SCHEMA = vol.All(vol.Lower, vol.Coerce(SwitchDeviceClass))
 
string ENTITY_ID_FORMAT = DOMAIN + ".{}"
 
 MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
 
 PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
 
 PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
 
 SCAN_INTERVAL = timedelta(seconds=30)
 

Detailed Description

Component to interface with switches that can be controlled remotely.

Function Documentation

◆ async_setup()

bool homeassistant.components.switch.async_setup ( HomeAssistant  hass,
ConfigType  config 
)
Track states and offer events for switches.

Definition at line 78 of file __init__.py.

◆ async_setup_entry()

bool homeassistant.components.switch.async_setup_entry ( HomeAssistant  hass,
ConfigEntry  entry 
)
Set up a config entry.

Definition at line 92 of file __init__.py.

◆ async_unload_entry()

bool homeassistant.components.switch.async_unload_entry ( HomeAssistant  hass,
ConfigEntry  entry 
)
Unload a config entry.

Definition at line 97 of file __init__.py.

◆ is_on()

bool homeassistant.components.switch.is_on ( HomeAssistant  hass,
str  entity_id 
)
Return if the switch is on based on the statemachine.

Async friendly.

Definition at line 70 of file __init__.py.

Variable Documentation

◆ __all__

homeassistant.components.switch.__all__ = all_with_deprecated_constants(globals())
private

Definition at line 134 of file __init__.py.

◆ __dir__

homeassistant.components.switch.__dir__
private
Initial value:
1 = partial(
2  dir_with_deprecated_constants, module_globals_keys=[*globals().keys()]
3 )

Definition at line 131 of file __init__.py.

◆ __getattr__

homeassistant.components.switch.__getattr__ = partial(check_if_deprecated_constant, module_globals=globals())
private

Definition at line 130 of file __init__.py.

◆ _DEPRECATED_DEVICE_CLASS_OUTLET

homeassistant.components.switch._DEPRECATED_DEVICE_CLASS_OUTLET
private
Initial value:
1 = DeprecatedConstantEnum(
2  SwitchDeviceClass.OUTLET, "2025.1"
3 )

Definition at line 59 of file __init__.py.

◆ _DEPRECATED_DEVICE_CLASS_SWITCH

homeassistant.components.switch._DEPRECATED_DEVICE_CLASS_SWITCH
private
Initial value:
1 = DeprecatedConstantEnum(
2  SwitchDeviceClass.SWITCH, "2025.1"
3 )

Definition at line 62 of file __init__.py.

◆ _LOGGER

homeassistant.components.switch._LOGGER = logging.getLogger(__name__)
private

Definition at line 36 of file __init__.py.

◆ CACHED_PROPERTIES_WITH_ATTR_

dictionary homeassistant.components.switch.CACHED_PROPERTIES_WITH_ATTR_
Initial value:
1 = {
2  "device_class",
3 }

Definition at line 108 of file __init__.py.

◆ DEVICE_CLASSES

list homeassistant.components.switch.DEVICE_CLASSES = [cls.value for cls in SwitchDeviceClass]

Definition at line 58 of file __init__.py.

◆ DEVICE_CLASSES_SCHEMA

homeassistant.components.switch.DEVICE_CLASSES_SCHEMA = vol.All(vol.Lower, vol.Coerce(SwitchDeviceClass))

Definition at line 54 of file __init__.py.

◆ ENTITY_ID_FORMAT

string homeassistant.components.switch.ENTITY_ID_FORMAT = DOMAIN + ".{}"

Definition at line 39 of file __init__.py.

◆ MIN_TIME_BETWEEN_SCANS

homeassistant.components.switch.MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)

Definition at line 44 of file __init__.py.

◆ PLATFORM_SCHEMA

homeassistant.components.switch.PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA

Definition at line 40 of file __init__.py.

◆ PLATFORM_SCHEMA_BASE

homeassistant.components.switch.PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE

Definition at line 41 of file __init__.py.

◆ SCAN_INTERVAL

homeassistant.components.switch.SCAN_INTERVAL = timedelta(seconds=30)

Definition at line 42 of file __init__.py.