Embed FeatureType inside Feature (#860)

Moves `FeatureType` into `Feature` to make it easier to use the API.
This also enforces that no invalid types are accepted (i.e.,
`Category.Config` cannot be a `Sensor`)
If `--verbose` is used with the cli tool, some extra information is
displayed for features when in the state command.
This commit is contained in:
Teemu R
2024-04-24 18:38:52 +02:00
committed by GitHub
parent e410e4f3f3
commit 65874c0365
23 changed files with 135 additions and 69 deletions

View File

@@ -4,7 +4,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from ...feature import Feature, FeatureType
from ...feature import Feature
from ..smartmodule import SmartModule
if TYPE_CHECKING:
@@ -32,7 +32,7 @@ class AlarmModule(SmartModule):
container=self,
attribute_getter="active",
icon="mdi:bell",
type=FeatureType.BinarySensor,
type=Feature.Type.BinarySensor,
)
)
self._add_feature(
@@ -60,7 +60,7 @@ class AlarmModule(SmartModule):
"Test alarm",
container=self,
attribute_setter="play",
type=FeatureType.Action,
type=Feature.Type.Action,
)
)
self._add_feature(
@@ -69,7 +69,7 @@ class AlarmModule(SmartModule):
"Stop alarm",
container=self,
attribute_setter="stop",
type=FeatureType.Action,
type=Feature.Type.Action,
)
)