1 """Support for binary sensor using GC100."""
3 from __future__
import annotations
5 import voluptuous
as vol
8 PLATFORM_SCHEMA
as BINARY_SENSOR_PLATFORM_SCHEMA,
17 from .
import CONF_PORTS, DATA_GC100
19 _SENSORS_SCHEMA = vol.Schema({cv.string: cv.string})
21 PLATFORM_SCHEMA = BINARY_SENSOR_PLATFORM_SCHEMA.extend(
22 {vol.Required(CONF_PORTS): vol.All(cv.ensure_list, [_SENSORS_SCHEMA])}
29 add_entities: AddEntitiesCallback,
30 discovery_info: DiscoveryInfoType |
None =
None,
32 """Set up the GC100 devices."""
34 ports = config[CONF_PORTS]
36 for port_addr, port_name
in port.items():
37 binary_sensors.append(
44 """Representation of a binary sensor from GC100."""
47 """Initialize the GC100 binary sensor."""
48 self.
_name_name = name
or DEVICE_DEFAULT_NAME
58 """Return the name of the sensor."""
59 return self.
_name_name
63 """Return the state of the entity."""
67 """Update the sensor state."""
71 """Set the current state."""
72 self.
_state_state = state == 1
def set_state(self, state)
def __init__(self, name, port_addr, gc100)
None schedule_update_ha_state(self, bool force_refresh=False)
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)
Callable[[], None] subscribe(HomeAssistant hass, str topic, MessageCallbackType msg_callback, int qos=DEFAULT_QOS, str encoding="utf-8")