Skip to content

Commit 9fdb69c

Browse files
authored
Remove the zengge integration (#141283)
1 parent 9356154 commit 9fdb69c

File tree

4 files changed

+24
-121
lines changed

4 files changed

+24
-121
lines changed

homeassistant/components/zengge/light.py

Lines changed: 15 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -2,138 +2,38 @@
22

33
from __future__ import annotations
44

5-
import logging
6-
from typing import Any
7-
85
import voluptuous as vol
9-
from zengge import zengge
106

11-
from homeassistant.components.light import (
12-
ATTR_BRIGHTNESS,
13-
ATTR_HS_COLOR,
14-
ATTR_WHITE,
15-
PLATFORM_SCHEMA as LIGHT_PLATFORM_SCHEMA,
16-
ColorMode,
17-
LightEntity,
18-
)
7+
from homeassistant.components.light import PLATFORM_SCHEMA as LIGHT_PLATFORM_SCHEMA
198
from homeassistant.const import CONF_DEVICES, CONF_NAME
209
from homeassistant.core import HomeAssistant
21-
from homeassistant.helpers import config_validation as cv
10+
from homeassistant.helpers import config_validation as cv, issue_registry as ir
2211
from homeassistant.helpers.entity_platform import AddEntitiesCallback
2312
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
24-
from homeassistant.util import color as color_util
25-
26-
_LOGGER = logging.getLogger(__name__)
2713

2814
DEVICE_SCHEMA = vol.Schema({vol.Optional(CONF_NAME): cv.string})
15+
DOMAIN = "zengge"
2916

3017
PLATFORM_SCHEMA = LIGHT_PLATFORM_SCHEMA.extend(
3118
{vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA}}
3219
)
3320

3421

35-
def setup_platform(
22+
def async_setup_platform(
3623
hass: HomeAssistant,
3724
config: ConfigType,
3825
add_entities: AddEntitiesCallback,
3926
discovery_info: DiscoveryInfoType | None = None,
4027
) -> None:
4128
"""Set up the Zengge platform."""
42-
lights = []
43-
for address, device_config in config[CONF_DEVICES].items():
44-
light = ZenggeLight(device_config[CONF_NAME], address)
45-
if light.is_valid:
46-
lights.append(light)
47-
48-
add_entities(lights, True)
49-
50-
51-
class ZenggeLight(LightEntity):
52-
"""Representation of a Zengge light."""
53-
54-
_attr_supported_color_modes = {ColorMode.HS, ColorMode.WHITE}
55-
56-
def __init__(self, name: str, address: str) -> None:
57-
"""Initialize the light."""
58-
59-
self._attr_name = name
60-
self._attr_unique_id = address
61-
self.is_valid = True
62-
self._bulb = zengge(address)
63-
self._white = 0
64-
self._attr_brightness = 0
65-
self._attr_hs_color = (0, 0)
66-
self._attr_is_on = False
67-
if self._bulb.connect() is False:
68-
self.is_valid = False
69-
_LOGGER.error("Failed to connect to bulb %s, %s", address, name)
70-
return
71-
72-
@property
73-
def white_value(self) -> int:
74-
"""Return the white property."""
75-
return self._white
76-
77-
@property
78-
def color_mode(self) -> ColorMode:
79-
"""Return the current color mode."""
80-
if self._white != 0:
81-
return ColorMode.WHITE
82-
return ColorMode.HS
83-
84-
def _set_rgb(self, red: int, green: int, blue: int) -> None:
85-
"""Set the rgb state."""
86-
self._bulb.set_rgb(red, green, blue)
87-
88-
def _set_white(self, white):
89-
"""Set the white state."""
90-
return self._bulb.set_white(white)
91-
92-
def turn_on(self, **kwargs: Any) -> None:
93-
"""Turn the specified light on."""
94-
self._attr_is_on = True
95-
self._bulb.on()
96-
97-
hs_color = kwargs.get(ATTR_HS_COLOR)
98-
white = kwargs.get(ATTR_WHITE)
99-
brightness = kwargs.get(ATTR_BRIGHTNESS)
100-
101-
if white is not None:
102-
# Change the bulb to white
103-
self._attr_brightness = white
104-
self._white = white
105-
self._attr_hs_color = (0, 0)
106-
107-
if hs_color is not None:
108-
# Change the bulb to hs
109-
self._white = 0
110-
self._attr_hs_color = hs_color
111-
112-
if brightness is not None:
113-
self._attr_brightness = brightness
114-
115-
if self._white != 0:
116-
self._set_white(self.brightness)
117-
else:
118-
assert self.hs_color is not None
119-
assert self.brightness is not None
120-
rgb = color_util.color_hsv_to_RGB(
121-
self.hs_color[0], self.hs_color[1], self.brightness / 255 * 100
122-
)
123-
self._set_rgb(*rgb)
124-
125-
def turn_off(self, **kwargs: Any) -> None:
126-
"""Turn the specified light off."""
127-
self._attr_is_on = False
128-
self._bulb.off()
129-
130-
def update(self) -> None:
131-
"""Synchronise internal state with the actual light state."""
132-
rgb = self._bulb.get_colour()
133-
hsv = color_util.color_RGB_to_hsv(*rgb)
134-
self._attr_hs_color = hsv[:2]
135-
self._attr_brightness = int((hsv[2] / 100) * 255)
136-
self._white = self._bulb.get_white()
137-
if self._white:
138-
self._attr_brightness = self._white
139-
self._attr_is_on = self._bulb.get_on()
29+
ir.async_create_issue(
30+
hass,
31+
DOMAIN,
32+
DOMAIN,
33+
is_fixable=False,
34+
severity=ir.IssueSeverity.ERROR,
35+
translation_key="integration_removed",
36+
translation_placeholders={
37+
"led_ble_url": "https://www.home-assistant.io/integrations/led_ble/",
38+
},
39+
)

homeassistant/components/zengge/manifest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
"documentation": "https://www.home-assistant.io/integrations/zengge",
66
"iot_class": "local_polling",
77
"loggers": ["zengge"],
8-
"quality_scale": "legacy",
9-
"requirements": ["bluepy==1.3.0", "zengge==0.2"]
8+
"quality_scale": "legacy"
109
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"issues": {
3+
"integration_removed": {
4+
"title": "The Zengge integration has been removed",
5+
"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})."
6+
}
7+
}
8+
}

requirements_all.txt

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)