1 """Allows to configure a switch using RPi GPIO."""
3 from __future__
import annotations
7 import voluptuous
as vol
10 PLATFORM_SCHEMA
as SWITCH_PLATFORM_SCHEMA,
19 from .
import CONF_INVERT_LOGIC, DEFAULT_INVERT_LOGIC, setup_output, write_output
23 _SENSORS_SCHEMA = vol.Schema({cv.positive_int: cv.string})
25 PLATFORM_SCHEMA = SWITCH_PLATFORM_SCHEMA.extend(
27 vol.Required(CONF_HOST): cv.string,
28 vol.Required(CONF_PORTS): _SENSORS_SCHEMA,
29 vol.Optional(CONF_INVERT_LOGIC, default=DEFAULT_INVERT_LOGIC): cv.boolean,
37 add_entities: AddEntitiesCallback,
38 discovery_info: DiscoveryInfoType |
None =
None,
40 """Set up the Remote Raspberry PI GPIO devices."""
41 address = config[CONF_HOST]
42 invert_logic = config[CONF_INVERT_LOGIC]
43 ports = config[CONF_PORTS]
46 for port, name
in ports.items():
49 except (ValueError, IndexError, KeyError, OSError):
52 devices.append(new_switch)
58 """Representation of a Remote Raspberry Pi GPIO."""
60 _attr_should_poll =
False
63 """Initialize the pin."""
64 self.
_name_name = name
or DEVICE_DEFAULT_NAME
70 """Return the name of the switch."""
71 return self.
_name_name
75 """If unable to access real state of the entity."""
80 """Return true if device is on."""
84 """Turn the device on."""
90 """Turn the device off."""
None turn_on(self, **Any kwargs)
None turn_off(self, **Any kwargs)
def __init__(self, name, led)
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)
def write_output(switch, value)
def setup_output(address, port, invert_logic)