diff --git a/homeassistant/components/wiz/light.py b/homeassistant/components/wiz/light.py index 509d40d654d..8a6de65cf73 100644 --- a/homeassistant/components/wiz/light.py +++ b/homeassistant/components/wiz/light.py @@ -80,6 +80,9 @@ class WizBulbEntity(WizToggleEntity, LightEntity): color_modes.add(RGB_WHITE_CHANNELS_COLOR_MODE[bulb_type.white_channels]) if features.color_tmp: color_modes.add(ColorMode.COLOR_TEMP) + kelvin = bulb_type.kelvin_range + self._attr_max_color_temp_kelvin = kelvin.max + self._attr_min_color_temp_kelvin = kelvin.min if features.brightness: color_modes.add(ColorMode.BRIGHTNESS) self._attr_supported_color_modes = filter_supported_color_modes(color_modes) @@ -87,10 +90,6 @@ class WizBulbEntity(WizToggleEntity, LightEntity): # If the light supports only a single color mode, set it now self._attr_color_mode = next(iter(self._attr_supported_color_modes)) self._attr_effect_list = wiz_data.scenes - if bulb_type.bulb_type != BulbClass.DW: - kelvin = bulb_type.kelvin_range - self._attr_max_color_temp_kelvin = kelvin.max - self._attr_min_color_temp_kelvin = kelvin.min if bulb_type.features.effect: self._attr_supported_features = LightEntityFeature.EFFECT self._async_update_attrs() diff --git a/tests/components/wiz/__init__.py b/tests/components/wiz/__init__.py index 037b6a1dfbd..a11a7251998 100644 --- a/tests/components/wiz/__init__.py +++ b/tests/components/wiz/__init__.py @@ -183,7 +183,7 @@ FAKE_DIMMABLE_FAN = BulbType( features=Features( color=False, color_tmp=False, - effect=True, + effect=False, brightness=True, dual_head=False, fan=True, @@ -191,11 +191,30 @@ FAKE_DIMMABLE_FAN = BulbType( fan_reverse=True, ), kelvin_range=KelvinRange(max=2700, min=2700), - fw_version="1.31.32", + fw_version="1.34.1", white_channels=1, white_to_color_ratio=20, fan_speed_range=6, ) +FAKE_DIMMABLE_FAN_2 = BulbType( + bulb_type=BulbClass.FANDIM, + name="ESP20_FANDIMS_31", + features=Features( + color=False, + color_tmp=False, + effect=False, + brightness=True, + dual_head=False, + fan=True, + fan_breeze_mode=True, + fan_reverse=True, + ), + kelvin_range=None, + fw_version="1.34.0", + white_channels=None, + white_to_color_ratio=None, + fan_speed_range=6, +) async def setup_integration(hass: HomeAssistant) -> MockConfigEntry: diff --git a/tests/components/wiz/snapshots/test_fan.ambr b/tests/components/wiz/snapshots/test_fan.ambr index 8bea65091d8..1ab3b78513f 100644 --- a/tests/components/wiz/snapshots/test_fan.ambr +++ b/tests/components/wiz/snapshots/test_fan.ambr @@ -1,5 +1,5 @@ # serializer version: 1 -# name: test_entity[fan.mock_title-entry] +# name: test_entity[bulb_type0][fan.mock_title-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -39,7 +39,68 @@ 'unit_of_measurement': None, }) # --- -# name: test_entity[fan.mock_title-state] +# name: test_entity[bulb_type0][fan.mock_title-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'direction': 'forward', + 'friendly_name': 'Mock Title', + 'percentage': 16, + 'percentage_step': 16.666666666666668, + 'preset_mode': None, + 'preset_modes': list([ + 'breeze', + ]), + 'supported_features': , + }), + 'context': , + 'entity_id': 'fan.mock_title', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_entity[bulb_type1][fan.mock_title-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'preset_modes': list([ + 'breeze', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'fan', + 'entity_category': None, + 'entity_id': 'fan.mock_title', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': None, + 'platform': 'wiz', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': None, + 'unique_id': 'abcabcabcabc', + 'unit_of_measurement': None, + }) +# --- +# name: test_entity[bulb_type1][fan.mock_title-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'direction': 'forward', diff --git a/tests/components/wiz/test_fan.py b/tests/components/wiz/test_fan.py index d15f083d431..42c022f2c45 100644 --- a/tests/components/wiz/test_fan.py +++ b/tests/components/wiz/test_fan.py @@ -3,6 +3,8 @@ from typing import Any from unittest.mock import patch +import pytest +from pywizlight import BulbType from syrupy.assertion import SnapshotAssertion from homeassistant.components.fan import ( @@ -28,7 +30,13 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er -from . import FAKE_DIMMABLE_FAN, FAKE_MAC, async_push_update, async_setup_integration +from . import ( + FAKE_DIMMABLE_FAN, + FAKE_DIMMABLE_FAN_2, + FAKE_MAC, + async_push_update, + async_setup_integration, +) from tests.common import snapshot_platform @@ -43,12 +51,16 @@ INITIAL_PARAMS = { } +@pytest.mark.parametrize("bulb_type", [FAKE_DIMMABLE_FAN, FAKE_DIMMABLE_FAN_2]) @patch("homeassistant.components.wiz.PLATFORMS", [Platform.FAN]) async def test_entity( - hass: HomeAssistant, snapshot: SnapshotAssertion, entity_registry: er.EntityRegistry + hass: HomeAssistant, + snapshot: SnapshotAssertion, + entity_registry: er.EntityRegistry, + bulb_type: BulbType, ) -> None: """Test the fan entity.""" - entry = (await async_setup_integration(hass, bulb_type=FAKE_DIMMABLE_FAN))[1] + entry = (await async_setup_integration(hass, bulb_type=bulb_type))[1] await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id)