mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Support more dimmer devices in fibaro (#145864)
This commit is contained in:
parent
f44f2522ef
commit
7cb3c397b2
@ -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}
|
||||
|
@ -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."""
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user