Ensure WiZ can still setup with old firmwares (#66968)

This commit is contained in:
J. Nick Koston 2022-02-21 08:42:54 -10:00 committed by GitHub
parent 5af4068583
commit 4811b510eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 61 additions and 8 deletions

View file

@ -150,6 +150,17 @@ FAKE_SOCKET = BulbType(
white_channels=2,
white_to_color_ratio=80,
)
FAKE_OLD_FIRMWARE_DIMMABLE_BULB = BulbType(
bulb_type=BulbClass.DW,
name=None,
features=Features(
color=False, color_tmp=False, effect=True, brightness=True, dual_head=False
),
kelvin_range=None,
fw_version="1.8.0",
white_channels=1,
white_to_color_ratio=80,
)
async def setup_integration(

View file

@ -22,6 +22,7 @@ from homeassistant.helpers import entity_registry as er
from . import (
FAKE_MAC,
FAKE_OLD_FIRMWARE_DIMMABLE_BULB,
FAKE_RGBW_BULB,
FAKE_RGBWW_BULB,
FAKE_TURNABLE_BULB,
@ -169,3 +170,34 @@ async def test_turnable_light(hass: HomeAssistant) -> None:
state = hass.states.get(entity_id)
assert state.state == STATE_ON
assert state.attributes[ATTR_COLOR_TEMP] == 153
async def test_old_firmware_dimmable_light(hass: HomeAssistant) -> None:
"""Test a light operation with a dimmable light with old firmware."""
bulb, _ = await async_setup_integration(
hass, bulb_type=FAKE_OLD_FIRMWARE_DIMMABLE_BULB
)
entity_id = "light.mock_title"
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: entity_id, ATTR_BRIGHTNESS: 128},
blocking=True,
)
pilot: PilotBuilder = bulb.turn_on.mock_calls[0][1][0]
assert pilot.pilot_params == {"dimming": 50, "state": True}
await async_push_update(hass, bulb, {"mac": FAKE_MAC, **pilot.pilot_params})
state = hass.states.get(entity_id)
assert state.state == STATE_ON
assert state.attributes[ATTR_BRIGHTNESS] == 128
bulb.turn_on.reset_mock()
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: entity_id, ATTR_BRIGHTNESS: 255},
blocking=True,
)
pilot: PilotBuilder = bulb.turn_on.mock_calls[0][1][0]
assert pilot.pilot_params == {"dimming": 100, "state": True}