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
4 changes: 2 additions & 2 deletions homeassistant/components/fibaro/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def __init__(self, fibaro_device: DeviceModel) -> None:
)
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}
Expand Down
33 changes: 33 additions & 0 deletions tests/components/fibaro/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,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."""
Expand Down
22 changes: 22 additions & 0 deletions tests/components/fibaro/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down