Bläddra i källkod

Remove obsolete device specific switch implementations.

Jason Rumney 4 år sedan
förälder
incheckning
1c5ffc2544

+ 0 - 0
custom_components/tuya_local/kogan_socket/__init__.py


+ 0 - 22
custom_components/tuya_local/kogan_socket/const.py

@@ -1,22 +0,0 @@
-from homeassistant.components.switch import ATTR_CURRENT_POWER_W
-
-ATTR_SWITCH = "switch"
-ATTR_TIMER = "timer"
-ATTR_CURRENT_A = "current_a"
-ATTR_VOLTAGE_V = "voltage_v"
-ATTR_ALT_TIMER = "alt_timer"
-ATTR_ALT_CURRENT_A = "alt_currrent_a"
-ATTR_ALT_CURRENT_POWER_W = "alt_power_w"
-ATTR_ALT_VOLTAGE_V = "alt_voltage_v"
-
-PROPERTY_TO_DPS_ID = {
-    ATTR_SWITCH: "1",
-    ATTR_TIMER: "2",
-    ATTR_CURRENT_A: "4",
-    ATTR_CURRENT_POWER_W: "5",
-    ATTR_VOLTAGE_V: "6",
-    ATTR_ALT_TIMER: "9",
-    ATTR_ALT_CURRENT_A: "18",
-    ATTR_ALT_CURRENT_POWER_W: "19",
-    ATTR_ALT_VOLTAGE_V: "20",
-}

+ 0 - 115
custom_components/tuya_local/kogan_socket/switch.py

@@ -1,115 +0,0 @@
-"""
-Platform to control the switch on Kogan WiFi-connected energy monitoring sockets.
-"""
-from homeassistant.components.switch import SwitchEntity
-from homeassistant.components.switch import (
-    ATTR_CURRENT_POWER_W,
-    DEVICE_CLASS_OUTLET,
-)
-
-from homeassistant.const import STATE_UNAVAILABLE
-
-from .const import (
-    ATTR_CURRENT_A,
-    ATTR_SWITCH,
-    ATTR_TIMER,
-    ATTR_VOLTAGE_V,
-    ATTR_ALT_TIMER,
-    ATTR_ALT_CURRENT_A,
-    ATTR_ALT_CURRENT_POWER_W,
-    ATTR_ALT_VOLTAGE_V,
-    PROPERTY_TO_DPS_ID,
-)
-
-
-class KoganSocketSwitch(SwitchEntity):
-    """Representation of a Kogan WiFi-connected energy monitoring socket"""
-
-    def __init__(self, device):
-        """Initialize the switch.
-        Args:
-            device (TuyaLocalDevice): The device API instance."""
-        self._device = device
-
-    @property
-    def should_poll(self):
-        """Return the polling state."""
-        return True
-
-    @property
-    def name(self):
-        """Return the name of the switch."""
-        return self._device.name
-
-    @property
-    def unique_id(self):
-        """Return the unique id for this switch."""
-        return self._device.unique_id
-
-    @property
-    def device_info(self):
-        """Return device information about this switch."""
-        return self._device.device_info
-
-    @property
-    def device_class(self):
-        """Return the class of this device"""
-        return DEVICE_CLASS_OUTLET
-
-    @property
-    def is_on(self):
-        """Return the whether the switch is on."""
-        is_switched_on = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_SWITCH])
-        if is_switched_on is None:
-            return STATE_UNAVAILABLE
-        else:
-            return is_switched_on
-
-    @property
-    def current_power_w(self):
-        """Return the current power consumption in Watts"""
-        pwr = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_CURRENT_POWER_W])
-        if pwr is None:
-            # Some newer plugs have the measurements on different DPS ids
-            pwr = self._device.get_property(
-                PROPERTY_TO_DPS_ID[ATTR_ALT_CURRENT_POWER_W]
-            )
-            if pwr is None:
-                return STATE_UNAVAILABLE
-
-        return pwr / 10.0
-
-    @property
-    def device_state_attributes(self):
-        """Get additional attributes that HA doesn't naturally support."""
-        timer = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_TIMER])
-        voltage = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_VOLTAGE_V])
-        current = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_CURRENT_A])
-
-        # Some newer plugs have the measurements on different DPS ids
-        if timer is None:
-            timer = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_ALT_TIMER])
-
-        if voltage is None:
-            voltage = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_ALT_VOLTAGE_V])
-
-        if current is None:
-            current = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_ALT_CURRENT_A])
-
-        return {
-            ATTR_CURRENT_POWER_W: self.current_power_w,
-            ATTR_CURRENT_A: None if current is None else current / 1000.0,
-            ATTR_VOLTAGE_V: None if voltage is None else voltage / 10.0,
-            ATTR_TIMER: timer,
-        }
-
-    async def async_turn_on(self, **kwargs):
-        """Turn the switch on"""
-        await self._device.async_set_property(PROPERTY_TO_DPS_ID[ATTR_SWITCH], True)
-
-    async def async_turn_off(self, **kwargs):
-        """Turn the switch off"""
-        await self._device.async_set_property(PROPERTY_TO_DPS_ID[ATTR_SWITCH], False)
-
-    async def async_update(self):
-        await self._device.async_refresh()

+ 0 - 73
custom_components/tuya_local/purline_m100_heater/switch.py

@@ -1,73 +0,0 @@
-"""
-Platform to control the Open Window Detector on Purline M100 heaters.
-"""
-from homeassistant.components.switch import SwitchEntity
-from homeassistant.components.switch import DEVICE_CLASS_SWITCH
-
-from homeassistant.const import STATE_UNAVAILABLE
-
-from .const import (
-    ATTR_OPEN_WINDOW_DETECT,
-    PROPERTY_TO_DPS_ID,
-)
-
-
-class PurlineM100OpenWindowDetector(SwitchEntity):
-    """Representation of the Open Window Detection of a Purline M100 heater"""
-
-    def __init__(self, device):
-        """Initialize the switch.
-        Args:
-            device (TuyaLocalDevice): The device API instance."""
-        self._device = device
-
-    @property
-    def should_poll(self):
-        """Return the polling state."""
-        return True
-
-    @property
-    def name(self):
-        """Return the name of the switch."""
-        return self._device.name
-
-    @property
-    def unique_id(self):
-        """Return the unique id for this switch."""
-        return self._device.unique_id
-
-    @property
-    def device_info(self):
-        """Return device information about this switch."""
-        return self._device.device_info
-
-    @property
-    def device_class(self):
-        """Return the class of this device"""
-        return DEVICE_CLASS_SWITCH
-
-    @property
-    def is_on(self):
-        """Return the whether the switch is on."""
-        is_switched_on = self._device.get_property(
-            PROPERTY_TO_DPS_ID[ATTR_OPEN_WINDOW_DETECT]
-        )
-        if is_switched_on is None:
-            return STATE_UNAVAILABLE
-        else:
-            return is_switched_on
-
-    async def async_turn_on(self, **kwargs):
-        """Turn the switch on"""
-        await self._device.async_set_property(
-            PROPERTY_TO_DPS_ID[ATTR_OPEN_WINDOW_DETECT], True
-        )
-
-    async def async_turn_off(self, **kwargs):
-        """Turn the switch off"""
-        await self._device.async_set_property(
-            PROPERTY_TO_DPS_ID[ATTR_OPEN_WINDOW_DETECT], False
-        )
-
-    async def async_update(self):
-        await self._device.async_refresh()

+ 0 - 0
tests/kogan_socket/__init__.py


+ 0 - 134
tests/kogan_socket/test_alt_switch.py

@@ -1,134 +0,0 @@
-from unittest import IsolatedAsyncioTestCase
-from unittest.mock import AsyncMock, patch
-
-from homeassistant.components.switch import ATTR_CURRENT_POWER_W, DEVICE_CLASS_OUTLET
-from homeassistant.const import STATE_UNAVAILABLE
-
-from custom_components.tuya_local.kogan_socket.const import (
-    ATTR_SWITCH,
-    ATTR_TIMER,
-    ATTR_ALT_TIMER,
-    ATTR_ALT_CURRENT_A,
-    ATTR_ALT_CURRENT_POWER_W,
-    ATTR_ALT_VOLTAGE_V,
-    ATTR_CURRENT_A,
-    ATTR_VOLTAGE_V,
-    PROPERTY_TO_DPS_ID,
-)
-from custom_components.tuya_local.kogan_socket.switch import KoganSocketSwitch
-
-from ..const import KOGAN_SOCKET_PAYLOAD2, KOGAN_SOCKET_CLEAR_PAYLOAD
-from ..helpers import assert_device_properties_set
-
-
-class TestKoganSocket(IsolatedAsyncioTestCase):
-    def setUp(self):
-        device_patcher = patch("custom_components.tuya_local.device.TuyaLocalDevice")
-        self.addCleanup(device_patcher.stop)
-        self.mock_device = device_patcher.start()
-
-        self.subject = KoganSocketSwitch(self.mock_device())
-
-        # since the socket needs to handle both types, give the mock some
-        # dummy fields to prevent breakage.
-        self.dps = KOGAN_SOCKET_CLEAR_PAYLOAD.copy()
-        self.dps.update(KOGAN_SOCKET_PAYLOAD2)
-        self.subject._device.get_property.side_effect = lambda id: self.dps[id]
-
-    def test_should_poll(self):
-        self.assertTrue(self.subject.should_poll)
-
-    def test_name_returns_device_name(self):
-        self.assertEqual(self.subject.name, self.subject._device.name)
-
-    def test_unique_id_returns_device_unique_id(self):
-        self.assertEqual(self.subject.unique_id, self.subject._device.unique_id)
-
-    def test_device_info_returns_device_info_from_device(self):
-        self.assertEqual(self.subject.device_info, self.subject._device.device_info)
-
-    def test_device_class_is_outlet(self):
-        self.assertEqual(self.subject.device_class, DEVICE_CLASS_OUTLET)
-
-    def test_is_on(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_SWITCH]] = True
-        self.assertEqual(self.subject.is_on, True)
-
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_SWITCH]] = False
-        self.assertEqual(self.subject.is_on, False)
-
-    def test_is_on_when_unavailable(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_SWITCH]] = None
-        self.assertEqual(self.subject.is_on, STATE_UNAVAILABLE)
-
-    async def test_turn_on(self):
-        async with assert_device_properties_set(
-            self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_SWITCH]: True}
-        ):
-            await self.subject.async_turn_on()
-
-    async def test_turn_off(self):
-        async with assert_device_properties_set(
-            self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_SWITCH]: False}
-        ):
-            await self.subject.async_turn_off()
-
-    async def test_toggle_turns_the_switch_on_when_it_was_off(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_SWITCH]] = False
-
-        async with assert_device_properties_set(
-            self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_SWITCH]: True}
-        ):
-            await self.subject.async_toggle()
-
-    async def test_toggle_turns_the_switch_off_when_it_was_on(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_SWITCH]] = True
-        async with assert_device_properties_set(
-            self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_SWITCH]: False}
-        ):
-            await self.subject.async_toggle()
-
-    def test_current_power_w(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_ALT_CURRENT_POWER_W]] = 1234
-        self.assertEqual(self.subject.current_power_w, 123.4)
-
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_ALT_CURRENT_POWER_W]] = None
-        self.assertEqual(self.subject.current_power_w, STATE_UNAVAILABLE)
-
-    def test_device_state_attributes_set(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_ALT_TIMER]] = 1
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_ALT_VOLTAGE_V]] = 2350
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_ALT_CURRENT_A]] = 1234
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_ALT_CURRENT_POWER_W]] = 5678
-        self.assertEqual(
-            self.subject.device_state_attributes,
-            {
-                ATTR_TIMER: 1,
-                ATTR_CURRENT_A: 1.234,
-                ATTR_VOLTAGE_V: 235.0,
-                ATTR_CURRENT_POWER_W: 567.8,
-            },
-        )
-
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_ALT_TIMER]] = 0
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_ALT_VOLTAGE_V]] = None
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_ALT_CURRENT_A]] = None
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_ALT_CURRENT_POWER_W]] = None
-        self.assertEqual(
-            self.subject.device_state_attributes,
-            {
-                ATTR_TIMER: 0,
-                ATTR_CURRENT_A: None,
-                ATTR_VOLTAGE_V: None,
-                ATTR_CURRENT_POWER_W: STATE_UNAVAILABLE,
-            },
-        )
-
-    async def test_update(self):
-        result = AsyncMock()
-        self.subject._device.async_refresh.return_value = result()
-
-        await self.subject.async_update()
-
-        self.subject._device.async_refresh.assert_called_once()
-        result.assert_awaited()

+ 0 - 131
tests/kogan_socket/test_switch.py

@@ -1,131 +0,0 @@
-from unittest import IsolatedAsyncioTestCase
-from unittest.mock import AsyncMock, patch
-
-from homeassistant.components.switch import ATTR_CURRENT_POWER_W, DEVICE_CLASS_OUTLET
-from homeassistant.const import STATE_UNAVAILABLE
-
-from custom_components.tuya_local.kogan_socket.const import (
-    ATTR_SWITCH,
-    ATTR_TIMER,
-    ATTR_CURRENT_A,
-    ATTR_VOLTAGE_V,
-    PROPERTY_TO_DPS_ID,
-)
-from custom_components.tuya_local.kogan_socket.switch import KoganSocketSwitch
-
-from ..const import KOGAN_SOCKET_PAYLOAD, KOGAN_SOCKET_CLEAR_PAYLOAD
-from ..helpers import assert_device_properties_set
-
-
-class TestKoganSocket(IsolatedAsyncioTestCase):
-    def setUp(self):
-        device_patcher = patch("custom_components.tuya_local.device.TuyaLocalDevice")
-        self.addCleanup(device_patcher.stop)
-        self.mock_device = device_patcher.start()
-
-        self.subject = KoganSocketSwitch(self.mock_device())
-
-        # since the socket needs to handle both types, give the mock some
-        # dummy fields to prevent breakage.
-        self.dps = KOGAN_SOCKET_CLEAR_PAYLOAD.copy()
-        self.dps.update(KOGAN_SOCKET_PAYLOAD)
-
-        self.subject._device.get_property.side_effect = lambda id: self.dps[id]
-
-    def test_should_poll(self):
-        self.assertTrue(self.subject.should_poll)
-
-    def test_name_returns_device_name(self):
-        self.assertEqual(self.subject.name, self.subject._device.name)
-
-    def test_unique_id_returns_device_unique_id(self):
-        self.assertEqual(self.subject.unique_id, self.subject._device.unique_id)
-
-    def test_device_info_returns_device_info_from_device(self):
-        self.assertEqual(self.subject.device_info, self.subject._device.device_info)
-
-    def test_device_class_is_outlet(self):
-        self.assertEqual(self.subject.device_class, DEVICE_CLASS_OUTLET)
-
-    def test_is_on(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_SWITCH]] = True
-        self.assertEqual(self.subject.is_on, True)
-
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_SWITCH]] = False
-        self.assertEqual(self.subject.is_on, False)
-
-    def test_is_on_when_unavailable(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_SWITCH]] = None
-        self.assertEqual(self.subject.is_on, STATE_UNAVAILABLE)
-
-    async def test_turn_on(self):
-        async with assert_device_properties_set(
-            self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_SWITCH]: True}
-        ):
-            await self.subject.async_turn_on()
-
-    async def test_turn_off(self):
-        async with assert_device_properties_set(
-            self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_SWITCH]: False}
-        ):
-            await self.subject.async_turn_off()
-
-    async def test_toggle_turns_the_switch_on_when_it_was_off(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_SWITCH]] = False
-
-        async with assert_device_properties_set(
-            self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_SWITCH]: True}
-        ):
-            await self.subject.async_toggle()
-
-    async def test_toggle_turns_the_switch_off_when_it_was_on(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_SWITCH]] = True
-        async with assert_device_properties_set(
-            self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_SWITCH]: False}
-        ):
-            await self.subject.async_toggle()
-
-    def test_current_power_w(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_CURRENT_POWER_W]] = 1234
-        self.assertEqual(self.subject.current_power_w, 123.4)
-
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_CURRENT_POWER_W]] = None
-        self.assertEqual(self.subject.current_power_w, STATE_UNAVAILABLE)
-
-    def test_device_state_attributes_set(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_TIMER]] = 1
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_VOLTAGE_V]] = 2350
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_CURRENT_A]] = 1234
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_CURRENT_POWER_W]] = 5678
-        self.assertEqual(
-            self.subject.device_state_attributes,
-            {
-                ATTR_TIMER: 1,
-                ATTR_CURRENT_A: 1.234,
-                ATTR_VOLTAGE_V: 235.0,
-                ATTR_CURRENT_POWER_W: 567.8,
-            },
-        )
-
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_TIMER]] = 0
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_VOLTAGE_V]] = None
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_CURRENT_A]] = None
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_CURRENT_POWER_W]] = None
-        self.assertEqual(
-            self.subject.device_state_attributes,
-            {
-                ATTR_TIMER: 0,
-                ATTR_CURRENT_A: None,
-                ATTR_VOLTAGE_V: None,
-                ATTR_CURRENT_POWER_W: STATE_UNAVAILABLE,
-            },
-        )
-
-    async def test_update(self):
-        result = AsyncMock()
-        self.subject._device.async_refresh.return_value = result()
-
-        await self.subject.async_update()
-
-        self.subject._device.async_refresh.assert_called_once()
-        result.assert_awaited()

+ 0 - 90
tests/purline_m100_heater/test_switch.py

@@ -1,90 +0,0 @@
-from unittest import IsolatedAsyncioTestCase
-from unittest.mock import AsyncMock, patch
-
-from homeassistant.components.switch import DEVICE_CLASS_SWITCH
-from homeassistant.const import STATE_UNAVAILABLE
-
-from custom_components.tuya_local.purline_m100_heater.const import (
-    ATTR_OPEN_WINDOW_DETECT,
-    PROPERTY_TO_DPS_ID,
-)
-from custom_components.tuya_local.purline_m100_heater.switch import (
-    PurlineM100OpenWindowDetector,
-)
-
-from ..const import PURLINE_M100_HEATER_PAYLOAD
-from ..helpers import assert_device_properties_set
-
-
-class TestPulineOpenWindowDetector(IsolatedAsyncioTestCase):
-    def setUp(self):
-        device_patcher = patch("custom_components.tuya_local.device.TuyaLocalDevice")
-        self.addCleanup(device_patcher.stop)
-        self.mock_device = device_patcher.start()
-
-        self.subject = PurlineM100OpenWindowDetector(self.mock_device())
-
-        self.dps = PURLINE_M100_HEATER_PAYLOAD.copy()
-        self.subject._device.get_property.side_effect = lambda id: self.dps[id]
-
-    def test_should_poll(self):
-        self.assertTrue(self.subject.should_poll)
-
-    def test_name_returns_device_name(self):
-        self.assertEqual(self.subject.name, self.subject._device.name)
-
-    def test_unique_id_returns_device_unique_id(self):
-        self.assertEqual(self.subject.unique_id, self.subject._device.unique_id)
-
-    def test_device_info_returns_device_info_from_device(self):
-        self.assertEqual(self.subject.device_info, self.subject._device.device_info)
-
-    def test_device_class_is_outlet(self):
-        self.assertEqual(self.subject.device_class, DEVICE_CLASS_SWITCH)
-
-    def test_is_on(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_OPEN_WINDOW_DETECT]] = True
-        self.assertEqual(self.subject.is_on, True)
-
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_OPEN_WINDOW_DETECT]] = False
-        self.assertEqual(self.subject.is_on, False)
-
-    def test_is_on_when_unavailable(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_OPEN_WINDOW_DETECT]] = None
-        self.assertEqual(self.subject.is_on, STATE_UNAVAILABLE)
-
-    async def test_turn_on(self):
-        async with assert_device_properties_set(
-            self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_OPEN_WINDOW_DETECT]: True}
-        ):
-            await self.subject.async_turn_on()
-
-    async def test_turn_off(self):
-        async with assert_device_properties_set(
-            self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_OPEN_WINDOW_DETECT]: False}
-        ):
-            await self.subject.async_turn_off()
-
-    async def test_toggle_turns_the_switch_on_when_it_was_off(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_OPEN_WINDOW_DETECT]] = False
-
-        async with assert_device_properties_set(
-            self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_OPEN_WINDOW_DETECT]: True}
-        ):
-            await self.subject.async_toggle()
-
-    async def test_toggle_turns_the_switch_off_when_it_was_on(self):
-        self.dps[PROPERTY_TO_DPS_ID[ATTR_OPEN_WINDOW_DETECT]] = True
-        async with assert_device_properties_set(
-            self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_OPEN_WINDOW_DETECT]: False}
-        ):
-            await self.subject.async_toggle()
-
-    async def test_update(self):
-        result = AsyncMock()
-        self.subject._device.async_refresh.return_value = result()
-
-        await self.subject.async_update()
-
-        self.subject._device.async_refresh.assert_called_once()
-        result.assert_awaited()

+ 12 - 21
tests/test_device_config.py

@@ -67,17 +67,6 @@ class TestDeviceConfig(unittest.TestCase):
             parsed = TuyaDeviceConfig(cfg)
             self.assertIsNotNone(parsed.legacy_type)
             self.assertIsNotNone(parsed.primary_entity)
-            self.assertIsNotNone(
-                parsed.primary_entity.legacy_class,
-                f"No class for {parsed.legacy_type}/primary entity",
-            )
-            for e in parsed.secondary_entities():
-                # Exception for entity types that were already moved to the new
-                # generic classes
-                if e.entity != "lock" and e.entity != "light":
-                    self.assertIsNotNone(
-                        e.legacy_class, f"No class for {parsed.legacy_type}/{e.name}"
-                    )
 
     def _test_detect(self, payload, legacy_type, legacy_class):
         """Test that payload is detected as the correct type and class."""
@@ -90,10 +79,11 @@ class TestDeviceConfig(unittest.TestCase):
                 self.assertFalse(matched)
                 matched = True
                 quality = cfg.match_quality(payload)
-                self.assertEqual(
-                    cfg.primary_entity.legacy_class.__name__,
-                    legacy_class,
-                )
+                if legacy_class is not None:
+                    self.assertEqual(
+                        cfg.primary_entity.legacy_class.__name__,
+                        legacy_class,
+                    )
             else:
                 false_matches.append(cfg)
 
@@ -112,10 +102,11 @@ class TestDeviceConfig(unittest.TestCase):
 
         # Ensure the same correct config is returned when looked up by type
         cfg = config_for_legacy_use(legacy_type)
-        self.assertEqual(
-            cfg.primary_entity.legacy_class.__name__,
-            legacy_class,
-        )
+        if legacy_class is not None:
+            self.assertEqual(
+                cfg.primary_entity.legacy_class.__name__,
+                legacy_class,
+            )
 
     def test_gpph_heater_detection(self):
         """Test that GPPH heater can be detected from its sample payload."""
@@ -170,7 +161,7 @@ class TestDeviceConfig(unittest.TestCase):
         self._test_detect(
             KOGAN_SOCKET_PAYLOAD,
             CONF_TYPE_KOGAN_SWITCH,
-            "KoganSocketSwitch",
+            None,
         )
 
     def test_kogan_socket2_detection(self):
@@ -178,7 +169,7 @@ class TestDeviceConfig(unittest.TestCase):
         self._test_detect(
             KOGAN_SOCKET_PAYLOAD2,
             CONF_TYPE_KOGAN_SWITCH,
-            "KoganSocketSwitch",
+            None,
         )
 
     def test_gsh_heater_detection(self):

+ 1 - 2
tests/test_switch.py

@@ -3,7 +3,7 @@ from pytest_homeassistant_custom_component.common import MockConfigEntry
 from unittest import IsolatedAsyncioTestCase
 from unittest.mock import AsyncMock, Mock, patch
 
-from homeassistant.components.switch import ATTR_CURRENT_POWER_W, DEVICE_CLASS_OUTLET
+from homeassistant.components.switch import DEVICE_CLASS_OUTLET
 from homeassistant.const import STATE_UNAVAILABLE
 
 from custom_components.tuya_local.const import (
@@ -16,7 +16,6 @@ from custom_components.tuya_local.const import (
 )
 from custom_components.tuya_local.generic.switch import TuyaLocalSwitch
 from custom_components.tuya_local.helpers.device_config import config_for_legacy_use
-from custom_components.tuya_local.kogan_socket.switch import KoganSocketSwitch
 from custom_components.tuya_local.switch import async_setup_entry
 
 from .const import KOGAN_SOCKET_PAYLOAD