Use a human readable model name in flux_led (#57519)
parent
f41aedc0f9
commit
abcacd2a00
|
@ -41,7 +41,7 @@ class FluxEntity(CoordinatorEntity):
|
|||
if self.unique_id:
|
||||
self._attr_device_info = {
|
||||
"connections": {(dr.CONNECTION_NETWORK_MAC, self.unique_id)},
|
||||
ATTR_MODEL: f"0x{self._device.model_num:02X}",
|
||||
ATTR_MODEL: self._device.model,
|
||||
ATTR_NAME: self.name,
|
||||
ATTR_SW_VERSION: str(self._device.version_num),
|
||||
ATTR_MANUFACTURER: "FluxLED/Magic Home",
|
||||
|
|
|
@ -68,6 +68,7 @@ def _mocked_bulb() -> AIOWifiLedBulb:
|
|||
bulb.getWhiteTemperature = MagicMock(return_value=(2700, 128))
|
||||
bulb.brightness = 128
|
||||
bulb.model_num = 0x35
|
||||
bulb.model = "Smart Bulb (0x35)"
|
||||
bulb.version_num = 8
|
||||
bulb.rgbwcapable = True
|
||||
bulb.color_modes = {FLUX_COLOR_MODE_RGB, FLUX_COLOR_MODE_CCT}
|
||||
|
@ -91,6 +92,7 @@ def _mocked_switch() -> AIOWifiLedBulb:
|
|||
switch.async_turn_off = AsyncMock()
|
||||
switch.async_turn_on = AsyncMock()
|
||||
switch.model_num = 0x97
|
||||
switch.model = "Smart Switch (0x97)"
|
||||
switch.version_num = 0x97
|
||||
switch.raw_state = LEDENETRawState(
|
||||
0, 0x97, 0, 0x61, 0x97, 50, 255, 0, 0, 50, 8, 0, 0, 0
|
||||
|
|
|
@ -143,10 +143,14 @@ async def test_light_no_unique_id(hass: HomeAssistant) -> None:
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"protocol,sw_version,model", [("LEDENET_ORIGINAL", 1, 0x35), ("LEDENET", 8, 0x33)]
|
||||
"protocol,sw_version,model_num,model",
|
||||
[
|
||||
("LEDENET_ORIGINAL", 1, 0x01, "Original LEDEDNET (0x35)"),
|
||||
("LEDENET", 8, 0x33, "Magic Home Branded RGB Controller (0x33)"),
|
||||
],
|
||||
)
|
||||
async def test_light_device_registry(
|
||||
hass: HomeAssistant, protocol: str, sw_version: int, model: int
|
||||
hass: HomeAssistant, protocol: str, sw_version: int, model_num: int, model: str
|
||||
) -> None:
|
||||
"""Test a light device registry entry."""
|
||||
config_entry = MockConfigEntry(
|
||||
|
@ -158,8 +162,8 @@ async def test_light_device_registry(
|
|||
bulb = _mocked_bulb()
|
||||
bulb.version_num = sw_version
|
||||
bulb.protocol = protocol
|
||||
bulb.raw_state = bulb.raw_state._replace(model_num=model, version_number=sw_version)
|
||||
bulb.model_num = model
|
||||
bulb.model_num = model_num
|
||||
bulb.model = model
|
||||
|
||||
with _patch_discovery(no_device=True), _patch_wifibulb(device=bulb):
|
||||
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
|
||||
|
@ -170,7 +174,7 @@ async def test_light_device_registry(
|
|||
identifiers={}, connections={(dr.CONNECTION_NETWORK_MAC, MAC_ADDRESS)}
|
||||
)
|
||||
assert device.sw_version == str(sw_version)
|
||||
assert device.model == f"0x{model:02X}"
|
||||
assert device.model == model
|
||||
|
||||
|
||||
async def test_rgb_light(hass: HomeAssistant) -> None:
|
||||
|
|
Loading…
Reference in New Issue