From 12dbcca078e8f08afadff390bb1822cadba759fe Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 24 Feb 2022 18:22:48 +0100 Subject: [PATCH] Remove deprecated BeagleBone Black GPIO integration (#67160) --- .coveragerc | 1 - homeassistant/components/bbb_gpio/__init__.py | 63 --------------- .../components/bbb_gpio/binary_sensor.py | 79 ------------------ .../components/bbb_gpio/manifest.json | 9 --- homeassistant/components/bbb_gpio/switch.py | 80 ------------------- requirements_all.txt | 3 - 6 files changed, 235 deletions(-) delete mode 100644 homeassistant/components/bbb_gpio/__init__.py delete mode 100644 homeassistant/components/bbb_gpio/binary_sensor.py delete mode 100644 homeassistant/components/bbb_gpio/manifest.json delete mode 100644 homeassistant/components/bbb_gpio/switch.py diff --git a/.coveragerc b/.coveragerc index ec22cbbfc67..3262c2703eb 100644 --- a/.coveragerc +++ b/.coveragerc @@ -101,7 +101,6 @@ omit = homeassistant/components/baidu/tts.py homeassistant/components/balboa/__init__.py homeassistant/components/beewi_smartclim/sensor.py - homeassistant/components/bbb_gpio/* homeassistant/components/bbox/device_tracker.py homeassistant/components/bbox/sensor.py homeassistant/components/bh1750/sensor.py diff --git a/homeassistant/components/bbb_gpio/__init__.py b/homeassistant/components/bbb_gpio/__init__.py deleted file mode 100644 index 511292cfb6f..00000000000 --- a/homeassistant/components/bbb_gpio/__init__.py +++ /dev/null @@ -1,63 +0,0 @@ -"""Support for controlling GPIO pins of a Beaglebone Black.""" -import logging - -from Adafruit_BBIO import GPIO # pylint: disable=import-error - -from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP -from homeassistant.core import HomeAssistant -from homeassistant.helpers.typing import ConfigType - -DOMAIN = "bbb_gpio" - -_LOGGER = logging.getLogger(__name__) - - -def setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Set up the BeagleBone Black GPIO component.""" - _LOGGER.warning( - "The BeagleBone Black GPIO integration is deprecated and will be removed " - "in Home Assistant Core 2022.4; this integration is removed under " - "Architectural Decision Record 0019, more information can be found here: " - "https://github.com/home-assistant/architecture/blob/master/adr/0019-GPIO.md" - ) - - def cleanup_gpio(event): - """Stuff to do before stopping.""" - GPIO.cleanup() - - def prepare_gpio(event): - """Stuff to do when Home Assistant starts.""" - hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, cleanup_gpio) - - hass.bus.listen_once(EVENT_HOMEASSISTANT_START, prepare_gpio) - return True - - -def setup_output(pin): - """Set up a GPIO as output.""" - - GPIO.setup(pin, GPIO.OUT) - - -def setup_input(pin, pull_mode): - """Set up a GPIO as input.""" - - GPIO.setup(pin, GPIO.IN, GPIO.PUD_DOWN if pull_mode == "DOWN" else GPIO.PUD_UP) - - -def write_output(pin, value): - """Write a value to a GPIO.""" - - GPIO.output(pin, value) - - -def read_input(pin): - """Read a value from a GPIO.""" - - return GPIO.input(pin) is GPIO.HIGH - - -def edge_detect(pin, event_callback, bounce): - """Add detection for RISING and FALLING events.""" - - GPIO.add_event_detect(pin, GPIO.BOTH, callback=event_callback, bouncetime=bounce) diff --git a/homeassistant/components/bbb_gpio/binary_sensor.py b/homeassistant/components/bbb_gpio/binary_sensor.py deleted file mode 100644 index 360d9d84376..00000000000 --- a/homeassistant/components/bbb_gpio/binary_sensor.py +++ /dev/null @@ -1,79 +0,0 @@ -"""Support for binary sensor using Beaglebone Black GPIO.""" -from __future__ import annotations - -import voluptuous as vol - -from homeassistant.components import bbb_gpio -from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity -from homeassistant.const import CONF_NAME, DEVICE_DEFAULT_NAME -from homeassistant.core import HomeAssistant -import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType - -CONF_PINS = "pins" -CONF_BOUNCETIME = "bouncetime" -CONF_INVERT_LOGIC = "invert_logic" -CONF_PULL_MODE = "pull_mode" - -DEFAULT_BOUNCETIME = 50 -DEFAULT_INVERT_LOGIC = False -DEFAULT_PULL_MODE = "UP" - -PIN_SCHEMA = vol.Schema( - { - vol.Required(CONF_NAME): cv.string, - vol.Optional(CONF_BOUNCETIME, default=DEFAULT_BOUNCETIME): cv.positive_int, - vol.Optional(CONF_INVERT_LOGIC, default=DEFAULT_INVERT_LOGIC): cv.boolean, - vol.Optional(CONF_PULL_MODE, default=DEFAULT_PULL_MODE): vol.In(["UP", "DOWN"]), - } -) - -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - {vol.Required(CONF_PINS, default={}): vol.Schema({cv.string: PIN_SCHEMA})} -) - - -def setup_platform( - hass: HomeAssistant, - config: ConfigType, - add_entities: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Set up the Beaglebone Black GPIO devices.""" - pins = config[CONF_PINS] - - binary_sensors = [] - - for pin, params in pins.items(): - binary_sensors.append(BBBGPIOBinarySensor(pin, params)) - add_entities(binary_sensors) - - -class BBBGPIOBinarySensor(BinarySensorEntity): - """Representation of a binary sensor that uses Beaglebone Black GPIO.""" - - _attr_should_poll = False - - def __init__(self, pin, params): - """Initialize the Beaglebone Black binary sensor.""" - self._pin = pin - self._attr_name = params[CONF_NAME] or DEVICE_DEFAULT_NAME - self._bouncetime = params[CONF_BOUNCETIME] - self._pull_mode = params[CONF_PULL_MODE] - self._invert_logic = params[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) - - @property - def is_on(self) -> bool: - """Return the state of the entity.""" - return self._state != self._invert_logic diff --git a/homeassistant/components/bbb_gpio/manifest.json b/homeassistant/components/bbb_gpio/manifest.json deleted file mode 100644 index c57530a9bf8..00000000000 --- a/homeassistant/components/bbb_gpio/manifest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "domain": "bbb_gpio", - "name": "BeagleBone Black GPIO", - "documentation": "https://www.home-assistant.io/integrations/bbb_gpio", - "requirements": ["Adafruit_BBIO==1.1.1"], - "codeowners": [], - "iot_class": "local_push", - "loggers": ["Adafruit_BBIO"] -} diff --git a/homeassistant/components/bbb_gpio/switch.py b/homeassistant/components/bbb_gpio/switch.py deleted file mode 100644 index fc830d2a1a8..00000000000 --- a/homeassistant/components/bbb_gpio/switch.py +++ /dev/null @@ -1,80 +0,0 @@ -"""Allows to configure a switch using BeagleBone Black GPIO.""" -from __future__ import annotations - -import voluptuous as vol - -from homeassistant.components import bbb_gpio -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity -from homeassistant.const import CONF_NAME, DEVICE_DEFAULT_NAME -from homeassistant.core import HomeAssistant -import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType - -CONF_PINS = "pins" -CONF_INITIAL = "initial" -CONF_INVERT_LOGIC = "invert_logic" - -PIN_SCHEMA = vol.Schema( - { - vol.Required(CONF_NAME): cv.string, - vol.Optional(CONF_INITIAL, default=False): cv.boolean, - vol.Optional(CONF_INVERT_LOGIC, default=False): cv.boolean, - } -) - -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - {vol.Required(CONF_PINS, default={}): vol.Schema({cv.string: PIN_SCHEMA})} -) - - -def setup_platform( - hass: HomeAssistant, - config: ConfigType, - add_entities: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Set up the BeagleBone Black GPIO devices.""" - pins = config[CONF_PINS] - - switches = [] - for pin, params in pins.items(): - switches.append(BBBGPIOSwitch(pin, params)) - add_entities(switches) - - -class BBBGPIOSwitch(SwitchEntity): - """Representation of a BeagleBone Black GPIO.""" - - _attr_should_poll = False - - def __init__(self, pin, params): - """Initialize the pin.""" - self._pin = pin - self._attr_name = params[CONF_NAME] or DEVICE_DEFAULT_NAME - self._state = params[CONF_INITIAL] - self._invert_logic = params[CONF_INVERT_LOGIC] - - bbb_gpio.setup_output(self._pin) - - if self._state is False: - bbb_gpio.write_output(self._pin, 1 if self._invert_logic else 0) - else: - bbb_gpio.write_output(self._pin, 0 if self._invert_logic else 1) - - @property - def is_on(self) -> bool: - """Return true if device is on.""" - return self._state - - def turn_on(self, **kwargs): - """Turn the device on.""" - bbb_gpio.write_output(self._pin, 0 if self._invert_logic else 1) - self._state = True - self.schedule_update_ha_state() - - def turn_off(self, **kwargs): - """Turn the device off.""" - bbb_gpio.write_output(self._pin, 1 if self._invert_logic else 0) - self._state = False - self.schedule_update_ha_state() diff --git a/requirements_all.txt b/requirements_all.txt index 300bf91f289..f5def50096e 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -10,9 +10,6 @@ Adafruit-GPIO==1.0.3 # homeassistant.components.sht31 Adafruit-SHT31==1.0.2 -# homeassistant.components.bbb_gpio -# Adafruit_BBIO==1.1.1 - # homeassistant.components.adax Adax-local==0.1.3