From e7e8ee5ff3aee0f2ddac0a45fcbb16f7fe6a4e92 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Fri, 25 Feb 2022 17:09:23 +0100 Subject: [PATCH] Remove deprecated pigpio Daemon PWM LED integration (#67187) --- .coveragerc | 1 - CODEOWNERS | 1 - .../components/rpi_gpio_pwm/__init__.py | 1 - .../components/rpi_gpio_pwm/light.py | 259 ------------------ .../components/rpi_gpio_pwm/manifest.json | 9 - requirements_all.txt | 3 - 6 files changed, 274 deletions(-) delete mode 100644 homeassistant/components/rpi_gpio_pwm/__init__.py delete mode 100644 homeassistant/components/rpi_gpio_pwm/light.py delete mode 100644 homeassistant/components/rpi_gpio_pwm/manifest.json diff --git a/.coveragerc b/.coveragerc index 38d2197701d..7116cab0ceb 100644 --- a/.coveragerc +++ b/.coveragerc @@ -993,7 +993,6 @@ omit = homeassistant/components/rova/sensor.py homeassistant/components/rpi_camera/* homeassistant/components/rpi_gpio/* - homeassistant/components/rpi_gpio_pwm/light.py homeassistant/components/rpi_pfio/* homeassistant/components/rpi_rf/switch.py homeassistant/components/rtorrent/sensor.py diff --git a/CODEOWNERS b/CODEOWNERS index 643c287e04a..574d559cfa4 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -797,7 +797,6 @@ homeassistant/components/roomba/* @pschmitt @cyr-ius @shenxn tests/components/roomba/* @pschmitt @cyr-ius @shenxn homeassistant/components/roon/* @pavoni tests/components/roon/* @pavoni -homeassistant/components/rpi_gpio_pwm/* @soldag homeassistant/components/rpi_power/* @shenxn @swetoast tests/components/rpi_power/* @shenxn @swetoast homeassistant/components/rtsp_to_webrtc/* @allenporter diff --git a/homeassistant/components/rpi_gpio_pwm/__init__.py b/homeassistant/components/rpi_gpio_pwm/__init__.py deleted file mode 100644 index 46aa24c12e6..00000000000 --- a/homeassistant/components/rpi_gpio_pwm/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""The rpi_gpio_pwm component.""" diff --git a/homeassistant/components/rpi_gpio_pwm/light.py b/homeassistant/components/rpi_gpio_pwm/light.py deleted file mode 100644 index 02444f902b4..00000000000 --- a/homeassistant/components/rpi_gpio_pwm/light.py +++ /dev/null @@ -1,259 +0,0 @@ -"""Support for LED lights that can be controlled using PWM.""" -from __future__ import annotations - -import logging - -from pwmled import Color -from pwmled.driver.gpio import GpioDriver -from pwmled.driver.pca9685 import Pca9685Driver -from pwmled.led import SimpleLed -from pwmled.led.rgb import RgbLed -from pwmled.led.rgbw import RgbwLed -import voluptuous as vol - -from homeassistant.components.light import ( - ATTR_BRIGHTNESS, - ATTR_HS_COLOR, - ATTR_TRANSITION, - PLATFORM_SCHEMA, - SUPPORT_BRIGHTNESS, - SUPPORT_COLOR, - SUPPORT_TRANSITION, - LightEntity, -) -from homeassistant.const import CONF_ADDRESS, CONF_HOST, CONF_NAME, CONF_TYPE, STATE_ON -from homeassistant.core import HomeAssistant -import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.restore_state import RestoreEntity -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -import homeassistant.util.color as color_util - -_LOGGER = logging.getLogger(__name__) - -CONF_LEDS = "leds" -CONF_DRIVER = "driver" -CONF_PINS = "pins" -CONF_FREQUENCY = "frequency" - -CONF_DRIVER_GPIO = "gpio" -CONF_DRIVER_PCA9685 = "pca9685" -CONF_DRIVER_TYPES = [CONF_DRIVER_GPIO, CONF_DRIVER_PCA9685] - -CONF_LED_TYPE_SIMPLE = "simple" -CONF_LED_TYPE_RGB = "rgb" -CONF_LED_TYPE_RGBW = "rgbw" -CONF_LED_TYPES = [CONF_LED_TYPE_SIMPLE, CONF_LED_TYPE_RGB, CONF_LED_TYPE_RGBW] - -DEFAULT_BRIGHTNESS = 255 -DEFAULT_COLOR = [0, 0] - -SUPPORT_SIMPLE_LED = SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION -SUPPORT_RGB_LED = SUPPORT_BRIGHTNESS | SUPPORT_COLOR | SUPPORT_TRANSITION - -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - { - vol.Required(CONF_LEDS): vol.All( - cv.ensure_list, - [ - { - vol.Required(CONF_NAME): cv.string, - vol.Required(CONF_DRIVER): vol.In(CONF_DRIVER_TYPES), - vol.Required(CONF_PINS): vol.All(cv.ensure_list, [cv.positive_int]), - vol.Required(CONF_TYPE): vol.In(CONF_LED_TYPES), - vol.Optional(CONF_FREQUENCY): cv.positive_int, - vol.Optional(CONF_ADDRESS): cv.byte, - vol.Optional(CONF_HOST): cv.string, - } - ], - ) - } -) - - -def setup_platform( - hass: HomeAssistant, - config: ConfigType, - add_entities: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Set up the PWM LED lights.""" - _LOGGER.warning( - "The pigpio Daemon PWM LED 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" - ) - - leds = [] - for led_conf in config[CONF_LEDS]: - driver_type = led_conf[CONF_DRIVER] - pins = led_conf[CONF_PINS] - opt_args = {} - if CONF_FREQUENCY in led_conf: - opt_args["freq"] = led_conf[CONF_FREQUENCY] - if driver_type == CONF_DRIVER_GPIO: - if CONF_HOST in led_conf: - opt_args["host"] = led_conf[CONF_HOST] - driver = GpioDriver(pins, **opt_args) - elif driver_type == CONF_DRIVER_PCA9685: - if CONF_ADDRESS in led_conf: - opt_args["address"] = led_conf[CONF_ADDRESS] - driver = Pca9685Driver(pins, **opt_args) - else: - _LOGGER.error("Invalid driver type") - return - - name = led_conf[CONF_NAME] - led_type = led_conf[CONF_TYPE] - if led_type == CONF_LED_TYPE_SIMPLE: - led = PwmSimpleLed(SimpleLed(driver), name) - elif led_type == CONF_LED_TYPE_RGB: - led = PwmRgbLed(RgbLed(driver), name) - elif led_type == CONF_LED_TYPE_RGBW: - led = PwmRgbLed(RgbwLed(driver), name) - else: - _LOGGER.error("Invalid led type") - return - leds.append(led) - - add_entities(leds) - - -class PwmSimpleLed(LightEntity, RestoreEntity): - """Representation of a simple one-color PWM LED.""" - - def __init__(self, led, name): - """Initialize one-color PWM LED.""" - self._led = led - self._name = name - self._is_on = False - self._brightness = DEFAULT_BRIGHTNESS - - async def async_added_to_hass(self): - """Handle entity about to be added to hass event.""" - await super().async_added_to_hass() - if last_state := await self.async_get_last_state(): - self._is_on = last_state.state == STATE_ON - self._brightness = last_state.attributes.get( - "brightness", DEFAULT_BRIGHTNESS - ) - - @property - def should_poll(self): - """No polling needed.""" - return False - - @property - def name(self): - """Return the name of the group.""" - return self._name - - @property - def is_on(self): - """Return true if device is on.""" - return self._is_on - - @property - def brightness(self): - """Return the brightness property.""" - return self._brightness - - @property - def supported_features(self): - """Flag supported features.""" - return SUPPORT_SIMPLE_LED - - def turn_on(self, **kwargs): - """Turn on a led.""" - if ATTR_BRIGHTNESS in kwargs: - self._brightness = kwargs[ATTR_BRIGHTNESS] - - if ATTR_TRANSITION in kwargs: - transition_time = kwargs[ATTR_TRANSITION] - self._led.transition( - transition_time, - is_on=True, - brightness=_from_hass_brightness(self._brightness), - ) - else: - self._led.set( - is_on=True, brightness=_from_hass_brightness(self._brightness) - ) - - self._is_on = True - self.schedule_update_ha_state() - - def turn_off(self, **kwargs): - """Turn off a LED.""" - if self.is_on: - if ATTR_TRANSITION in kwargs: - transition_time = kwargs[ATTR_TRANSITION] - self._led.transition(transition_time, is_on=False) - else: - self._led.off() - - self._is_on = False - self.schedule_update_ha_state() - - -class PwmRgbLed(PwmSimpleLed): - """Representation of a RGB(W) PWM LED.""" - - def __init__(self, led, name): - """Initialize a RGB(W) PWM LED.""" - super().__init__(led, name) - self._color = DEFAULT_COLOR - - async def async_added_to_hass(self): - """Handle entity about to be added to hass event.""" - await super().async_added_to_hass() - if last_state := await self.async_get_last_state(): - self._color = last_state.attributes.get("hs_color", DEFAULT_COLOR) - - @property - def hs_color(self): - """Return the color property.""" - return self._color - - @property - def supported_features(self): - """Flag supported features.""" - return SUPPORT_RGB_LED - - def turn_on(self, **kwargs): - """Turn on a LED.""" - if ATTR_HS_COLOR in kwargs: - self._color = kwargs[ATTR_HS_COLOR] - if ATTR_BRIGHTNESS in kwargs: - self._brightness = kwargs[ATTR_BRIGHTNESS] - - if ATTR_TRANSITION in kwargs: - transition_time = kwargs[ATTR_TRANSITION] - self._led.transition( - transition_time, - is_on=True, - brightness=_from_hass_brightness(self._brightness), - color=_from_hass_color(self._color), - ) - else: - self._led.set( - is_on=True, - brightness=_from_hass_brightness(self._brightness), - color=_from_hass_color(self._color), - ) - - self._is_on = True - self.schedule_update_ha_state() - - -def _from_hass_brightness(brightness): - """Convert Home Assistant brightness units to percentage.""" - return brightness / 255 - - -def _from_hass_color(color): - """Convert Home Assistant RGB list to Color tuple.""" - - rgb = color_util.color_hs_to_RGB(*color) - return Color(*tuple(rgb)) diff --git a/homeassistant/components/rpi_gpio_pwm/manifest.json b/homeassistant/components/rpi_gpio_pwm/manifest.json deleted file mode 100644 index 403f607e379..00000000000 --- a/homeassistant/components/rpi_gpio_pwm/manifest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "domain": "rpi_gpio_pwm", - "name": "pigpio Daemon PWM LED", - "documentation": "https://www.home-assistant.io/integrations/rpi_gpio_pwm", - "requirements": ["pwmled==1.6.10"], - "codeowners": ["@soldag"], - "iot_class": "local_push", - "loggers": ["adafruit_blinka", "adafruit_circuitpython_pca9685", "pwmled"] -} diff --git a/requirements_all.txt b/requirements_all.txt index a07faa1e3d6..3b3ebfccd5a 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1289,9 +1289,6 @@ pushover_complete==1.1.1 # homeassistant.components.pvoutput pvo==0.2.2 -# homeassistant.components.rpi_gpio_pwm -pwmled==1.6.10 - # homeassistant.components.canary py-canary==0.5.1