1 """Support for Tasmota binary sensors."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from datetime
import datetime
9 from hatasmota
import switch
as tasmota_switch
10 from hatasmota.entity
import TasmotaEntity
as HATasmotaEntity
11 from hatasmota.models
import DiscoveryHashType
21 from .const
import DATA_REMOVE_DISCOVER_COMPONENT
22 from .discovery
import TASMOTA_DISCOVERY_ENTITY_NEW
23 from .entity
import TasmotaAvailability, TasmotaDiscoveryUpdate
28 config_entry: ConfigEntry,
29 async_add_entities: AddEntitiesCallback,
31 """Set up Tasmota binary sensor dynamically through discovery."""
35 tasmota_entity: HATasmotaEntity, discovery_hash: DiscoveryHashType
37 """Discover and add a Tasmota binary sensor."""
41 tasmota_entity=tasmota_entity, discovery_hash=discovery_hash
46 hass.data[DATA_REMOVE_DISCOVER_COMPONENT.format(binary_sensor.DOMAIN)] = (
49 TASMOTA_DISCOVERY_ENTITY_NEW.format(binary_sensor.DOMAIN),
57 TasmotaDiscoveryUpdate,
60 """Representation a Tasmota binary sensor."""
62 _delay_listener: Callable |
None =
None
63 _on_off_state: bool |
None =
None
64 _tasmota_entity: tasmota_switch.TasmotaSwitch
67 """Initialize the Tasmota binary sensor."""
75 """Subscribe to MQTT events."""
81 """Switch device off after a delay."""
88 """Handle state updates."""
105 """Return true if the binary sensor is on."""
None on_off_state_updated(self, bool state, **Any kwargs)
None async_added_to_hass(self)
None __init__(self, **Any kwds)
None off_delay_listener(self, datetime now)
None async_write_ha_state(self)
None async_discover(DiscoveryInfo discovery_info)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)