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

Classes

class  RestSwitch
 

Functions

None async_setup_platform (HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)
 

Variables

 _LOGGER = logging.getLogger(__name__)
 
string CONF_BODY_OFF = "body_off"
 
string CONF_BODY_ON = "body_on"
 
string CONF_IS_ON_TEMPLATE = "is_on_template"
 
string CONF_STATE_RESOURCE = "state_resource"
 
string DEFAULT_BODY_OFF = "OFF"
 
string DEFAULT_BODY_ON = "ON"
 
string DEFAULT_METHOD = "post"
 
string DEFAULT_NAME = "REST Switch"
 
int DEFAULT_TIMEOUT = 10
 
bool DEFAULT_VERIFY_SSL = True
 
 PLATFORM_SCHEMA
 
list SUPPORT_REST_METHODS = ["post", "put", "patch"]
 
tuple TRIGGER_ENTITY_OPTIONS
 

Detailed Description

Support for RESTful switches.

Function Documentation

◆ async_setup_platform()

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

Definition at line 90 of file switch.py.

Variable Documentation

◆ _LOGGER

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

Definition at line 44 of file switch.py.

◆ CONF_BODY_OFF

string homeassistant.components.rest.switch.CONF_BODY_OFF = "body_off"

Definition at line 45 of file switch.py.

◆ CONF_BODY_ON

string homeassistant.components.rest.switch.CONF_BODY_ON = "body_on"

Definition at line 46 of file switch.py.

◆ CONF_IS_ON_TEMPLATE

string homeassistant.components.rest.switch.CONF_IS_ON_TEMPLATE = "is_on_template"

Definition at line 47 of file switch.py.

◆ CONF_STATE_RESOURCE

string homeassistant.components.rest.switch.CONF_STATE_RESOURCE = "state_resource"

Definition at line 48 of file switch.py.

◆ DEFAULT_BODY_OFF

string homeassistant.components.rest.switch.DEFAULT_BODY_OFF = "OFF"

Definition at line 59 of file switch.py.

◆ DEFAULT_BODY_ON

string homeassistant.components.rest.switch.DEFAULT_BODY_ON = "ON"

Definition at line 60 of file switch.py.

◆ DEFAULT_METHOD

string homeassistant.components.rest.switch.DEFAULT_METHOD = "post"

Definition at line 58 of file switch.py.

◆ DEFAULT_NAME

string homeassistant.components.rest.switch.DEFAULT_NAME = "REST Switch"

Definition at line 61 of file switch.py.

◆ DEFAULT_TIMEOUT

int homeassistant.components.rest.switch.DEFAULT_TIMEOUT = 10

Definition at line 62 of file switch.py.

◆ DEFAULT_VERIFY_SSL

bool homeassistant.components.rest.switch.DEFAULT_VERIFY_SSL = True

Definition at line 63 of file switch.py.

◆ PLATFORM_SCHEMA

homeassistant.components.rest.switch.PLATFORM_SCHEMA
Initial value:
1 = SWITCH_PLATFORM_SCHEMA.extend(
2  {
3  **TEMPLATE_ENTITY_BASE_SCHEMA.schema,
4  vol.Required(CONF_RESOURCE): cv.url,
5  vol.Optional(CONF_STATE_RESOURCE): cv.url,
6  vol.Optional(CONF_HEADERS): {cv.string: cv.template},
7  vol.Optional(CONF_PARAMS): {cv.string: cv.template},
8  vol.Optional(CONF_BODY_OFF, default=DEFAULT_BODY_OFF): cv.template,
9  vol.Optional(CONF_BODY_ON, default=DEFAULT_BODY_ON): cv.template,
10  vol.Optional(CONF_IS_ON_TEMPLATE): cv.template,
11  vol.Optional(CONF_METHOD, default=DEFAULT_METHOD): vol.All(
12  vol.Lower, vol.In(SUPPORT_REST_METHODS)
13  ),
14  vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
15  vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int,
16  vol.Inclusive(CONF_USERNAME, "authentication"): cv.string,
17  vol.Inclusive(CONF_PASSWORD, "authentication"): cv.string,
18  vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL): cv.boolean,
19  vol.Optional(CONF_AVAILABILITY): cv.template,
20  }
21 )

Definition at line 67 of file switch.py.

◆ SUPPORT_REST_METHODS

list homeassistant.components.rest.switch.SUPPORT_REST_METHODS = ["post", "put", "patch"]

Definition at line 65 of file switch.py.

◆ TRIGGER_ENTITY_OPTIONS

tuple homeassistant.components.rest.switch.TRIGGER_ENTITY_OPTIONS
Initial value:
1 = (
2  CONF_AVAILABILITY,
3  CONF_DEVICE_CLASS,
4  CONF_ICON,
5  CONF_PICTURE,
6  CONF_UNIQUE_ID,
7 )

Definition at line 50 of file switch.py.