diff --git a/homeassistant/components/fibaro/light.py b/homeassistant/components/fibaro/light.py index 446b9b9f7ff..a82769bf9ee 100644 --- a/homeassistant/components/fibaro/light.py +++ b/homeassistant/components/fibaro/light.py @@ -83,8 +83,8 @@ class FibaroLight(FibaroEntity, LightEntity): ) supports_dimming = ( fibaro_device.has_interface("levelChange") - and "setValue" in fibaro_device.actions - ) + or fibaro_device.type == "com.fibaro.multilevelSwitch" + ) and "setValue" in fibaro_device.actions if supports_color and supports_white_v: self._attr_supported_color_modes = {ColorMode.RGBW} diff --git a/tests/components/fibaro/conftest.py b/tests/components/fibaro/conftest.py index bf1fb53621a..952efbbb8ec 100644 --- a/tests/components/fibaro/conftest.py +++ b/tests/components/fibaro/conftest.py @@ -172,6 +172,39 @@ def mock_light() -> Mock: return light +@pytest.fixture +def mock_zigbee_light() -> Mock: + """Fixture for a dimmmable zigbee light.""" + light = Mock() + light.fibaro_id = 12 + light.parent_fibaro_id = 0 + light.name = "Test light" + light.room_id = 1 + light.dead = False + light.visible = True + light.enabled = True + light.type = "com.fibaro.multilevelSwitch" + light.base_type = "com.fibaro.binarySwitch" + light.properties = { + "manufacturer": "", + "isLight": True, + "interfaces": ["autoTurnOff", "favoritePosition", "light", "zigbee"], + } + light.actions = {"setValue": 1, "toggle": 0, "turnOn": 0, "turnOff": 0} + light.supported_features = {} + light.has_interface.return_value = False + light.raw_data = { + "fibaro_id": 12, + "name": "Test light", + "properties": {"value": 20}, + } + value_mock = Mock() + value_mock.has_value = True + value_mock.int_value.return_value = 20 + light.value = value_mock + return light + + @pytest.fixture def mock_thermostat() -> Mock: """Fixture for a thermostat.""" diff --git a/tests/components/fibaro/test_light.py b/tests/components/fibaro/test_light.py index 88576e86dc6..e44036e3f08 100644 --- a/tests/components/fibaro/test_light.py +++ b/tests/components/fibaro/test_light.py @@ -58,6 +58,28 @@ async def test_light_brightness( assert state.state == "on" +async def test_zigbee_light_brightness( + hass: HomeAssistant, + mock_fibaro_client: Mock, + mock_config_entry: MockConfigEntry, + mock_zigbee_light: Mock, + mock_room: Mock, +) -> None: + """Test that the zigbee dimmable light is detected.""" + + # Arrange + mock_fibaro_client.read_rooms.return_value = [mock_room] + mock_fibaro_client.read_devices.return_value = [mock_zigbee_light] + + with patch("homeassistant.components.fibaro.PLATFORMS", [Platform.LIGHT]): + # Act + await init_integration(hass, mock_config_entry) + # Assert + state = hass.states.get("light.room_1_test_light_12") + assert state.attributes["brightness"] == 51 + assert state.state == "on" + + async def test_light_turn_off( hass: HomeAssistant, mock_fibaro_client: Mock,