1
mirror of https://github.com/home-assistant/core synced 2024-07-27 18:58:57 +02:00

Remove deprecated Orange Pi GPIO integration (#67177)

This commit is contained in:
Franck Nijhof 2022-02-24 22:46:59 +01:00 committed by GitHub
parent 00c6e30988
commit ba6493d66f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 0 additions and 209 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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,
}

View File

@ -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"]
}

View File

@ -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