Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions homeassistant/components/fritzbox/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ def __init__(
"""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:
Comment thread
parliament119 marked this conversation as resolved.
Outdated
# 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
Expand Down Expand Up @@ -125,7 +127,11 @@ def color_mode(self) -> ColorMode:
@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."""
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/fritzbox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/components/fritzbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions tests/components/fritzbox/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
ATTR_HS_COLOR,
ATTR_MAX_COLOR_TEMP_KELVIN,
ATTR_MIN_COLOR_TEMP_KELVIN,
ATTR_SUPPORTED_COLOR_MODES,
DOMAIN,
)
from homeassistant.const import (
Expand Down Expand Up @@ -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:
Comment thread
mib1185 marked this conversation as resolved.
Outdated
"""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:
Expand All @@ -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:
Expand Down