mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Remove deprecated BeagleBone Black GPIO integration (#67160)
This commit is contained in:
parent
21f3e5ef13
commit
12dbcca078
@ -101,7 +101,6 @@ omit =
|
|||||||
homeassistant/components/baidu/tts.py
|
homeassistant/components/baidu/tts.py
|
||||||
homeassistant/components/balboa/__init__.py
|
homeassistant/components/balboa/__init__.py
|
||||||
homeassistant/components/beewi_smartclim/sensor.py
|
homeassistant/components/beewi_smartclim/sensor.py
|
||||||
homeassistant/components/bbb_gpio/*
|
|
||||||
homeassistant/components/bbox/device_tracker.py
|
homeassistant/components/bbox/device_tracker.py
|
||||||
homeassistant/components/bbox/sensor.py
|
homeassistant/components/bbox/sensor.py
|
||||||
homeassistant/components/bh1750/sensor.py
|
homeassistant/components/bh1750/sensor.py
|
||||||
|
@ -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)
|
|
@ -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
|
|
@ -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"]
|
|
||||||
}
|
|
@ -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()
|
|
@ -10,9 +10,6 @@ Adafruit-GPIO==1.0.3
|
|||||||
# homeassistant.components.sht31
|
# homeassistant.components.sht31
|
||||||
Adafruit-SHT31==1.0.2
|
Adafruit-SHT31==1.0.2
|
||||||
|
|
||||||
# homeassistant.components.bbb_gpio
|
|
||||||
# Adafruit_BBIO==1.1.1
|
|
||||||
|
|
||||||
# homeassistant.components.adax
|
# homeassistant.components.adax
|
||||||
Adax-local==0.1.3
|
Adax-local==0.1.3
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user