1 """Component for interfacing RFK101 proximity card readers."""
3 from __future__
import annotations
7 from rfk101py.rfk101py
import rfk101py
8 import voluptuous
as vol
14 EVENT_HOMEASSISTANT_STOP,
20 _LOGGER = logging.getLogger(__name__)
22 DOMAIN =
"idteck_prox"
24 EVENT_IDTECK_PROX_KEYCARD =
"idteck_prox_keycard"
26 CONFIG_SCHEMA = vol.Schema(
33 vol.Required(CONF_HOST): cv.string,
34 vol.Required(CONF_PORT): cv.port,
35 vol.Required(CONF_NAME): cv.string,
41 extra=vol.ALLOW_EXTRA,
45 def setup(hass: HomeAssistant, config: ConfigType) -> bool:
46 """Set up the IDTECK proximity card component."""
49 host = unit[CONF_HOST]
50 port = unit[CONF_PORT]
51 name = unit[CONF_NAME]
56 hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, reader.stop)
57 except OSError
as error:
58 _LOGGER.error(
"Error creating %s. %s", name, error)
65 """Representation of an IDTECK proximity card reader."""
68 """Initialize the reader."""
76 """Connect to the reader."""
81 """Send a keycard event message into Home Assistant whenever a card is read."""
82 self.
hasshass.bus.fire(
83 EVENT_IDTECK_PROX_KEYCARD, {
"card": card,
"name": self.
_name_name}
86 def stop(self, _: Event) ->
None:
87 """Close resources."""
def _callback(self, card)
def __init__(self, hass, host, port, name)
bool setup(HomeAssistant hass, ConfigType config)