1 """Support for ESPHome binary sensors."""
3 from __future__
import annotations
5 from typing
import TYPE_CHECKING
7 from aioesphomeapi
import BinarySensorInfo, BinarySensorState, EntityInfo
10 BinarySensorDeviceClass,
12 BinarySensorEntityDescription,
19 from .const
import DOMAIN
20 from .entity
import EsphomeAssistEntity, EsphomeEntity, platform_async_setup_entry
21 from .entry_data
import ESPHomeConfigEntry
26 entry: ESPHomeConfigEntry,
27 async_add_entities: AddEntitiesCallback,
29 """Set up ESPHome binary sensors based on a config entry."""
34 info_type=BinarySensorInfo,
35 entity_type=EsphomeBinarySensor,
36 state_type=BinarySensorState,
39 entry_data = entry.runtime_data
40 assert entry_data.device_info
is not None
41 if entry_data.device_info.voice_assistant_feature_flags_compat(
42 entry_data.api_version
48 EsphomeEntity[BinarySensorInfo, BinarySensorState], BinarySensorEntity
50 """A binary sensor implementation for ESPHome."""
54 """Return true if the binary sensor is on."""
55 if self.
_static_info_static_info.is_status_binary_sensor:
61 return self.
_state_state.state
65 """Set attrs from static info."""
68 BinarySensorDeviceClass, self.
_static_info_static_info.device_class
73 """Return True if entity is available."""
74 return self.
_static_info_static_info.is_status_binary_sensor
or super().available
78 """A binary sensor implementation for ESPHome for use with assist_pipeline."""
81 entity_registry_enabled_default=
False,
82 key=
"assist_in_progress",
83 translation_key=
"assist_in_progress",
91 ir.async_create_issue(
94 f
"assist_in_progress_deprecated_{self.registry_entry.id}",
95 breaks_in_ha_version=
"2025.4",
99 "integration_name":
"ESPHome",
102 severity=ir.IssueSeverity.WARNING,
103 translation_key=
"assist_in_progress_deprecated",
104 translation_placeholders={
105 "integration_name":
"ESPHome",
114 ir.async_delete_issue(
117 f
"assist_in_progress_deprecated_{self.registry_entry.id}",
122 """Return true if the binary sensor is on."""
123 return self._entry_data.assist_pipeline_state
None async_will_remove_from_hass(self)
None async_added_to_hass(self)
None _on_static_info_update(self, EntityInfo static_info)
None async_setup_entry(HomeAssistant hass, ESPHomeConfigEntry entry, AddEntitiesCallback async_add_entities)
None platform_async_setup_entry(HomeAssistant hass, ESPHomeConfigEntry entry, AddEntitiesCallback async_add_entities, *type[_InfoT] info_type, type[_EntityT] entity_type, type[_StateT] state_type)