Remove deprecated Arduino integration (#63406)

This commit is contained in:
Franck Nijhof 2022-01-05 09:15:50 +01:00 committed by GitHub
parent 0adc96348c
commit 56520b69ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 0 additions and 263 deletions

View File

@ -66,7 +66,6 @@ omit =
homeassistant/components/aquostv/media_player.py
homeassistant/components/arcam_fmj/media_player.py
homeassistant/components/arcam_fmj/__init__.py
homeassistant/components/arduino/*
homeassistant/components/arest/binary_sensor.py
homeassistant/components/arest/sensor.py
homeassistant/components/arest/switch.py

View File

@ -77,7 +77,6 @@ homeassistant/components/aprs/* @PhilRW
tests/components/aprs/* @PhilRW
homeassistant/components/arcam_fmj/* @elupus
tests/components/arcam_fmj/* @elupus
homeassistant/components/arduino/* @fabaff
homeassistant/components/arest/* @fabaff
homeassistant/components/arris_tg2492lg/* @vanbalken
homeassistant/components/aseko_pool_live/* @milanmeu

View File

@ -1,117 +0,0 @@
"""Support for Arduino boards running with the Firmata firmware."""
import logging
from PyMata.pymata import PyMata
import serial
import voluptuous as vol
from homeassistant.const import (
CONF_PORT,
EVENT_HOMEASSISTANT_START,
EVENT_HOMEASSISTANT_STOP,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__)
DOMAIN = "arduino"
CONFIG_SCHEMA = vol.Schema(
{DOMAIN: vol.Schema({vol.Required(CONF_PORT): cv.string})}, extra=vol.ALLOW_EXTRA
)
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Arduino component."""
_LOGGER.warning(
"The %s integration has been deprecated. Please move your "
"configuration to the firmata integration. "
"https://www.home-assistant.io/integrations/firmata",
DOMAIN,
)
port = config[DOMAIN][CONF_PORT]
try:
board = ArduinoBoard(port)
except (serial.serialutil.SerialException, FileNotFoundError):
_LOGGER.error("Your port %s is not accessible", port)
return False
try:
if board.get_firmata()[1] <= 2:
_LOGGER.error("The StandardFirmata sketch should be 2.2 or newer")
return False
except IndexError:
_LOGGER.warning(
"The version of the StandardFirmata sketch was not"
"detected. This may lead to side effects"
)
def stop_arduino(event):
"""Stop the Arduino service."""
board.disconnect()
def start_arduino(event):
"""Start the Arduino service."""
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_arduino)
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_arduino)
hass.data[DOMAIN] = board
return True
class ArduinoBoard:
"""Representation of an Arduino board."""
def __init__(self, port):
"""Initialize the board."""
self._port = port
self._board = PyMata(self._port, verbose=False)
def set_mode(self, pin, direction, mode):
"""Set the mode and the direction of a given pin."""
if mode == "analog" and direction == "in":
self._board.set_pin_mode(pin, self._board.INPUT, self._board.ANALOG)
elif mode == "analog" and direction == "out":
self._board.set_pin_mode(pin, self._board.OUTPUT, self._board.ANALOG)
elif mode == "digital" and direction == "in":
self._board.set_pin_mode(pin, self._board.INPUT, self._board.DIGITAL)
elif mode == "digital" and direction == "out":
self._board.set_pin_mode(pin, self._board.OUTPUT, self._board.DIGITAL)
elif mode == "pwm":
self._board.set_pin_mode(pin, self._board.OUTPUT, self._board.PWM)
def get_analog_inputs(self):
"""Get the values from the pins."""
self._board.capability_query()
return self._board.get_analog_response_table()
def set_digital_out_high(self, pin):
"""Set a given digital pin to high."""
self._board.digital_write(pin, 1)
def set_digital_out_low(self, pin):
"""Set a given digital pin to low."""
self._board.digital_write(pin, 0)
def get_digital_in(self, pin):
"""Get the value from a given digital pin."""
self._board.digital_read(pin)
def get_analog_in(self, pin):
"""Get the value from a given analog pin."""
self._board.analog_read(pin)
def get_firmata(self):
"""Return the version of the Firmata firmware."""
return self._board.get_firmata_version()
def disconnect(self):
"""Disconnect the board and close the serial connection."""
self._board.reset()
self._board.close()

View File

@ -1,8 +0,0 @@
{
"domain": "arduino",
"name": "Arduino",
"documentation": "https://www.home-assistant.io/integrations/arduino",
"requirements": ["PyMata==2.20"],
"codeowners": ["@fabaff"],
"iot_class": "local_polling"
}

View File

@ -1,55 +0,0 @@
"""Support for getting information from Arduino pins."""
from __future__ import annotations
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import CONF_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
from . import DOMAIN
CONF_PINS = "pins"
CONF_TYPE = "analog"
PIN_SCHEMA = vol.Schema({vol.Required(CONF_NAME): cv.string})
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{vol.Required(CONF_PINS): vol.Schema({cv.positive_int: PIN_SCHEMA})}
)
def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Arduino platform."""
board = hass.data[DOMAIN]
pins = config[CONF_PINS]
sensors = []
for pinnum, pin in pins.items():
sensors.append(ArduinoSensor(pin.get(CONF_NAME), pinnum, CONF_TYPE, board))
add_entities(sensors)
class ArduinoSensor(SensorEntity):
"""Representation of an Arduino Sensor."""
def __init__(self, name, pin, pin_type, board):
"""Initialize the sensor."""
self._pin = pin
self._attr_name = name
board.set_mode(self._pin, "in", pin_type)
self._board = board
def update(self):
"""Get the latest value from the pin."""
self._attr_native_value = self._board.get_analog_inputs()[self._pin][1]

View File

@ -1,78 +0,0 @@
"""Support for switching Arduino pins on and off."""
from __future__ import annotations
import voluptuous as vol
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
from homeassistant.const import CONF_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
from . import DOMAIN
CONF_PINS = "pins"
CONF_TYPE = "digital"
CONF_NEGATE = "negate"
CONF_INITIAL = "initial"
PIN_SCHEMA = vol.Schema(
{
vol.Required(CONF_NAME): cv.string,
vol.Optional(CONF_INITIAL, default=False): cv.boolean,
vol.Optional(CONF_NEGATE, default=False): cv.boolean,
}
)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{vol.Required(CONF_PINS, default={}): vol.Schema({cv.positive_int: PIN_SCHEMA})}
)
def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Arduino platform."""
board = hass.data[DOMAIN]
pins = config[CONF_PINS]
switches = []
for pinnum, pin in pins.items():
switches.append(ArduinoSwitch(pinnum, pin, board))
add_entities(switches)
class ArduinoSwitch(SwitchEntity):
"""Representation of an Arduino switch."""
def __init__(self, pin, options, board):
"""Initialize the Pin."""
self._pin = pin
self._attr_name = options[CONF_NAME]
self._attr_is_on = options[CONF_INITIAL]
if options[CONF_NEGATE]:
self.turn_on_handler = board.set_digital_out_low
self.turn_off_handler = board.set_digital_out_high
else:
self.turn_on_handler = board.set_digital_out_high
self.turn_off_handler = board.set_digital_out_low
board.set_mode(pin, "out", CONF_TYPE)
(self.turn_on_handler if self.is_on else self.turn_off_handler)(pin)
def turn_on(self, **kwargs):
"""Turn the pin to high/on."""
self._attr_is_on = True
self.turn_on_handler(self._pin)
def turn_off(self, **kwargs):
"""Turn the pin to low/off."""
self._attr_is_on = False
self.turn_off_handler(self._pin)

View File

@ -31,9 +31,6 @@ PyFlick==0.0.2
# homeassistant.components.mvglive
PyMVGLive==1.1.4
# homeassistant.components.arduino
PyMata==2.20
# homeassistant.components.mobile_app
# homeassistant.components.owntracks
PyNaCl==1.4.0