mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Remove deprecated PiFace Digital I/O (PFIO) integration (#67282)
This commit is contained in:
parent
d41eeaa88b
commit
2bb5573ddc
@ -983,7 +983,6 @@ omit =
|
||||
homeassistant/components/rova/sensor.py
|
||||
homeassistant/components/rpi_camera/*
|
||||
homeassistant/components/rpi_gpio/*
|
||||
homeassistant/components/rpi_pfio/*
|
||||
homeassistant/components/rtorrent/sensor.py
|
||||
homeassistant/components/russound_rio/media_player.py
|
||||
homeassistant/components/russound_rnet/media_player.py
|
||||
|
@ -1,62 +0,0 @@
|
||||
"""Support for controlling the PiFace Digital I/O module on a RPi."""
|
||||
import logging
|
||||
|
||||
import pifacedigitalio as PFIO
|
||||
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
DOMAIN = "rpi_pfio"
|
||||
|
||||
DATA_PFIO_LISTENER = "pfio_listener"
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the Raspberry PI PFIO component."""
|
||||
_LOGGER.warning(
|
||||
"The PiFace Digital I/O (PFIO) 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"
|
||||
)
|
||||
|
||||
pifacedigital = PFIO.PiFaceDigital()
|
||||
hass.data[DATA_PFIO_LISTENER] = PFIO.InputEventListener(chip=pifacedigital)
|
||||
|
||||
def cleanup_pfio(event):
|
||||
"""Stuff to do before stopping."""
|
||||
PFIO.deinit()
|
||||
|
||||
def prepare_pfio(event):
|
||||
"""Stuff to do when Home Assistant starts."""
|
||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, cleanup_pfio)
|
||||
|
||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, prepare_pfio)
|
||||
PFIO.init()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def write_output(port, value):
|
||||
"""Write a value to a PFIO."""
|
||||
PFIO.digital_write(port, value)
|
||||
|
||||
|
||||
def read_input(port):
|
||||
"""Read a value from a PFIO."""
|
||||
return PFIO.digital_read(port)
|
||||
|
||||
|
||||
def edge_detect(hass, port, event_callback, settle):
|
||||
"""Add detection for RISING and FALLING events."""
|
||||
hass.data[DATA_PFIO_LISTENER].register(
|
||||
port, PFIO.IODIR_BOTH, event_callback, settle_time=settle
|
||||
)
|
||||
|
||||
|
||||
def activate_listener(hass):
|
||||
"""Activate the registered listener events."""
|
||||
hass.data[DATA_PFIO_LISTENER].activate()
|
@ -1,90 +0,0 @@
|
||||
"""Support for binary sensor using the PiFace Digital I/O module on a RPi."""
|
||||
from __future__ import annotations
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import rpi_pfio
|
||||
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_INVERT_LOGIC = "invert_logic"
|
||||
CONF_PORTS = "ports"
|
||||
CONF_SETTLE_TIME = "settle_time"
|
||||
|
||||
DEFAULT_INVERT_LOGIC = False
|
||||
DEFAULT_SETTLE_TIME = 20
|
||||
|
||||
PORT_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_NAME): cv.string,
|
||||
vol.Optional(CONF_SETTLE_TIME, default=DEFAULT_SETTLE_TIME): cv.positive_int,
|
||||
vol.Optional(CONF_INVERT_LOGIC, default=DEFAULT_INVERT_LOGIC): cv.boolean,
|
||||
}
|
||||
)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{vol.Optional(CONF_PORTS, default={}): vol.Schema({cv.positive_int: PORT_SCHEMA})}
|
||||
)
|
||||
|
||||
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the PiFace Digital Input devices."""
|
||||
binary_sensors = []
|
||||
ports = config[CONF_PORTS]
|
||||
for port, port_entity in ports.items():
|
||||
name = port_entity.get(CONF_NAME)
|
||||
settle_time = port_entity[CONF_SETTLE_TIME] / 1000
|
||||
invert_logic = port_entity[CONF_INVERT_LOGIC]
|
||||
|
||||
binary_sensors.append(
|
||||
RPiPFIOBinarySensor(hass, port, name, settle_time, invert_logic)
|
||||
)
|
||||
add_entities(binary_sensors, True)
|
||||
|
||||
rpi_pfio.activate_listener(hass)
|
||||
|
||||
|
||||
class RPiPFIOBinarySensor(BinarySensorEntity):
|
||||
"""Represent a binary sensor that a PiFace Digital Input."""
|
||||
|
||||
def __init__(self, hass, port, name, settle_time, invert_logic):
|
||||
"""Initialize the RPi binary sensor."""
|
||||
self._port = port
|
||||
self._name = name or DEVICE_DEFAULT_NAME
|
||||
self._invert_logic = invert_logic
|
||||
self._state = None
|
||||
|
||||
def read_pfio(port):
|
||||
"""Read state from PFIO."""
|
||||
self._state = rpi_pfio.read_input(self._port)
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
rpi_pfio.edge_detect(hass, self._port, read_pfio, settle_time)
|
||||
|
||||
@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 the PFIO state."""
|
||||
self._state = rpi_pfio.read_input(self._port)
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"domain": "rpi_pfio",
|
||||
"name": "PiFace Digital I/O (PFIO)",
|
||||
"documentation": "https://www.home-assistant.io/integrations/rpi_pfio",
|
||||
"requirements": ["pifacecommon==4.2.2", "pifacedigitalio==3.0.5"],
|
||||
"codeowners": [],
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["pifacedigitalio"]
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
"""Support for switches using the PiFace Digital I/O module on a RPi."""
|
||||
from __future__ import annotations
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import rpi_pfio
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
||||
from homeassistant.const import ATTR_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
|
||||
|
||||
ATTR_INVERT_LOGIC = "invert_logic"
|
||||
|
||||
CONF_PORTS = "ports"
|
||||
|
||||
DEFAULT_INVERT_LOGIC = False
|
||||
|
||||
PORT_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(ATTR_NAME): cv.string,
|
||||
vol.Optional(ATTR_INVERT_LOGIC, default=DEFAULT_INVERT_LOGIC): cv.boolean,
|
||||
}
|
||||
)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{vol.Optional(CONF_PORTS, default={}): vol.Schema({cv.positive_int: PORT_SCHEMA})}
|
||||
)
|
||||
|
||||
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the PiFace Digital Output devices."""
|
||||
switches = []
|
||||
ports = config[CONF_PORTS]
|
||||
for port, port_entity in ports.items():
|
||||
name = port_entity.get(ATTR_NAME)
|
||||
invert_logic = port_entity[ATTR_INVERT_LOGIC]
|
||||
|
||||
switches.append(RPiPFIOSwitch(port, name, invert_logic))
|
||||
add_entities(switches)
|
||||
|
||||
|
||||
class RPiPFIOSwitch(SwitchEntity):
|
||||
"""Representation of a PiFace Digital Output."""
|
||||
|
||||
def __init__(self, port, name, invert_logic):
|
||||
"""Initialize the pin."""
|
||||
self._port = port
|
||||
self._name = name or DEVICE_DEFAULT_NAME
|
||||
self._invert_logic = invert_logic
|
||||
self._state = False
|
||||
rpi_pfio.write_output(self._port, 1 if self._invert_logic else 0)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the switch."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""Return the polling state."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if device is on."""
|
||||
return self._state
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn the device on."""
|
||||
rpi_pfio.write_output(self._port, 0 if self._invert_logic else 1)
|
||||
self._state = True
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn the device off."""
|
||||
rpi_pfio.write_output(self._port, 1 if self._invert_logic else 0)
|
||||
self._state = False
|
||||
self.schedule_update_ha_state()
|
@ -1192,12 +1192,6 @@ phone_modem==0.1.1
|
||||
# homeassistant.components.onewire
|
||||
pi1wire==0.1.0
|
||||
|
||||
# homeassistant.components.rpi_pfio
|
||||
pifacecommon==4.2.2
|
||||
|
||||
# homeassistant.components.rpi_pfio
|
||||
pifacedigitalio==3.0.5
|
||||
|
||||
# homeassistant.components.pilight
|
||||
pilight==0.1.1
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user