Skip to content

Commit 7cb3c39

Browse files
authored
Support more dimmer devices in fibaro (home-assistant#145864)
1 parent f44f252 commit 7cb3c39

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

homeassistant/components/fibaro/light.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def __init__(self, fibaro_device: DeviceModel) -> None:
8383
)
8484
supports_dimming = (
8585
fibaro_device.has_interface("levelChange")
86-
and "setValue" in fibaro_device.actions
87-
)
86+
or fibaro_device.type == "com.fibaro.multilevelSwitch"
87+
) and "setValue" in fibaro_device.actions
8888

8989
if supports_color and supports_white_v:
9090
self._attr_supported_color_modes = {ColorMode.RGBW}

tests/components/fibaro/conftest.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,39 @@ def mock_light() -> Mock:
172172
return light
173173

174174

175+
@pytest.fixture
176+
def mock_zigbee_light() -> Mock:
177+
"""Fixture for a dimmmable zigbee light."""
178+
light = Mock()
179+
light.fibaro_id = 12
180+
light.parent_fibaro_id = 0
181+
light.name = "Test light"
182+
light.room_id = 1
183+
light.dead = False
184+
light.visible = True
185+
light.enabled = True
186+
light.type = "com.fibaro.multilevelSwitch"
187+
light.base_type = "com.fibaro.binarySwitch"
188+
light.properties = {
189+
"manufacturer": "",
190+
"isLight": True,
191+
"interfaces": ["autoTurnOff", "favoritePosition", "light", "zigbee"],
192+
}
193+
light.actions = {"setValue": 1, "toggle": 0, "turnOn": 0, "turnOff": 0}
194+
light.supported_features = {}
195+
light.has_interface.return_value = False
196+
light.raw_data = {
197+
"fibaro_id": 12,
198+
"name": "Test light",
199+
"properties": {"value": 20},
200+
}
201+
value_mock = Mock()
202+
value_mock.has_value = True
203+
value_mock.int_value.return_value = 20
204+
light.value = value_mock
205+
return light
206+
207+
175208
@pytest.fixture
176209
def mock_thermostat() -> Mock:
177210
"""Fixture for a thermostat."""

tests/components/fibaro/test_light.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,28 @@ async def test_light_brightness(
5858
assert state.state == "on"
5959

6060

61+
async def test_zigbee_light_brightness(
62+
hass: HomeAssistant,
63+
mock_fibaro_client: Mock,
64+
mock_config_entry: MockConfigEntry,
65+
mock_zigbee_light: Mock,
66+
mock_room: Mock,
67+
) -> None:
68+
"""Test that the zigbee dimmable light is detected."""
69+
70+
# Arrange
71+
mock_fibaro_client.read_rooms.return_value = [mock_room]
72+
mock_fibaro_client.read_devices.return_value = [mock_zigbee_light]
73+
74+
with patch("homeassistant.components.fibaro.PLATFORMS", [Platform.LIGHT]):
75+
# Act
76+
await init_integration(hass, mock_config_entry)
77+
# Assert
78+
state = hass.states.get("light.room_1_test_light_12")
79+
assert state.attributes["brightness"] == 51
80+
assert state.state == "on"
81+
82+
6183
async def test_light_turn_off(
6284
hass: HomeAssistant,
6385
mock_fibaro_client: Mock,

0 commit comments

Comments
 (0)