Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.command_line.switch.CommandSwitch Class Reference
Inheritance diagram for homeassistant.components.command_line.switch.CommandSwitch:
[legend]
Collaboration diagram for homeassistant.components.command_line.switch.CommandSwitch:
[legend]

Public Member Functions

None __init__ (self, ConfigType config, str object_id, str command_on, str command_off, str|None command_state, Template|None value_template, int timeout, timedelta scan_interval)
 
bool assumed_state (self)
 
None async_added_to_hass (self)
 
None async_turn_off (self, **Any kwargs)
 
None async_turn_on (self, **Any kwargs)
 
None async_update (self)
 
- Public Member Functions inherited from homeassistant.helpers.trigger_template_entity.ManualTriggerEntity
None __init__ (self, HomeAssistant hass, ConfigType config)
 
- Public Member Functions inherited from homeassistant.helpers.trigger_template_entity.TriggerBaseEntity
bool available (self)
 
str|None entity_picture (self)
 
dict[str, Any]|None extra_state_attributes (self)
 
str|None icon (self)
 
str|None name (self)
 
None restore_attributes (self, State last_state)
 
str|None unique_id (self)
 
- Public Member Functions inherited from homeassistant.helpers.entity.Entity
None __init_subclass__ (cls, **Any kwargs)
 
str __repr__ (self)
 
None add_to_platform_abort (self)
 
None add_to_platform_finish (self)
 
None add_to_platform_start (self, HomeAssistant hass, EntityPlatform platform, asyncio.Semaphore|None parallel_updates)
 
None async_device_update (self, bool warning=True)
 
None async_internal_added_to_hass (self)
 
None async_internal_will_remove_from_hass (self)
 
None async_on_remove (self, CALLBACK_TYPE func)
 
None async_registry_entry_updated (self)
 
None async_remove (self, *bool force_remove=False)
 
None async_removed_from_registry (self)
 
None async_schedule_update_ha_state (self, bool force_refresh=False)
 
None async_set_context (self, Context context)
 
None async_update_ha_state (self, bool force_refresh=False)
 
None async_will_remove_from_hass (self)
 
None async_write_ha_state (self)
 
str|None attribution (self)
 
dict[str, Any]|None capability_attributes (self)
 
DeviceInfo|None device_info (self)
 
bool enabled (self)
 
EntityCategory|None entity_category (self)
 
bool entity_registry_enabled_default (self)
 
bool entity_registry_visible_default (self)
 
bool force_update (self)
 
HassJobType get_hassjob_type (self, str function_name)
 
er.EntityOptionsType|None get_initial_entity_options (self)
 
bool has_entity_name (self)
 
None schedule_update_ha_state (self, bool force_refresh=False)
 
bool should_poll (self)
 
dict[str, Any]|None state_attributes (self)
 
str|None suggested_object_id (self)
 
int|None supported_features (self)
 
str|None translation_key (self)
 
Mapping[str, strtranslation_placeholders (self)
 
str|None unit_of_measurement (self)
 
bool use_device_name (self)
 
- Public Member Functions inherited from homeassistant.helpers.entity.CachedProperties
None __init__ (cls, str name, tuple[type,...] bases, dict[Any, Any] namespace, **Any kwargs)
 
Any __new__ (mcs, str name, tuple[type,...] bases, dict[Any, Any] namespace, set[str]|None cached_properties=None, **Any kwargs)
 
- Public Member Functions inherited from homeassistant.components.switch.SwitchEntity
SwitchDeviceClass|None device_class (self)
 
- Public Member Functions inherited from homeassistant.helpers.entity.ToggleEntity
None async_toggle (self, **Any kwargs)
 
bool|None is_on (self)
 
Literal["on", "off"]|None state (self)
 
None toggle (self, **Any kwargs)
 
None turn_off (self, **Any kwargs)
 
None turn_on (self, **Any kwargs)
 

Public Attributes

 entity_id
 
- Public Attributes inherited from homeassistant.helpers.trigger_template_entity.TriggerBaseEntity
 hass
 
- Public Attributes inherited from homeassistant.helpers.entity.Entity
 device_entry
 
 entity_id
 
 hass
 
 parallel_updates
 
 platform
 
 registry_entry
 

Private Member Functions

str|int|None _async_query_state (self)
 
bool _async_query_state_code (self, str command)
 
str|None _async_query_state_value (self, str command)
 
None _async_update (self)
 
bool _switch (self, str command)
 
None _update_entity_state (self, datetime|None now=None)
 

Private Attributes

 _attr_is_on
 
 _command_off
 
 _command_on
 
 _command_state
 
 _process_updates
 
 _scan_interval
 
 _timeout
 
 _value_template
 

Static Private Attributes

bool _attr_should_poll = False
 

Additional Inherited Members

- Static Public Attributes inherited from homeassistant.helpers.trigger_template_entity.TriggerBaseEntity
 None
 
- Static Public Attributes inherited from homeassistant.helpers.entity.Entity
 bool
 
 EntityPlatform
 
 HomeAssistant
 
 None
 
 StateInfo
 
 StateType
 
 str
 
- Static Public Attributes inherited from homeassistant.helpers.entity.ToggleEntity
 None
 

Detailed Description

Representation a switch that can be toggled using shell commands.

Definition at line 70 of file switch.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.components.command_line.switch.CommandSwitch.__init__ (   self,
ConfigType  config,
str  object_id,
str  command_on,
str  command_off,
str | None  command_state,
Template | None  value_template,
int  timeout,
timedelta  scan_interval 
)
Initialize the switch.

Definition at line 75 of file switch.py.

Member Function Documentation

◆ _async_query_state()

str | int | None homeassistant.components.command_line.switch.CommandSwitch._async_query_state (   self)
private
Query for state.

Definition at line 143 of file switch.py.

◆ _async_query_state_code()

bool homeassistant.components.command_line.switch.CommandSwitch._async_query_state_code (   self,
str  command 
)
private
Execute state command for return code.

Definition at line 128 of file switch.py.

◆ _async_query_state_value()

str | None homeassistant.components.command_line.switch.CommandSwitch._async_query_state_value (   self,
str  command 
)
private
Execute state command for return value.

Definition at line 123 of file switch.py.

◆ _async_update()

None homeassistant.components.command_line.switch.CommandSwitch._async_update (   self)
private
Update device state.

Definition at line 166 of file switch.py.

◆ _switch()

bool homeassistant.components.command_line.switch.CommandSwitch._switch (   self,
str  command 
)
private
Execute the actual commands.

Definition at line 112 of file switch.py.

◆ _update_entity_state()

None homeassistant.components.command_line.switch.CommandSwitch._update_entity_state (   self,
datetime | None   now = None 
)
private
Update the state of the entity.

Definition at line 151 of file switch.py.

◆ assumed_state()

bool homeassistant.components.command_line.switch.CommandSwitch.assumed_state (   self)
Return true if we do optimistic updates.

Reimplemented from homeassistant.helpers.entity.Entity.

Definition at line 139 of file switch.py.

◆ async_added_to_hass()

None homeassistant.components.command_line.switch.CommandSwitch.async_added_to_hass (   self)
Call when entity about to be added to hass.

Reimplemented from homeassistant.helpers.entity.Entity.

Definition at line 98 of file switch.py.

◆ async_turn_off()

None homeassistant.components.command_line.switch.CommandSwitch.async_turn_off (   self,
**Any  kwargs 
)
Turn the device off.

Reimplemented from homeassistant.helpers.entity.ToggleEntity.

Definition at line 195 of file switch.py.

◆ async_turn_on()

None homeassistant.components.command_line.switch.CommandSwitch.async_turn_on (   self,
**Any  kwargs 
)
Turn the device on.

Reimplemented from homeassistant.helpers.entity.ToggleEntity.

Definition at line 188 of file switch.py.

◆ async_update()

None homeassistant.components.command_line.switch.CommandSwitch.async_update (   self)
Update the entity.

Only used by the generic entity update service.

Definition at line 181 of file switch.py.

Member Data Documentation

◆ _attr_is_on

homeassistant.components.command_line.switch.CommandSwitch._attr_is_on
private

Definition at line 89 of file switch.py.

◆ _attr_should_poll

bool homeassistant.components.command_line.switch.CommandSwitch._attr_should_poll = False
staticprivate

Definition at line 73 of file switch.py.

◆ _command_off

homeassistant.components.command_line.switch.CommandSwitch._command_off
private

Definition at line 91 of file switch.py.

◆ _command_on

homeassistant.components.command_line.switch.CommandSwitch._command_on
private

Definition at line 90 of file switch.py.

◆ _command_state

homeassistant.components.command_line.switch.CommandSwitch._command_state
private

Definition at line 92 of file switch.py.

◆ _process_updates

homeassistant.components.command_line.switch.CommandSwitch._process_updates
private

Definition at line 154 of file switch.py.

◆ _scan_interval

homeassistant.components.command_line.switch.CommandSwitch._scan_interval
private

Definition at line 95 of file switch.py.

◆ _timeout

homeassistant.components.command_line.switch.CommandSwitch._timeout
private

Definition at line 94 of file switch.py.

◆ _value_template

homeassistant.components.command_line.switch.CommandSwitch._value_template
private

Definition at line 93 of file switch.py.

◆ entity_id

homeassistant.components.command_line.switch.CommandSwitch.entity_id

Definition at line 88 of file switch.py.


The documentation for this class was generated from the following file: