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

Classes

class  AutoOffExtraStoredData
 
class  BinarySensorTemplate
 
class  TriggerBinarySensorEntity
 

Functions

None _async_create_template_tracking_entities (AddEntitiesCallback async_add_entities, HomeAssistant hass, list[dict] definitions, str|None unique_id_prefix)
 
BinarySensorTemplate async_create_preview_binary_sensor (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)
 
list[dict] rewrite_legacy_to_modern_conf (HomeAssistant hass, dict[str, dict] cfg)
 

Variables

 BINARY_SENSOR_CONFIG_SCHEMA
 
 BINARY_SENSOR_SCHEMA
 
string CONF_ATTRIBUTE_TEMPLATES = "attribute_templates"
 
string CONF_AUTO_OFF = "auto_off"
 
string CONF_DELAY_OFF = "delay_off"
 
string CONF_DELAY_ON = "delay_on"
 
 LEGACY_BINARY_SENSOR_SCHEMA
 
dictionary LEGACY_FIELDS
 
 PLATFORM_SCHEMA
 

Detailed Description

Support for exposing a templated binary sensor.

Function Documentation

◆ _async_create_template_tracking_entities()

None homeassistant.components.template.binary_sensor._async_create_template_tracking_entities ( AddEntitiesCallback  async_add_entities,
HomeAssistant  hass,
list[dict]  definitions,
str | None  unique_id_prefix 
)
private
Create the template binary sensors.

Definition at line 153 of file binary_sensor.py.

◆ async_create_preview_binary_sensor()

BinarySensorTemplate homeassistant.components.template.binary_sensor.async_create_preview_binary_sensor ( HomeAssistant  hass,
str  name,
dict[str, Any]   config 
)
Create a preview sensor.

Definition at line 225 of file binary_sensor.py.

◆ async_setup_entry()

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

Definition at line 210 of file binary_sensor.py.

◆ async_setup_platform()

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

Definition at line 179 of file binary_sensor.py.

◆ rewrite_legacy_to_modern_conf()

list[dict] homeassistant.components.template.binary_sensor.rewrite_legacy_to_modern_conf ( HomeAssistant  hass,
dict[str, dict]   cfg 
)
Rewrite legacy binary sensor definitions to modern ones.

Definition at line 122 of file binary_sensor.py.

Variable Documentation

◆ BINARY_SENSOR_CONFIG_SCHEMA

homeassistant.components.template.binary_sensor.BINARY_SENSOR_CONFIG_SCHEMA
Initial value:
1 = BINARY_SENSOR_SCHEMA.extend(
2  {
3  vol.Optional(CONF_DEVICE_ID): selector.DeviceSelector(),
4  }
5 )

Definition at line 94 of file binary_sensor.py.

◆ BINARY_SENSOR_SCHEMA

homeassistant.components.template.binary_sensor.BINARY_SENSOR_SCHEMA
Initial value:
1 = vol.Schema(
2  {
3  vol.Optional(CONF_AUTO_OFF): vol.Any(cv.positive_time_period, cv.template),
4  vol.Optional(CONF_DELAY_OFF): vol.Any(cv.positive_time_period, cv.template),
5  vol.Optional(CONF_DELAY_ON): vol.Any(cv.positive_time_period, cv.template),
6  vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
7  vol.Required(CONF_STATE): cv.template,
8  vol.Optional(CONF_UNIT_OF_MEASUREMENT): cv.string,
9  }
10 ).extend(TEMPLATE_ENTITY_COMMON_SCHEMA.schema)

Definition at line 83 of file binary_sensor.py.

◆ CONF_ATTRIBUTE_TEMPLATES

string homeassistant.components.template.binary_sensor.CONF_ATTRIBUTE_TEMPLATES = "attribute_templates"

Definition at line 71 of file binary_sensor.py.

◆ CONF_AUTO_OFF

string homeassistant.components.template.binary_sensor.CONF_AUTO_OFF = "auto_off"

Definition at line 70 of file binary_sensor.py.

◆ CONF_DELAY_OFF

string homeassistant.components.template.binary_sensor.CONF_DELAY_OFF = "delay_off"

Definition at line 69 of file binary_sensor.py.

◆ CONF_DELAY_ON

string homeassistant.components.template.binary_sensor.CONF_DELAY_ON = "delay_on"

Definition at line 68 of file binary_sensor.py.

◆ LEGACY_BINARY_SENSOR_SCHEMA

homeassistant.components.template.binary_sensor.LEGACY_BINARY_SENSOR_SCHEMA
Initial value:
1 = vol.All(
2  cv.deprecated(ATTR_ENTITY_ID),
3  vol.Schema(
4  {
5  vol.Required(CONF_VALUE_TEMPLATE): cv.template,
6  vol.Optional(CONF_ICON_TEMPLATE): cv.template,
7  vol.Optional(CONF_ENTITY_PICTURE_TEMPLATE): cv.template,
8  vol.Optional(CONF_AVAILABILITY_TEMPLATE): cv.template,
9  vol.Optional(CONF_ATTRIBUTE_TEMPLATES): vol.Schema(
10  {cv.string: cv.template}
11  ),
12  vol.Optional(ATTR_FRIENDLY_NAME): cv.string,
13  vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
14  vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
15  vol.Optional(CONF_DELAY_ON): vol.Any(cv.positive_time_period, cv.template),
16  vol.Optional(CONF_DELAY_OFF): vol.Any(cv.positive_time_period, cv.template),
17  vol.Optional(CONF_UNIQUE_ID): cv.string,
18  }
19  ),
20 )

Definition at line 100 of file binary_sensor.py.

◆ LEGACY_FIELDS

dictionary homeassistant.components.template.binary_sensor.LEGACY_FIELDS
Initial value:
1 = {
2  CONF_ICON_TEMPLATE: CONF_ICON,
3  CONF_ENTITY_PICTURE_TEMPLATE: CONF_PICTURE,
4  CONF_AVAILABILITY_TEMPLATE: CONF_AVAILABILITY,
5  CONF_ATTRIBUTE_TEMPLATES: CONF_ATTRIBUTES,
6  CONF_FRIENDLY_NAME_TEMPLATE: CONF_NAME,
7  CONF_FRIENDLY_NAME: CONF_NAME,
8  CONF_VALUE_TEMPLATE: CONF_STATE,
9 }

Definition at line 73 of file binary_sensor.py.

◆ PLATFORM_SCHEMA

homeassistant.components.template.binary_sensor.PLATFORM_SCHEMA
Initial value:
1 = BINARY_SENSOR_PLATFORM_SCHEMA.extend(
2  {
3  vol.Required(CONF_SENSORS): cv.schema_with_slug_keys(
4  LEGACY_BINARY_SENSOR_SCHEMA
5  ),
6  }
7 )

Definition at line 143 of file binary_sensor.py.