mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
Remove the zengge integration (#141283)
This commit is contained in:
parent
93561543ff
commit
9fdb69c558
@ -2,138 +2,38 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from zengge import zengge
|
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import PLATFORM_SCHEMA as LIGHT_PLATFORM_SCHEMA
|
||||||
ATTR_BRIGHTNESS,
|
|
||||||
ATTR_HS_COLOR,
|
|
||||||
ATTR_WHITE,
|
|
||||||
PLATFORM_SCHEMA as LIGHT_PLATFORM_SCHEMA,
|
|
||||||
ColorMode,
|
|
||||||
LightEntity,
|
|
||||||
)
|
|
||||||
from homeassistant.const import CONF_DEVICES, CONF_NAME
|
from homeassistant.const import CONF_DEVICES, CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv, issue_registry as ir
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
from homeassistant.util import color as color_util
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
DEVICE_SCHEMA = vol.Schema({vol.Optional(CONF_NAME): cv.string})
|
DEVICE_SCHEMA = vol.Schema({vol.Optional(CONF_NAME): cv.string})
|
||||||
|
DOMAIN = "zengge"
|
||||||
|
|
||||||
PLATFORM_SCHEMA = LIGHT_PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = LIGHT_PLATFORM_SCHEMA.extend(
|
||||||
{vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA}}
|
{vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA}}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(
|
def async_setup_platform(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
add_entities: AddEntitiesCallback,
|
add_entities: AddEntitiesCallback,
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Zengge platform."""
|
"""Set up the Zengge platform."""
|
||||||
lights = []
|
ir.async_create_issue(
|
||||||
for address, device_config in config[CONF_DEVICES].items():
|
hass,
|
||||||
light = ZenggeLight(device_config[CONF_NAME], address)
|
DOMAIN,
|
||||||
if light.is_valid:
|
DOMAIN,
|
||||||
lights.append(light)
|
is_fixable=False,
|
||||||
|
severity=ir.IssueSeverity.ERROR,
|
||||||
add_entities(lights, True)
|
translation_key="integration_removed",
|
||||||
|
translation_placeholders={
|
||||||
|
"led_ble_url": "https://www.home-assistant.io/integrations/led_ble/",
|
||||||
class ZenggeLight(LightEntity):
|
},
|
||||||
"""Representation of a Zengge light."""
|
)
|
||||||
|
|
||||||
_attr_supported_color_modes = {ColorMode.HS, ColorMode.WHITE}
|
|
||||||
|
|
||||||
def __init__(self, name: str, address: str) -> None:
|
|
||||||
"""Initialize the light."""
|
|
||||||
|
|
||||||
self._attr_name = name
|
|
||||||
self._attr_unique_id = address
|
|
||||||
self.is_valid = True
|
|
||||||
self._bulb = zengge(address)
|
|
||||||
self._white = 0
|
|
||||||
self._attr_brightness = 0
|
|
||||||
self._attr_hs_color = (0, 0)
|
|
||||||
self._attr_is_on = False
|
|
||||||
if self._bulb.connect() is False:
|
|
||||||
self.is_valid = False
|
|
||||||
_LOGGER.error("Failed to connect to bulb %s, %s", address, name)
|
|
||||||
return
|
|
||||||
|
|
||||||
@property
|
|
||||||
def white_value(self) -> int:
|
|
||||||
"""Return the white property."""
|
|
||||||
return self._white
|
|
||||||
|
|
||||||
@property
|
|
||||||
def color_mode(self) -> ColorMode:
|
|
||||||
"""Return the current color mode."""
|
|
||||||
if self._white != 0:
|
|
||||||
return ColorMode.WHITE
|
|
||||||
return ColorMode.HS
|
|
||||||
|
|
||||||
def _set_rgb(self, red: int, green: int, blue: int) -> None:
|
|
||||||
"""Set the rgb state."""
|
|
||||||
self._bulb.set_rgb(red, green, blue)
|
|
||||||
|
|
||||||
def _set_white(self, white):
|
|
||||||
"""Set the white state."""
|
|
||||||
return self._bulb.set_white(white)
|
|
||||||
|
|
||||||
def turn_on(self, **kwargs: Any) -> None:
|
|
||||||
"""Turn the specified light on."""
|
|
||||||
self._attr_is_on = True
|
|
||||||
self._bulb.on()
|
|
||||||
|
|
||||||
hs_color = kwargs.get(ATTR_HS_COLOR)
|
|
||||||
white = kwargs.get(ATTR_WHITE)
|
|
||||||
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
|
||||||
|
|
||||||
if white is not None:
|
|
||||||
# Change the bulb to white
|
|
||||||
self._attr_brightness = white
|
|
||||||
self._white = white
|
|
||||||
self._attr_hs_color = (0, 0)
|
|
||||||
|
|
||||||
if hs_color is not None:
|
|
||||||
# Change the bulb to hs
|
|
||||||
self._white = 0
|
|
||||||
self._attr_hs_color = hs_color
|
|
||||||
|
|
||||||
if brightness is not None:
|
|
||||||
self._attr_brightness = brightness
|
|
||||||
|
|
||||||
if self._white != 0:
|
|
||||||
self._set_white(self.brightness)
|
|
||||||
else:
|
|
||||||
assert self.hs_color is not None
|
|
||||||
assert self.brightness is not None
|
|
||||||
rgb = color_util.color_hsv_to_RGB(
|
|
||||||
self.hs_color[0], self.hs_color[1], self.brightness / 255 * 100
|
|
||||||
)
|
|
||||||
self._set_rgb(*rgb)
|
|
||||||
|
|
||||||
def turn_off(self, **kwargs: Any) -> None:
|
|
||||||
"""Turn the specified light off."""
|
|
||||||
self._attr_is_on = False
|
|
||||||
self._bulb.off()
|
|
||||||
|
|
||||||
def update(self) -> None:
|
|
||||||
"""Synchronise internal state with the actual light state."""
|
|
||||||
rgb = self._bulb.get_colour()
|
|
||||||
hsv = color_util.color_RGB_to_hsv(*rgb)
|
|
||||||
self._attr_hs_color = hsv[:2]
|
|
||||||
self._attr_brightness = int((hsv[2] / 100) * 255)
|
|
||||||
self._white = self._bulb.get_white()
|
|
||||||
if self._white:
|
|
||||||
self._attr_brightness = self._white
|
|
||||||
self._attr_is_on = self._bulb.get_on()
|
|
||||||
|
@ -5,6 +5,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/zengge",
|
"documentation": "https://www.home-assistant.io/integrations/zengge",
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"loggers": ["zengge"],
|
"loggers": ["zengge"],
|
||||||
"quality_scale": "legacy",
|
"quality_scale": "legacy"
|
||||||
"requirements": ["bluepy==1.3.0", "zengge==0.2"]
|
|
||||||
}
|
}
|
||||||
|
8
homeassistant/components/zengge/strings.json
Normal file
8
homeassistant/components/zengge/strings.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"issues": {
|
||||||
|
"integration_removed": {
|
||||||
|
"title": "The Zengge integration has been removed",
|
||||||
|
"description": "The Zengge integration has been removed from Home Assistant. Support for Zengge lights is provided by the `led_ble` integration.\n\nTo resolve this issue, please remove the (now defunct) `zengge` light configuration from your Home Assistant configuration and [configure the `led_ble` integration]({led_ble_url})."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
requirements_all.txt
generated
4
requirements_all.txt
generated
@ -627,7 +627,6 @@ bluecurrent-api==1.2.3
|
|||||||
bluemaestro-ble==0.2.3
|
bluemaestro-ble==0.2.3
|
||||||
|
|
||||||
# homeassistant.components.decora
|
# homeassistant.components.decora
|
||||||
# homeassistant.components.zengge
|
|
||||||
# bluepy==1.3.0
|
# bluepy==1.3.0
|
||||||
|
|
||||||
# homeassistant.components.bluetooth
|
# homeassistant.components.bluetooth
|
||||||
@ -3143,9 +3142,6 @@ zabbix-utils==2.0.2
|
|||||||
# homeassistant.components.zamg
|
# homeassistant.components.zamg
|
||||||
zamg==0.3.6
|
zamg==0.3.6
|
||||||
|
|
||||||
# homeassistant.components.zengge
|
|
||||||
zengge==0.2
|
|
||||||
|
|
||||||
# homeassistant.components.zeroconf
|
# homeassistant.components.zeroconf
|
||||||
zeroconf==0.146.0
|
zeroconf==0.146.0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user