diff --git a/blebox_uniapi/box_types.py b/blebox_uniapi/box_types.py index f345abf..6a1d4d9 100644 --- a/blebox_uniapi/box_types.py +++ b/blebox_uniapi/box_types.py @@ -280,7 +280,9 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { + # note: switchbox/switchboxD sensors are currently not indexed (singletons) "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value", + "activePower": lambda x: "sensors[?type == 'activePower']|[0]|value", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, @@ -305,7 +307,9 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { + # note: switchbox/switchboxD sensors are currently not indexed (singletons) "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value", + "activePower": lambda x: "sensors[?type == 'activePower']|[0]|value", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, @@ -330,7 +334,9 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { + # note: switchbox/switchboxD sensors are currently not indexed (singletons) "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value", + "activePower": lambda x: "sensors[?type == 'activePower']|[0]|value", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, @@ -357,7 +363,9 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { + # note: switchbox/switchboxD sensors are currently not indexed (singletons) "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value ", + "activePower": lambda x: "sensors[?type == 'activePower']|[0]|value", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, @@ -392,7 +400,9 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { + # note: switchbox/switchboxD sensors are currently not indexed (singletons) "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value ", + "activePower": lambda x: "sensors[?type == 'activePower']|[0]|value", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, @@ -424,7 +434,9 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { + # note: switchbox/switchboxD sensors are currently not indexed (singletons) "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value ", + "activePower": lambda x: "sensors[?type == 'activePower']|[0]|value", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, @@ -456,7 +468,9 @@ def get_latest_api_level(product_type: str) -> Union[dict, int]: [ "switchBox.energy", { + # note: switchbox/switchboxD sensors are currently not indexed (singletons) "powerConsumption": lambda x: "powerMeasuring.powerConsumption[0]|value ", + "activePower": lambda x: "sensors[?type == 'activePower']|[0]|value", "periodS": "powerMeasuring.powerConsumption[0]|periodS", "measurement_enabled": "powerMeasuring.enabled", }, diff --git a/blebox_uniapi/sensor.py b/blebox_uniapi/sensor.py index d35b684..5cab9b8 100644 --- a/blebox_uniapi/sensor.py +++ b/blebox_uniapi/sensor.py @@ -35,7 +35,9 @@ def _sensor_states(extended_state: dict): # note: probably we should iterate extended state in future if there # are other api flavours other than multiSensor that provide sensors states = extended_state.get("multiSensor", {}).get("sensors", []) - + # note: but for now we are only able to support non-multisensor devices + # that provide sensor data in extended data payload root + states.extend(extended_state.get("sensors", [])) # note: power measuring feature predates multiSensor API, so we need a small # shim to adapt older shape of power measuring schema to the new sensor API if "powerMeasuring" in extended_state: