Skip to content

Commit

Permalink
set units
Browse files Browse the repository at this point in the history
  • Loading branch information
hmn committed Nov 9, 2024
1 parent 6615c5d commit fd2f5b6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion custom_components/siku/api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ async def _format_response(self, data: dict) -> dict:
"mode": data["operation_mode"],
"humidity": int(data["humidity_level"]),
"alarm": bool(data["alarm_status"] == NoYes.YES),
"filter_timer": int(data["timer_countdown"]),
"timer_countdown": int(data["timer_countdown"]),
"boost": bool(
data["boost_mode_after_sensor"] == NoYesYes.YES
or data["boost_mode_after_sensor"] == NoYesYes.YES2
Expand Down
9 changes: 8 additions & 1 deletion custom_components/siku/api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
COMMAND_DEVICE_TYPE = "B9"
COMMAND_BOOST = "06"
COMMAND_MODE = "07"
COMMAND_TIMER_COUNTDOWN = "11"
COMMAND_CURRENT_HUMIDITY = "25"
COMMAND_MANUAL_SPEED = "44"
COMMAND_FAN1RPM = "4A"
Expand Down Expand Up @@ -105,6 +106,7 @@ async def status(self) -> dict:
COMMAND_DIRECTION,
COMMAND_BOOST,
COMMAND_MODE,
COMMAND_TIMER_COUNTDOWN,
COMMAND_CURRENT_HUMIDITY,
COMMAND_FAN1RPM,
COMMAND_FILTER_TIMER,
Expand Down Expand Up @@ -325,6 +327,10 @@ async def _translate_response(self, data: dict) -> dict:
firmware = f"{int(data[COMMAND_READ_FIRMWARE_VERSION][0], 16)}.{int(data[COMMAND_READ_FIRMWARE_VERSION][1], 16)}"
except KeyError:
firmware = None
try:
timer_countdown = int(data[COMMAND_TIMER_COUNTDOWN], 16)
except KeyError:
timer_countdown = 0
return {
"is_on": is_on,
"speed": speed,
Expand All @@ -339,7 +345,8 @@ async def _translate_response(self, data: dict) -> dict:
"humidity": humidity,
"rpm": rpm,
"firmware": firmware,
"filter_timer": filter_timer,
"filter_timer_days": filter_timer,
"timer_countdown": timer_countdown,
"alarm": alarm,
"version": "2",
}
Expand Down
28 changes: 19 additions & 9 deletions custom_components/siku/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,44 +67,54 @@ class SikuSensorEntityDescription(SensorEntityDescription):
icon="mdi:alarm-light",
),
SikuSensorEntityDescription(
key="filter_timer",
key="filter_timer_days",
name="Filter timer countdown",
icon="mdi:timer",
native_unit_of_measurement=UnitOfTime.MINUTES,
suggested_display_precision=2,
suggested_display_precision=0,
suggested_unit_of_measurement=UnitOfTime.DAYS,
device_class=SensorDeviceClass.DURATION,
state_class=SensorStateClass.TOTAL,
state_class=SensorStateClass.MEASUREMENT,
),
SikuSensorEntityDescription(
key="timer_countdown",
name="Timer countdown",
icon="mdi:timer",
native_unit_of_measurement=UnitOfTime.SECONDS,
suggested_display_precision=0,
suggested_unit_of_measurement=UnitOfTime.MINUTES,
device_class=SensorDeviceClass.DURATION,
state_class=SensorStateClass.MEASUREMENT,
),
SikuSensorEntityDescription(
key="boost_mode_timer",
name="Boost mode timer",
icon="mdi:timer",
native_unit_of_measurement=UnitOfTime.MINUTES,
suggested_display_precision=2,
suggested_display_precision=0,
suggested_unit_of_measurement=UnitOfTime.DAYS,
device_class=SensorDeviceClass.DURATION,
state_class=SensorStateClass.TOTAL,
state_class=SensorStateClass.MEASUREMENT,
),
SikuSensorEntityDescription(
key="night_mode_timer",
name="Sleep mode timer",
icon="mdi:timer",
native_unit_of_measurement=UnitOfTime.MINUTES,
suggested_display_precision=2,
suggested_display_precision=0,
suggested_unit_of_measurement=UnitOfTime.DAYS,
device_class=SensorDeviceClass.DURATION,
state_class=SensorStateClass.TOTAL,
state_class=SensorStateClass.MEASUREMENT,
),
SikuSensorEntityDescription(
key="party_mode_timer",
name="Party mode timer",
icon="mdi:timer",
native_unit_of_measurement=UnitOfTime.MINUTES,
suggested_display_precision=2,
suggested_display_precision=0,
suggested_unit_of_measurement=UnitOfTime.DAYS,
device_class=SensorDeviceClass.DURATION,
state_class=SensorStateClass.TOTAL,
state_class=SensorStateClass.MEASUREMENT,
),
SikuSensorEntityDescription(
key="boost",
Expand Down

0 comments on commit fd2f5b6

Please sign in to comment.