diff --git a/blebox_uniapi/box_types.py b/blebox_uniapi/box_types.py index 2efe71c..f345abf 100644 --- a/blebox_uniapi/box_types.py +++ b/blebox_uniapi/box_types.py @@ -280,7 +280,7 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { - "powerMeasurement": lambda x: "powerMeasuring.powerConsumption[0]|value", + "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, @@ -305,7 +305,7 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { - "powerMeasurement": lambda x: "powerMeasuring.powerConsumption[0]|value", + "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, @@ -330,7 +330,7 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { - "powerMeasurement": lambda x: "powerMeasuring.powerConsumption[0]|value", + "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, @@ -357,7 +357,7 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { - "powerMeasurement": lambda x: "powerMeasuring.powerConsumption[0]|value ", + "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value ", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, @@ -392,7 +392,7 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { - "powerMeasurement": lambda x: "powerMeasuring.powerConsumption[0]|value ", + "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value ", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, @@ -424,7 +424,7 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { - "powerMeasurement": lambda x: "powerMeasuring.powerConsumption[0]|value ", + "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value ", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, @@ -456,7 +456,7 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { - "powerMeasurement": lambda x: "powerMeasuring.powerConsumption[0]|value ", + "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value ", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, diff --git a/blebox_uniapi/sensor.py b/blebox_uniapi/sensor.py index b98fde3..d35b684 100644 --- a/blebox_uniapi/sensor.py +++ b/blebox_uniapi/sensor.py @@ -42,7 +42,7 @@ def _sensor_states(extended_state: dict): power_states = extended_state["powerMeasuring"].get("powerConsumption", []) # note: be careful of names as this has been historically named differently # in home-assistant - states.extend({"type": "powerMeasurement", **s} for s in power_states) + states.extend({"type": "powerConsumption", **s} for s in power_states) return states @classmethod @@ -133,6 +133,7 @@ def __str__(self): @SensorFactory.register("forwardActiveEnergy", unit="kWh") @SensorFactory.register("illuminance", unit="lx", scale=100) @SensorFactory.register("humidity", unit="percentage", scale=100) +@SensorFactory.register("wind", unit="m/s", scale=10) class GenericSensor(BaseSensor): def __init__( # base sensor params @@ -173,17 +174,7 @@ def after_update(self): self._native_value = native -@SensorFactory.register("wind", unit="m/s", scale=10) -class Wind(GenericSensor): - @property - def device_class(self): - # compat/legacy: this sensor is advertised in homeassistant as wind speed - # despite different sensor-type naming. Keep it consistent until we rectiify - # this upstream - return "wind_speed" - - -@SensorFactory.register("powerMeasurement", unit="kWh") +@SensorFactory.register("powerConsumption", unit="kWh") class PowerConsumption(GenericSensor): # note: almost the same as typical generic sensor but also provides extra property # to read last reset value