diff --git a/.coveragerc b/.coveragerc index 4c2564a2425..a36c9579e1d 100644 --- a/.coveragerc +++ b/.coveragerc @@ -859,7 +859,6 @@ omit = homeassistant/components/openweathermap/weather_update_coordinator.py homeassistant/components/opnsense/* homeassistant/components/opple/light.py - homeassistant/components/orangepi_gpio/* homeassistant/components/oru/* homeassistant/components/orvibo/switch.py homeassistant/components/osramlightify/light.py diff --git a/CODEOWNERS b/CODEOWNERS index 283bd6442b1..643c287e04a 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -689,7 +689,6 @@ homeassistant/components/openweathermap/* @fabaff @freekode @nzapponi tests/components/openweathermap/* @fabaff @freekode @nzapponi homeassistant/components/opnsense/* @mtreinish tests/components/opnsense/* @mtreinish -homeassistant/components/orangepi_gpio/* @pascallj homeassistant/components/oru/* @bvlaicu homeassistant/components/overkiz/* @imicknl @vlebourl @tetienne tests/components/overkiz/* @imicknl @vlebourl @tetienne diff --git a/homeassistant/components/orangepi_gpio/__init__.py b/homeassistant/components/orangepi_gpio/__init__.py deleted file mode 100644 index 1b0d7a46648..00000000000 --- a/homeassistant/components/orangepi_gpio/__init__.py +++ /dev/null @@ -1,59 +0,0 @@ -"""Support for controlling GPIO pins of a Orange Pi.""" -import logging - -from OPi import GPIO - -from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP -from homeassistant.core import HomeAssistant -from homeassistant.helpers.typing import ConfigType - -from .const import PIN_MODES - -_LOGGER = logging.getLogger(__name__) - -DOMAIN = "orangepi_gpio" - - -async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Set up the Orange Pi GPIO component.""" - _LOGGER.warning( - "The Orange Pi 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.async_listen_once(EVENT_HOMEASSISTANT_STOP, cleanup_gpio) - - hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, prepare_gpio) - return True - - -def setup_mode(mode): - """Set GPIO pin mode.""" - _LOGGER.debug("Setting GPIO pin mode as %s", PIN_MODES[mode]) - GPIO.setmode(PIN_MODES[mode]) - - -def setup_input(port): - """Set up a GPIO as input.""" - _LOGGER.debug("Setting up GPIO pin %i as input", port) - GPIO.setup(port, GPIO.IN) - - -def read_input(port): - """Read a value from a GPIO.""" - _LOGGER.debug("Reading GPIO pin %i", port) - return GPIO.input(port) - - -def edge_detect(port, event_callback): - """Add detection for RISING and FALLING events.""" - _LOGGER.debug("Add callback for GPIO pin %i", port) - GPIO.add_event_detect(port, GPIO.BOTH, callback=event_callback) diff --git a/homeassistant/components/orangepi_gpio/binary_sensor.py b/homeassistant/components/orangepi_gpio/binary_sensor.py deleted file mode 100644 index 0be4ec48394..00000000000 --- a/homeassistant/components/orangepi_gpio/binary_sensor.py +++ /dev/null @@ -1,77 +0,0 @@ -"""Support for binary sensor using Orange Pi GPIO.""" -from __future__ import annotations - -from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity -from homeassistant.core import HomeAssistant -from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType - -from . import edge_detect, read_input, setup_input, setup_mode -from .const import CONF_INVERT_LOGIC, CONF_PIN_MODE, CONF_PORTS, PORT_SCHEMA - -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(PORT_SCHEMA) - - -async def async_setup_platform( - hass: HomeAssistant, - config: ConfigType, - async_add_entities: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Set up the Orange Pi GPIO platform.""" - binary_sensors = [] - invert_logic = config[CONF_INVERT_LOGIC] - pin_mode = config[CONF_PIN_MODE] - ports = config[CONF_PORTS] - - setup_mode(pin_mode) - - for port_num, port_name in ports.items(): - binary_sensors.append( - OPiGPIOBinarySensor(hass, port_name, port_num, invert_logic) - ) - async_add_entities(binary_sensors) - - -class OPiGPIOBinarySensor(BinarySensorEntity): - """Represent a binary sensor that uses Orange Pi GPIO.""" - - def __init__(self, hass, name, port, invert_logic): - """Initialize the Orange Pi binary sensor.""" - self._name = name - self._port = port - self._invert_logic = invert_logic - self._state = None - - async def async_added_to_hass(self): - """Run when entity about to be added to hass.""" - - def gpio_edge_listener(port): - """Update GPIO when edge change is detected.""" - self.schedule_update_ha_state(True) - - def setup_entity(): - setup_input(self._port) - edge_detect(self._port, gpio_edge_listener) - self.schedule_update_ha_state(True) - - await self.hass.async_add_executor_job(setup_entity) - - @property - def should_poll(self): - """No polling needed.""" - return False - - @property - def name(self): - """Return the name of the sensor.""" - return self._name - - @property - def is_on(self): - """Return the state of the entity.""" - return self._state != self._invert_logic - - def update(self): - """Update state with new GPIO data.""" - self._state = read_input(self._port) diff --git a/homeassistant/components/orangepi_gpio/const.py b/homeassistant/components/orangepi_gpio/const.py deleted file mode 100644 index f663fbc1ef4..00000000000 --- a/homeassistant/components/orangepi_gpio/const.py +++ /dev/null @@ -1,59 +0,0 @@ -"""Constants for Orange Pi GPIO.""" - -from nanopi import duo, neocore2 -from orangepi import ( - lite, - lite2, - one, - oneplus, - pc, - pc2, - pcplus, - pi3, - pi4, - pi4B, - plus2e, - prime, - r1, - winplus, - zero, - zeroplus, - zeroplus2, -) -import voluptuous as vol - -from homeassistant.helpers import config_validation as cv - -CONF_INVERT_LOGIC = "invert_logic" -CONF_PIN_MODE = "pin_mode" -CONF_PORTS = "ports" -DEFAULT_INVERT_LOGIC = False -PIN_MODES = { - "duo": duo.BOARD, - "lite": lite.BOARD, - "lite2": lite2.BOARD, - "neocore2": neocore2.BOARD, - "one": one.BOARD, - "oneplus": oneplus.BOARD, - "pc": pc.BOARD, - "pc2": pc2.BOARD, - "pcplus": pcplus.BOARD, - "pi3": pi3.BOARD, - "pi4": pi4.BOARD, - "pi4B": pi4B.BOARD, - "plus2e": plus2e.BOARD, - "prime": prime.BOARD, - "r1": r1.BOARD, - "winplus": winplus.BOARD, - "zero": zero.BOARD, - "zeroplus": zeroplus.BOARD, - "zeroplus2": zeroplus2.BOARD, -} - -_SENSORS_SCHEMA = vol.Schema({cv.positive_int: cv.string}) - -PORT_SCHEMA = { - vol.Required(CONF_PORTS): _SENSORS_SCHEMA, - vol.Required(CONF_PIN_MODE): vol.In(PIN_MODES.keys()), - vol.Optional(CONF_INVERT_LOGIC, default=DEFAULT_INVERT_LOGIC): cv.boolean, -} diff --git a/homeassistant/components/orangepi_gpio/manifest.json b/homeassistant/components/orangepi_gpio/manifest.json deleted file mode 100644 index b4cda33ee80..00000000000 --- a/homeassistant/components/orangepi_gpio/manifest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "domain": "orangepi_gpio", - "name": "Orange Pi GPIO", - "documentation": "https://www.home-assistant.io/integrations/orangepi_gpio", - "requirements": ["OPi.GPIO==0.5.2"], - "codeowners": ["@pascallj"], - "iot_class": "local_push", - "loggers": ["OPi", "nanopi", "orangepi"] -} diff --git a/requirements_all.txt b/requirements_all.txt index 68de5e3830e..1662428acef 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -19,9 +19,6 @@ HAP-python==4.4.0 # homeassistant.components.mastodon Mastodon.py==1.5.1 -# homeassistant.components.orangepi_gpio -OPi.GPIO==0.5.2 - # homeassistant.components.flick_electric PyFlick==0.0.2