Improve categorization of features (#904)

This updates the categorization of features and makes the id mandatory for features
This commit is contained in:
Teemu R
2024-05-07 11:13:35 +02:00
committed by GitHub
parent 50b5107f75
commit 55653d0346
31 changed files with 131 additions and 52 deletions

View File

@@ -213,6 +213,7 @@ class IotBulb(IotDevice, Bulb):
self._add_feature(
Feature(
device=self,
id="brightness",
name="Brightness",
attribute_getter="brightness",
attribute_setter="set_brightness",
@@ -227,6 +228,7 @@ class IotBulb(IotDevice, Bulb):
self._add_feature(
Feature(
device=self,
id="color_temperature",
name="Color temperature",
container=self,
attribute_getter="color_temp",

View File

@@ -334,6 +334,7 @@ class IotDevice(Device):
self._add_feature(
Feature(
device=self,
id="rssi",
name="RSSI",
attribute_getter="rssi",
icon="mdi:signal",
@@ -344,6 +345,7 @@ class IotDevice(Device):
self._add_feature(
Feature(
device=self,
id="on_since",
name="On since",
attribute_getter="on_since",
icon="mdi:clock",

View File

@@ -91,12 +91,15 @@ class IotDimmer(IotPlug):
self._add_feature(
Feature(
device=self,
id="brightness",
name="Brightness",
attribute_getter="brightness",
attribute_setter="set_brightness",
minimum_value=1,
maximum_value=100,
unit="%",
type=Feature.Type.Number,
category=Feature.Category.Primary,
)
)

View File

@@ -65,6 +65,7 @@ class IotPlug(IotDevice):
self._add_feature(
Feature(
device=self,
id="led",
name="LED",
icon="mdi:led-{state}",
attribute_getter="led",

View File

@@ -22,10 +22,13 @@ class AmbientLight(IotModule):
Feature(
device=device,
container=self,
id="ambient_light",
name="Ambient Light",
icon="mdi:brightness-percent",
attribute_getter="ambientlight_brightness",
type=Feature.Type.Sensor,
category=Feature.Category.Primary,
unit="%",
)
)

View File

@@ -30,10 +30,12 @@ class Cloud(IotModule):
Feature(
device=device,
container=self,
id="cloud_connection",
name="Cloud connection",
icon="mdi:cloud",
attribute_getter="is_connected",
type=Feature.Type.BinarySensor,
category=Feature.Category.Info,
)
)

View File

@@ -24,6 +24,7 @@ class Emeter(Usage):
unit="W",
id="current_power_w", # for homeassistant backwards compat
precision_hint=1,
category=Feature.Category.Primary,
)
)
self._add_feature(
@@ -35,16 +36,19 @@ class Emeter(Usage):
unit="kWh",
id="today_energy_kwh", # for homeassistant backwards compat
precision_hint=3,
category=Feature.Category.Info,
)
)
self._add_feature(
Feature(
device,
id="consumption_this_month",
name="This month's consumption",
attribute_getter="emeter_this_month",
container=self,
unit="kWh",
precision_hint=3,
category=Feature.Category.Info,
)
)
self._add_feature(
@@ -56,6 +60,7 @@ class Emeter(Usage):
unit="kWh",
id="total_energy_kwh", # for homeassistant backwards compat
precision_hint=3,
category=Feature.Category.Info,
)
)
self._add_feature(
@@ -67,6 +72,7 @@ class Emeter(Usage):
unit="V",
id="voltage", # for homeassistant backwards compat
precision_hint=1,
category=Feature.Category.Primary,
)
)
self._add_feature(
@@ -78,6 +84,7 @@ class Emeter(Usage):
unit="A",
id="current_a", # for homeassistant backwards compat
precision_hint=2,
category=Feature.Category.Primary,
)
)