Skip to content

Commit

Permalink
i guess we need key for some reason.
Browse files Browse the repository at this point in the history
  • Loading branch information
dalinicus committed Jan 28, 2025
1 parent 64526a2 commit 065b362
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
14 changes: 10 additions & 4 deletions custom_components/ac_infinity/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
class ACInfinitySensorEntityDescription(SensorEntityDescription):
"""Describes ACInfinity Number Sensor Entities."""

key: str
icon: str | None
translation_key: str | None
device_class: SensorDeviceClass | None
Expand All @@ -68,8 +69,6 @@ class ACInfinityControllerSensorEntityDescription(
):
"""Describes ACInfinity Controller Sensor Entities."""

key: str


@dataclass
class ACInfinitySensorSensorEntityDescription(
Expand All @@ -84,8 +83,6 @@ class ACInfinityPortSensorEntityDescription(
):
"""Describes ACInfinity Device Sensor Entities."""

key: str


def __suitable_fn_controller_property_default(
entity: ACInfinityEntity, controller: ACInfinityController
Expand Down Expand Up @@ -269,6 +266,8 @@ def __get_next_mode_change_timestamp(

SENSOR_DESCRIPTIONS: dict[int, ACInfinitySensorSensorEntityDescription] = {
SensorType.PROBE_TEMPERATURE: ACInfinitySensorSensorEntityDescription(
# key is not used for sensors.
key="probeTemperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
Expand All @@ -279,6 +278,7 @@ def __get_next_mode_change_timestamp(
get_value_fn=__get_value_fn_sensor_value_temperature,
),
SensorType.PROBE_HUMIDITY: ACInfinitySensorSensorEntityDescription(
key="probeHumidity",
device_class=SensorDeviceClass.HUMIDITY,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=PERCENTAGE,
Expand All @@ -289,6 +289,7 @@ def __get_next_mode_change_timestamp(
get_value_fn=__get_value_fn_sensor_value_default,
),
SensorType.PROBE_VPD: ACInfinitySensorSensorEntityDescription(
key="probeVaporPressureDeficit",
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
suggested_unit_of_measurement=UnitOfPressure.KPA,
Expand All @@ -299,6 +300,7 @@ def __get_next_mode_change_timestamp(
get_value_fn=__get_value_fn_sensor_value_default,
),
SensorType.EXTERNAL_TEMPERATURE: ACInfinitySensorSensorEntityDescription(
key="externalTemperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
Expand All @@ -309,6 +311,7 @@ def __get_next_mode_change_timestamp(
get_value_fn=__get_value_fn_sensor_value_temperature,
),
SensorType.EXTERNAL_HUMIDITY: ACInfinitySensorSensorEntityDescription(
key="externalHumidity",
device_class=SensorDeviceClass.HUMIDITY,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=PERCENTAGE,
Expand All @@ -319,6 +322,7 @@ def __get_next_mode_change_timestamp(
get_value_fn=__get_value_fn_sensor_value_default,
),
SensorType.EXTERNAL_VPD: ACInfinitySensorSensorEntityDescription(
key="externalVaporPressureDeficit",
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
suggested_unit_of_measurement=UnitOfPressure.KPA,
Expand All @@ -329,6 +333,7 @@ def __get_next_mode_change_timestamp(
get_value_fn=__get_value_fn_sensor_value_default,
),
SensorType.CO2: ACInfinitySensorSensorEntityDescription(
key="co2Sensor",
device_class=SensorDeviceClass.CO2,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
Expand All @@ -339,6 +344,7 @@ def __get_next_mode_change_timestamp(
get_value_fn=__get_value_fn_sensor_value_default,
),
SensorType.LIGHT: ACInfinitySensorSensorEntityDescription(
key="lightSensor",
device_class=SensorDeviceClass.ILLUMINANCE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=LIGHT_LUX,
Expand Down
6 changes: 6 additions & 0 deletions custom_components/ac_infinity/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@
"external_vapor_pressure_deficit": {
"name": "External VPD"
},
"co2_sensor": {
"name": "CO2"
},
"light_sensor": {
"name": "Light Level"
},
"current_power": {
"name": "Current Power"
},
Expand Down
6 changes: 6 additions & 0 deletions custom_components/ac_infinity/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@
"external_vapor_pressure_deficit": {
"name": "External VPD"
},
"co2_sensor": {
"name": "CO2"
},
"light_sensor": {
"name": "Light Level"
},
"current_power": {
"name": "Current Power"
},
Expand Down
3 changes: 2 additions & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ async def test_get_device_all_device_meta_data_returns_empty_list(self, data):
"dev_type,expected_model",
[
(11, "UIS Controller 69 Pro (CTR69P)"),
(18, "UIS CONTROLLER 69 Pro+ (CTR69Q)"),
(18, "UIS Controller 69 Pro+ (CTR69Q)"),
(20, "UIS Controller AI+ (CTR89Q)"),
(3, "UIS Controller Type 3"),
],
)
Expand Down

0 comments on commit 065b362

Please sign in to comment.