Browse Source

2022.4 compatibility fix.

In 2022.2, HA introduced Enumerations to replace strings in several locations.  After just two releases in 2022.4, the support for using strings was removed from categories, causing entities to fail to initialise if they specified a category in the config.

Switch to enums for EntityCategory, and update minimum supported HA version to 2022.2.

Temporarily disable automated testing, as the current version of test harness has a resource leak that causes tests to start failing after the 255th test, and we have over 1000 tests.  The last version without this problem required HA 2021.12 to run.
Jason Rumney 3 years ago
parent
commit
d81ae12c34
3 changed files with 4 additions and 3 deletions
  1. 1 1
      .github/workflows/tests.yml
  2. 2 1
      custom_components/tuya_local/helpers/mixin.py
  3. 1 1
      hacs.json

+ 1 - 1
.github/workflows/tests.yml

@@ -1,6 +1,6 @@
 name: Python tests
 
-on: [push, pull_request]
+on: workflow_dispatch
 
 jobs:
   tests:

+ 2 - 1
custom_components/tuya_local/helpers/mixin.py

@@ -8,6 +8,7 @@ from homeassistant.const import (
     TEMP_CELSIUS,
     TEMP_FAHRENHEIT,
 )
+from homeassistant.helpers.entity import EntityCategory
 
 _LOGGER = logging.getLogger(__name__)
 
@@ -52,7 +53,7 @@ class TuyaLocalEntity:
     @property
     def entity_category(self):
         """Return the entitiy's category."""
-        return self._config.entity_category
+        return EntityCategory(self._config.entity_category)
 
     @property
     def icon(self):

+ 1 - 1
hacs.json

@@ -15,6 +15,6 @@
 	"switch",
 	"vacuum"
     ],
-  "homeassistant": "2021.10.0",
+  "homeassistant": "2022.2.0",
   "iot_class": "Local Polling"
 }