Ensure WiZ can still setup with old firmwares (#66968)
parent
5af4068583
commit
4811b510eb
|
@ -71,6 +71,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
try:
|
||||
bulbtype = await bulb.get_bulbtype()
|
||||
except WIZ_CONNECT_EXCEPTIONS as ex:
|
||||
_LOGGER.debug(
|
||||
"Failed to connect to %s during discovery: %s",
|
||||
device.ip_address,
|
||||
ex,
|
||||
exc_info=True,
|
||||
)
|
||||
raise AbortFlow("cannot_connect") from ex
|
||||
self._name = name_from_bulb_type_and_mac(bulbtype, device.mac_address)
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ from typing import Any
|
|||
|
||||
from pywizlight.bulblibrary import BulbType
|
||||
|
||||
from homeassistant.const import ATTR_HW_VERSION, ATTR_MODEL
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity, ToggleEntity
|
||||
|
@ -24,17 +25,20 @@ class WizEntity(CoordinatorEntity, Entity):
|
|||
bulb_type: BulbType = self._device.bulbtype
|
||||
self._attr_unique_id = self._device.mac
|
||||
self._attr_name = name
|
||||
hw_data = bulb_type.name.split("_")
|
||||
board = hw_data.pop(0)
|
||||
model = hw_data.pop(0)
|
||||
self._attr_device_info = DeviceInfo(
|
||||
connections={(CONNECTION_NETWORK_MAC, self._device.mac)},
|
||||
name=name,
|
||||
manufacturer="WiZ",
|
||||
model=model,
|
||||
hw_version=f"{board} {hw_data[0]}" if hw_data else board,
|
||||
sw_version=bulb_type.fw_version,
|
||||
)
|
||||
if bulb_type.name is None:
|
||||
return
|
||||
hw_data = bulb_type.name.split("_")
|
||||
board = hw_data.pop(0)
|
||||
model = hw_data.pop(0)
|
||||
hw_version = f"{board} {hw_data[0]}" if hw_data else board
|
||||
self._attr_device_info[ATTR_HW_VERSION] = hw_version
|
||||
self._attr_device_info[ATTR_MODEL] = model
|
||||
|
||||
@callback
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"dependencies": ["network"],
|
||||
"quality_scale": "platinum",
|
||||
"documentation": "https://www.home-assistant.io/integrations/wiz",
|
||||
"requirements": ["pywizlight==0.5.11"],
|
||||
"requirements": ["pywizlight==0.5.12"],
|
||||
"iot_class": "local_push",
|
||||
"codeowners": ["@sbidy"]
|
||||
}
|
||||
|
|
|
@ -2057,7 +2057,7 @@ pywemo==0.7.0
|
|||
pywilight==0.0.70
|
||||
|
||||
# homeassistant.components.wiz
|
||||
pywizlight==0.5.11
|
||||
pywizlight==0.5.12
|
||||
|
||||
# homeassistant.components.xeoma
|
||||
pyxeoma==1.4.1
|
||||
|
|
|
@ -1288,7 +1288,7 @@ pywemo==0.7.0
|
|||
pywilight==0.0.70
|
||||
|
||||
# homeassistant.components.wiz
|
||||
pywizlight==0.5.11
|
||||
pywizlight==0.5.12
|
||||
|
||||
# homeassistant.components.zerproc
|
||||
pyzerproc==0.4.8
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in New Issue