From 636e4ed90b135a77bd9dd3955aa34be41b6e036f Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 24 Feb 2022 14:47:20 +0100 Subject: [PATCH] Remove deprecated Time of Flight integration (#67167) --- .coveragerc | 1 - homeassistant/components/tof/__init__.py | 1 - homeassistant/components/tof/manifest.json | 10 -- homeassistant/components/tof/sensor.py | 120 --------------------- requirements_all.txt | 3 - script/gen_requirements_all.py | 1 - 6 files changed, 136 deletions(-) delete mode 100644 homeassistant/components/tof/__init__.py delete mode 100644 homeassistant/components/tof/manifest.json delete mode 100644 homeassistant/components/tof/sensor.py diff --git a/.coveragerc b/.coveragerc index 360bd5f6911..ec22cbbfc67 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1244,7 +1244,6 @@ omit = homeassistant/components/tmb/sensor.py homeassistant/components/todoist/calendar.py homeassistant/components/todoist/const.py - homeassistant/components/tof/sensor.py homeassistant/components/tolo/__init__.py homeassistant/components/tolo/binary_sensor.py homeassistant/components/tolo/button.py diff --git a/homeassistant/components/tof/__init__.py b/homeassistant/components/tof/__init__.py deleted file mode 100644 index 0e72aca724b..00000000000 --- a/homeassistant/components/tof/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Platform for Time of Flight sensor VL53L1X from STMicroelectronics.""" diff --git a/homeassistant/components/tof/manifest.json b/homeassistant/components/tof/manifest.json deleted file mode 100644 index e530c67b930..00000000000 --- a/homeassistant/components/tof/manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "domain": "tof", - "name": "Time of Flight", - "documentation": "https://www.home-assistant.io/integrations/tof", - "requirements": ["VL53L1X2==0.1.5"], - "dependencies": ["rpi_gpio"], - "codeowners": [], - "iot_class": "local_polling", - "loggers": ["VL53L1X2"] -} diff --git a/homeassistant/components/tof/sensor.py b/homeassistant/components/tof/sensor.py deleted file mode 100644 index 2934aa744aa..00000000000 --- a/homeassistant/components/tof/sensor.py +++ /dev/null @@ -1,120 +0,0 @@ -"""Platform for Time of Flight sensor VL53L1X from STMicroelectronics.""" -from __future__ import annotations - -import asyncio -from functools import partial -import logging - -from VL53L1X2 import VL53L1X # pylint: disable=import-error -import voluptuous as vol - -from homeassistant.components import rpi_gpio -from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity -from homeassistant.const import CONF_NAME, LENGTH_MILLIMETERS -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_I2C_ADDRESS = "i2c_address" -CONF_I2C_BUS = "i2c_bus" -CONF_XSHUT = "xshut" - -DEFAULT_NAME = "VL53L1X" -DEFAULT_I2C_ADDRESS = 0x29 -DEFAULT_I2C_BUS = 1 -DEFAULT_XSHUT = 16 -DEFAULT_RANGE = 2 - -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - { - vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, - vol.Optional(CONF_I2C_ADDRESS, default=DEFAULT_I2C_ADDRESS): vol.Coerce(int), - vol.Optional(CONF_I2C_BUS, default=DEFAULT_I2C_BUS): vol.Coerce(int), - vol.Optional(CONF_XSHUT, default=DEFAULT_XSHUT): cv.positive_int, - } -) - -_LOGGER = logging.getLogger(__name__) - - -def init_tof_0(xshut, sensor): - """XSHUT port LOW resets the device.""" - sensor.open() - rpi_gpio.setup_output(xshut) - rpi_gpio.write_output(xshut, 0) - - -def init_tof_1(xshut): - """XSHUT port HIGH enables the device.""" - rpi_gpio.setup_output(xshut) - rpi_gpio.write_output(xshut, 1) - - -async def async_setup_platform( - hass: HomeAssistant, - config: ConfigType, - async_add_entities: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Reset and initialize the VL53L1X ToF Sensor from STMicroelectronics.""" - _LOGGER.warning( - "The Time of Flight 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" - ) - - name = config.get(CONF_NAME) - bus_number = config.get(CONF_I2C_BUS) - i2c_address = config.get(CONF_I2C_ADDRESS) - unit = LENGTH_MILLIMETERS - xshut = config.get(CONF_XSHUT) - - sensor = await hass.async_add_executor_job(partial(VL53L1X, bus_number)) - await hass.async_add_executor_job(init_tof_0, xshut, sensor) - await asyncio.sleep(0.01) - await hass.async_add_executor_job(init_tof_1, xshut) - await asyncio.sleep(0.01) - - dev = [VL53L1XSensor(sensor, name, unit, i2c_address)] - - async_add_entities(dev, True) - - -class VL53L1XSensor(SensorEntity): - """Implementation of VL53L1X sensor.""" - - def __init__(self, vl53l1x_sensor, name, unit, i2c_address): - """Initialize the sensor.""" - self._name = name - self._unit_of_measurement = unit - self.vl53l1x_sensor = vl53l1x_sensor - self.i2c_address = i2c_address - self._state = None - self.init = True - - @property - def name(self) -> str: - """Return the name of the sensor.""" - return self._name - - @property - def native_value(self) -> int: - """Return the state of the sensor.""" - return self._state - - @property - def native_unit_of_measurement(self) -> str: - """Return the unit of measurement.""" - return self._unit_of_measurement - - def update(self): - """Get the latest measurement and update state.""" - if self.init: - self.vl53l1x_sensor.add_sensor(self.i2c_address, self.i2c_address) - self.init = False - self.vl53l1x_sensor.start_ranging(self.i2c_address, DEFAULT_RANGE) - self.vl53l1x_sensor.update(self.i2c_address) - self.vl53l1x_sensor.stop_ranging(self.i2c_address) - self._state = self.vl53l1x_sensor.distance diff --git a/requirements_all.txt b/requirements_all.txt index 9b21741348f..300bf91f289 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -77,9 +77,6 @@ TravisPy==0.3.5 # homeassistant.components.twitter TwitterAPI==2.7.5 -# homeassistant.components.tof -# VL53L1X2==0.1.5 - # homeassistant.components.onvif WSDiscovery==2.0.0 diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py index fe8962e4f1e..6ebea07ae4b 100755 --- a/script/gen_requirements_all.py +++ b/script/gen_requirements_all.py @@ -44,7 +44,6 @@ COMMENT_REQUIREMENTS = ( "smbus-cffi", "tensorflow", "tf-models-official", - "VL53L1X2", ) COMMENT_REQUIREMENTS_NORMALIZED = {