mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Remove deprecated Time of Flight integration (#67167)
This commit is contained in:
parent
9131fb39fe
commit
636e4ed90b
@ -1244,7 +1244,6 @@ omit =
|
|||||||
homeassistant/components/tmb/sensor.py
|
homeassistant/components/tmb/sensor.py
|
||||||
homeassistant/components/todoist/calendar.py
|
homeassistant/components/todoist/calendar.py
|
||||||
homeassistant/components/todoist/const.py
|
homeassistant/components/todoist/const.py
|
||||||
homeassistant/components/tof/sensor.py
|
|
||||||
homeassistant/components/tolo/__init__.py
|
homeassistant/components/tolo/__init__.py
|
||||||
homeassistant/components/tolo/binary_sensor.py
|
homeassistant/components/tolo/binary_sensor.py
|
||||||
homeassistant/components/tolo/button.py
|
homeassistant/components/tolo/button.py
|
||||||
|
@ -1 +0,0 @@
|
|||||||
"""Platform for Time of Flight sensor VL53L1X from STMicroelectronics."""
|
|
@ -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"]
|
|
||||||
}
|
|
@ -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
|
|
@ -77,9 +77,6 @@ TravisPy==0.3.5
|
|||||||
# homeassistant.components.twitter
|
# homeassistant.components.twitter
|
||||||
TwitterAPI==2.7.5
|
TwitterAPI==2.7.5
|
||||||
|
|
||||||
# homeassistant.components.tof
|
|
||||||
# VL53L1X2==0.1.5
|
|
||||||
|
|
||||||
# homeassistant.components.onvif
|
# homeassistant.components.onvif
|
||||||
WSDiscovery==2.0.0
|
WSDiscovery==2.0.0
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ COMMENT_REQUIREMENTS = (
|
|||||||
"smbus-cffi",
|
"smbus-cffi",
|
||||||
"tensorflow",
|
"tensorflow",
|
||||||
"tf-models-official",
|
"tf-models-official",
|
||||||
"VL53L1X2",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
COMMENT_REQUIREMENTS_NORMALIZED = {
|
COMMENT_REQUIREMENTS_NORMALIZED = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user