コード例 #1
0
ファイル: bbb_gpio.py プロジェクト: Teagan42/home-assistant
    def __init__(self, pin, params):
        """Initialize the Beaglebone Black binary sensor."""
        self._pin = pin
        self._name = params.get(CONF_NAME) or DEVICE_DEFAULT_NAME
        self._bouncetime = params.get(CONF_BOUNCETIME)
        self._pull_mode = params.get(CONF_PULL_MODE)
        self._invert_logic = params.get(CONF_INVERT_LOGIC)

        bbb_gpio.setup_input(self._pin, self._pull_mode)
        self._state = bbb_gpio.read_input(self._pin)

        def read_gpio(pin):
            """Read state from GPIO."""
            self._state = bbb_gpio.read_input(self._pin)
            self.schedule_update_ha_state()

        bbb_gpio.edge_detect(self._pin, read_gpio, self._bouncetime)
コード例 #2
0
    def __init__(self, pin, params):
        """Initialize the Beaglebone Black binary sensor."""
        self._pin = pin
        self._name = params.get(CONF_NAME) or DEVICE_DEFAULT_NAME
        self._bouncetime = params.get(CONF_BOUNCETIME)
        self._pull_mode = params.get(CONF_PULL_MODE)
        self._invert_logic = params.get(CONF_INVERT_LOGIC)

        bbb_gpio.setup_input(self._pin, self._pull_mode)
        self._state = bbb_gpio.read_input(self._pin)

        def read_gpio(pin):
            """Read state from GPIO."""
            self._state = bbb_gpio.read_input(self._pin)
            self.schedule_update_ha_state()

        bbb_gpio.edge_detect(self._pin, read_gpio, self._bouncetime)