Răsfoiți Sursa

maint!(entity): use new UnitOfDenstity enum

HA 2026.8 deprecates CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
replacing it with UnitOfDensity.MICROGRAMS_PER_CUBIC_METER

This resolves the deprecation warning which has attracted multiple
reports and a PR over the past 4 weeks since they released the beta.

BREAKING CHANGE: requires HA 2026.8.0 or later

Issue #5801
Jason Rumney 5 ore în urmă
părinte
comite
f7d88ce746
3 a modificat fișierele cu 6 adăugiri și 6 ștergeri
  1. 3 3
      custom_components/tuya_local/entity.py
  2. 1 1
      hacs.json
  3. 2 2
      tests/test_entity.py

+ 3 - 3
custom_components/tuya_local/entity.py

@@ -6,7 +6,7 @@ import json
 import logging
 
 from homeassistant.const import (
-    CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
+    UnitOfDensity,
     UnitOfArea,
     UnitOfTemperature,
 )
@@ -143,8 +143,8 @@ class TuyaLocalEntity:
 UNIT_ASCII_MAP = {
     "C": UnitOfTemperature.CELSIUS.value,
     "F": UnitOfTemperature.FAHRENHEIT.value,
-    "ugm3": CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
-    "m2": UnitOfArea.SQUARE_METERS,
+    "ugm3": UnitOfDensity.MICROGRAMS_PER_CUBIC_METER.value,
+    "m2": UnitOfArea.SQUARE_METERS.value,
 }
 
 

+ 1 - 1
hacs.json

@@ -1,5 +1,5 @@
 {
     "name": "Tuya Local",
-    "homeassistant": "2026.6.0",
+    "homeassistant": "2026.8.0",
     "hacs": "2.0.0"
 }

+ 2 - 2
tests/test_entity.py

@@ -4,7 +4,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
 
 import pytest
 from homeassistant.const import (
-    CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
+    UnitOfDensity,
     UnitOfArea,
     UnitOfTemperature,
 )
@@ -308,7 +308,7 @@ class TestUnitFromAscii:
         assert unit_from_ascii("F") == UnitOfTemperature.FAHRENHEIT.value
 
     def test_micrograms(self):
-        assert unit_from_ascii("ugm3") == CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
+        assert unit_from_ascii("ugm3") == UnitOfDensity.MICROGRAMS_PER_CUBIC_METER.value
 
     def test_square_meters(self):
         assert unit_from_ascii("m2") == UnitOfArea.SQUARE_METERS