Просмотр исходного кода

Tests: stricter checking on state_class.

When class is at dp level, it corresponds to state_class (for sensors only),
which has a small set of fixed possible values.

As inexperienced users tend to confuse this with the device_class (class at
entity level), it will help to check this more thoroughly.
Jason Rumney 1 год назад
Родитель
Сommit
20ee69d4b1
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      tests/test_device_config.py

+ 7 - 1
tests/test_device_config.py

@@ -98,7 +98,13 @@ DP_SCHEMA = vol.Schema(
         },
         vol.Optional("unit"): str,
         vol.Optional("precision"): vol.Any(int, float),
-        vol.Optional("class"): str,
+        vol.Optional("class"): vol.In(
+            [
+                "measurement",
+                "total",
+                "total_increasing",
+            ]
+        ),
         vol.Optional("optional"): True,
         vol.Optional("persist"): False,
         vol.Optional("hidden"): True,