1 """Support for switches using GC100."""
3 from __future__
import annotations
7 import voluptuous
as vol
10 PLATFORM_SCHEMA
as SWITCH_PLATFORM_SCHEMA,
19 from .
import CONF_PORTS, DATA_GC100
21 _SWITCH_SCHEMA = vol.Schema({cv.string: cv.string})
23 PLATFORM_SCHEMA = SWITCH_PLATFORM_SCHEMA.extend(
24 {vol.Required(CONF_PORTS): vol.All(cv.ensure_list, [_SWITCH_SCHEMA])}
31 add_entities: AddEntitiesCallback,
32 discovery_info: DiscoveryInfoType |
None =
None,
34 """Set up the GC100 devices."""
36 ports = config[CONF_PORTS]
38 for port_addr, port_name
in port.items():
39 switches.append(
GC100Switch(port_name, port_addr, hass.data[DATA_GC100]))
44 """Represent a switch/relay from GC100."""
47 """Initialize the GC100 switch."""
48 self.
_name_name = name
or DEVICE_DEFAULT_NAME
55 """Return the name of the switch."""
56 return self.
_name_name
60 """Return the state of the entity."""
64 """Turn the device on."""
68 """Turn the device off."""
72 """Update the sensor state."""
76 """Set the current state."""
77 self.
_state_state = state == 1
None turn_off(self, **Any kwargs)
None turn_on(self, **Any kwargs)
def __init__(self, name, port_addr, gc100)
def set_state(self, state)
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)