Bump pyfritzhome to 0.6.8 and add support for Non-Color-Bulbs (#89141)
parent
18cb53a35c
commit
7d97653895
|
@ -72,8 +72,10 @@ class FritzboxLight(FritzBoxDeviceEntity, LightEntity):
|
|||
"""Initialize the FritzboxLight entity."""
|
||||
super().__init__(coordinator, ain, None)
|
||||
|
||||
self._attr_max_color_temp_kelvin = int(max(supported_color_temps))
|
||||
self._attr_min_color_temp_kelvin = int(min(supported_color_temps))
|
||||
if supported_color_temps:
|
||||
# only available for color bulbs
|
||||
self._attr_max_color_temp_kelvin = int(max(supported_color_temps))
|
||||
self._attr_min_color_temp_kelvin = int(min(supported_color_temps))
|
||||
|
||||
# Fritz!DECT 500 only supports 12 values for hue, with 3 saturations each.
|
||||
# Map supported colors to dict {hue: [sat1, sat2, sat3]} for easier lookup
|
||||
|
@ -125,7 +127,11 @@ class FritzboxLight(FritzBoxDeviceEntity, LightEntity):
|
|||
@property
|
||||
def supported_color_modes(self) -> set[ColorMode]:
|
||||
"""Flag supported color modes."""
|
||||
return SUPPORTED_COLOR_MODES
|
||||
if self.data.has_color:
|
||||
return SUPPORTED_COLOR_MODES
|
||||
if self.data.has_level:
|
||||
return {ColorMode.BRIGHTNESS}
|
||||
return {ColorMode.ONOFF}
|
||||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the light on."""
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"integration_type": "hub",
|
||||
"iot_class": "local_polling",
|
||||
"loggers": ["pyfritzhome"],
|
||||
"requirements": ["pyfritzhome==0.6.7"],
|
||||
"requirements": ["pyfritzhome==0.6.8"],
|
||||
"ssdp": [
|
||||
{
|
||||
"st": "urn:schemas-upnp-org:device:fritzbox:1"
|
||||
|
|
|
@ -1645,7 +1645,7 @@ pyforked-daapd==0.1.14
|
|||
pyfreedompro==1.1.0
|
||||
|
||||
# homeassistant.components.fritzbox
|
||||
pyfritzhome==0.6.7
|
||||
pyfritzhome==0.6.8
|
||||
|
||||
# homeassistant.components.fronius
|
||||
pyfronius==0.7.1
|
||||
|
|
|
@ -1182,7 +1182,7 @@ pyforked-daapd==0.1.14
|
|||
pyfreedompro==1.1.0
|
||||
|
||||
# homeassistant.components.fritzbox
|
||||
pyfritzhome==0.6.7
|
||||
pyfritzhome==0.6.8
|
||||
|
||||
# homeassistant.components.fronius
|
||||
pyfronius==0.7.1
|
||||
|
|
|
@ -151,6 +151,8 @@ class FritzDeviceLightMock(FritzEntityBaseMock):
|
|||
has_alarm = False
|
||||
has_powermeter = False
|
||||
has_lightbulb = True
|
||||
has_color = True
|
||||
has_level = True
|
||||
has_switch = False
|
||||
has_temperature_sensor = False
|
||||
has_thermostat = False
|
||||
|
|
|
@ -15,6 +15,7 @@ from homeassistant.components.light import (
|
|||
ATTR_HS_COLOR,
|
||||
ATTR_MAX_COLOR_TEMP_KELVIN,
|
||||
ATTR_MIN_COLOR_TEMP_KELVIN,
|
||||
ATTR_SUPPORTED_COLOR_MODES,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
|
@ -57,6 +58,46 @@ async def test_setup(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
assert state.attributes[ATTR_COLOR_TEMP_KELVIN] == 2700
|
||||
assert state.attributes[ATTR_MIN_COLOR_TEMP_KELVIN] == 2700
|
||||
assert state.attributes[ATTR_MAX_COLOR_TEMP_KELVIN] == 6500
|
||||
assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == ["color_temp", "hs"]
|
||||
|
||||
|
||||
async def test_setup_non_color(hass: HomeAssistant, fritz: Mock) -> None:
|
||||
"""Test setup of platform of non color bulb."""
|
||||
device = FritzDeviceLightMock()
|
||||
device.has_color = False
|
||||
device.get_color_temps.return_value = []
|
||||
device.get_colors.return_value = {}
|
||||
|
||||
assert await setup_config_entry(
|
||||
hass, MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0], ENTITY_ID, device, fritz
|
||||
)
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes[ATTR_FRIENDLY_NAME] == "fake_name"
|
||||
assert state.attributes[ATTR_BRIGHTNESS] == 100
|
||||
assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == ["brightness"]
|
||||
|
||||
|
||||
async def test_setup_non_color_non_level(hass: HomeAssistant, fritz: Mock) -> None:
|
||||
"""Test setup of platform of non color and non level bulb."""
|
||||
device = FritzDeviceLightMock()
|
||||
device.has_color = False
|
||||
device.has_level = False
|
||||
device.get_color_temps.return_value = []
|
||||
device.get_colors.return_value = {}
|
||||
|
||||
assert await setup_config_entry(
|
||||
hass, MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0], ENTITY_ID, device, fritz
|
||||
)
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes[ATTR_FRIENDLY_NAME] == "fake_name"
|
||||
assert state.attributes[ATTR_BRIGHTNESS] == 100
|
||||
assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == ["onoff"]
|
||||
|
||||
|
||||
async def test_setup_color(hass: HomeAssistant, fritz: Mock) -> None:
|
||||
|
@ -80,6 +121,7 @@ async def test_setup_color(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
assert state.attributes[ATTR_FRIENDLY_NAME] == "fake_name"
|
||||
assert state.attributes[ATTR_BRIGHTNESS] == 100
|
||||
assert state.attributes[ATTR_HS_COLOR] == (100, 70)
|
||||
assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == ["color_temp", "hs"]
|
||||
|
||||
|
||||
async def test_turn_on(hass: HomeAssistant, fritz: Mock) -> None:
|
||||
|
|
Loading…
Reference in New Issue