Răsfoiți Sursa

Remove obsolete constants.

SCAN_INTERVAL was particularly misleading, as it suggests some control
over how often Home Assistant polls for changes, but this is only
available to single platform integrations for some time now, and the
platforms themselves decide how often is appropriate to poll by default.
Other CONF_<platform> constants were only used in tests for migration
and entity creation.
Jason Rumney 3 ani în urmă
părinte
comite
9eb57679e9

+ 0 - 2
custom_components/tuya_local/__init__.py

@@ -15,9 +15,7 @@ from homeassistant.helpers.entity_registry import async_migrate_entries
 
 from .const import (
     CONF_DEVICE_ID,
-    CONF_LIGHT,
     CONF_LOCAL_KEY,
-    CONF_LOCK,
     CONF_TYPE,
     DOMAIN,
 )

+ 0 - 8
custom_components/tuya_local/const.py

@@ -5,12 +5,4 @@ DOMAIN = "tuya_local"
 CONF_DEVICE_ID = "device_id"
 CONF_LOCAL_KEY = "local_key"
 CONF_TYPE = "type"
-CONF_CLIMATE = "climate"
-CONF_FAN = "fan"
-CONF_LIGHT = "light"
-CONF_LOCK = "lock"
-CONF_SWITCH = "switch"
-CONF_HUMIDIFIER = "humidifier"
-CONF_WATER_HEATER = "water_heater"
 API_PROTOCOL_VERSIONS = [3.3, 3.1, 3.2, 3.4]
-SCAN_INTERVAL = timedelta(seconds=30)

+ 1 - 2
tests/test_climate.py

@@ -3,7 +3,6 @@ from pytest_homeassistant_custom_component.common import MockConfigEntry
 from unittest.mock import AsyncMock, Mock
 
 from custom_components.tuya_local.const import (
-    CONF_CLIMATE,
     CONF_DEVICE_ID,
     CONF_TYPE,
     DOMAIN,
@@ -29,7 +28,7 @@ async def test_init_entry(hass):
     hass.data[DOMAIN]["dummy"]["device"] = m_device
 
     await async_setup_entry(hass, entry, m_add_entities)
-    assert type(hass.data[DOMAIN]["dummy"][CONF_CLIMATE]) == TuyaLocalClimate
+    assert type(hass.data[DOMAIN]["dummy"]["climate"]) == TuyaLocalClimate
     m_add_entities.assert_called_once()
 
 

+ 11 - 17
tests/test_config_flow.py

@@ -13,14 +13,8 @@ from custom_components.tuya_local import (
     async_setup_entry,
 )
 from custom_components.tuya_local.const import (
-    CONF_CLIMATE,
     CONF_DEVICE_ID,
-    CONF_FAN,
-    CONF_HUMIDIFIER,
-    CONF_LIGHT,
     CONF_LOCAL_KEY,
-    CONF_LOCK,
-    CONF_SWITCH,
     CONF_TYPE,
     DOMAIN,
 )
@@ -78,7 +72,7 @@ async def test_migrate_entry(mock_setup, hass):
             CONF_HOST: "hostname",
             CONF_LOCAL_KEY: "localkey",
             CONF_TYPE: "auto",
-            CONF_CLIMATE: True,
+            "climate": True,
             "child_lock": True,
             "display_light": True,
         },
@@ -97,7 +91,7 @@ async def test_migrate_entry(mock_setup, hass):
             CONF_HOST: "hostname",
             CONF_LOCAL_KEY: "localkey",
             CONF_TYPE: "unknown",
-            CONF_CLIMATE: False,
+            "climate": False,
         },
     )
     assert not await async_migrate_entry(hass, entry)
@@ -114,7 +108,7 @@ async def test_migrate_entry(mock_setup, hass):
             CONF_TYPE: "auto",
         },
         options={
-            CONF_CLIMATE: False,
+            "climate": False,
         },
     )
     assert not await async_migrate_entry(hass, entry)
@@ -133,7 +127,7 @@ async def test_migrate_entry(mock_setup, hass):
             CONF_TYPE: "smartplugv1",
         },
         options={
-            CONF_SWITCH: True,
+            "switch": True,
         },
     )
     assert await async_migrate_entry(hass, entry)
@@ -152,7 +146,7 @@ async def test_migrate_entry(mock_setup, hass):
             CONF_TYPE: "smartplugv1",
         },
         options={
-            CONF_SWITCH: True,
+            "switch": True,
         },
     )
     assert await async_migrate_entry(hass, entry)
@@ -171,11 +165,11 @@ async def test_migrate_entry(mock_setup, hass):
             CONF_TYPE: "goldair_dehumidifier",
         },
         options={
-            CONF_HUMIDIFIER: True,
-            CONF_FAN: True,
-            CONF_LIGHT: True,
-            CONF_LOCK: False,
-            CONF_SWITCH: True,
+            "humidifier": True,
+            "fan": True,
+            "light": True,
+            "lock": False,
+            "switch": True,
         },
     )
     assert await async_migrate_entry(hass, entry)
@@ -402,7 +396,7 @@ async def test_flow_choose_entities_init(hass):
     except vol.MultipleInvalid:
         assert False
     try:
-        result["data_schema"]({CONF_CLIMATE: True})
+        result["data_schema"]({"climate": True})
         assert False
     except vol.MultipleInvalid:
         pass

+ 2 - 3
tests/test_fan.py

@@ -3,7 +3,6 @@ from pytest_homeassistant_custom_component.common import MockConfigEntry
 from unittest.mock import AsyncMock, Mock
 
 from custom_components.tuya_local.const import (
-    CONF_FAN,
     CONF_DEVICE_ID,
     CONF_TYPE,
     DOMAIN,
@@ -29,7 +28,7 @@ async def test_init_entry(hass):
     hass.data[DOMAIN]["dummy"]["device"] = m_device
 
     await async_setup_entry(hass, entry, m_add_entities)
-    assert type(hass.data[DOMAIN]["dummy"][CONF_FAN]) == TuyaLocalFan
+    assert type(hass.data[DOMAIN]["dummy"]["fan"]) == TuyaLocalFan
     m_add_entities.assert_called_once()
 
 
@@ -53,7 +52,7 @@ async def test_init_entry_as_secondary(hass):
     hass.data[DOMAIN]["dummy"]["device"] = m_device
 
     await async_setup_entry(hass, entry, m_add_entities)
-    assert type(hass.data[DOMAIN]["dummy"][CONF_FAN]) == TuyaLocalFan
+    assert type(hass.data[DOMAIN]["dummy"]["fan"]) == TuyaLocalFan
     m_add_entities.assert_called_once()
 
 

+ 1 - 2
tests/test_humidifier.py

@@ -3,7 +3,6 @@ from pytest_homeassistant_custom_component.common import MockConfigEntry
 from unittest.mock import AsyncMock, Mock
 
 from custom_components.tuya_local.const import (
-    CONF_HUMIDIFIER,
     CONF_DEVICE_ID,
     CONF_TYPE,
     DOMAIN,
@@ -32,7 +31,7 @@ async def test_init_entry(hass):
     hass.data[DOMAIN]["dummy"]["device"] = m_device
 
     await async_setup_entry(hass, entry, m_add_entities)
-    assert type(hass.data[DOMAIN]["dummy"][CONF_HUMIDIFIER]) == TuyaLocalHumidifier
+    assert type(hass.data[DOMAIN]["dummy"]["humidifier"]) == TuyaLocalHumidifier
     m_add_entities.assert_called_once()
 
 

+ 1 - 2
tests/test_switch.py

@@ -4,7 +4,6 @@ from unittest.mock import AsyncMock, Mock
 
 from custom_components.tuya_local.const import (
     CONF_DEVICE_ID,
-    CONF_SWITCH,
     CONF_TYPE,
     DOMAIN,
 )
@@ -29,7 +28,7 @@ async def test_init_entry(hass):
     hass.data[DOMAIN]["dummy"]["device"] = m_device
 
     await async_setup_entry(hass, entry, m_add_entities)
-    assert type(hass.data[DOMAIN]["dummy"][CONF_SWITCH]) == TuyaLocalSwitch
+    assert type(hass.data[DOMAIN]["dummy"]["switch"]) == TuyaLocalSwitch
     m_add_entities.assert_called_once()
 
 

+ 1 - 2
tests/test_water_heater.py

@@ -5,7 +5,6 @@ from unittest.mock import AsyncMock, Mock
 from custom_components.tuya_local.const import (
     CONF_DEVICE_ID,
     CONF_TYPE,
-    CONF_WATER_HEATER,
     DOMAIN,
 )
 from custom_components.tuya_local.generic.water_heater import TuyaLocalWaterHeater
@@ -29,7 +28,7 @@ async def test_init_entry(hass):
     hass.data[DOMAIN]["dummy"]["device"] = m_device
 
     await async_setup_entry(hass, entry, m_add_entities)
-    assert type(hass.data[DOMAIN]["dummy"][CONF_WATER_HEATER]) == TuyaLocalWaterHeater
+    assert type(hass.data[DOMAIN]["dummy"]["water_heater"]) == TuyaLocalWaterHeater
     m_add_entities.assert_called_once()