Skip to content

Commit

Permalink
Fix to fan.py for missing attribute of motorstate
Browse files Browse the repository at this point in the history
  • Loading branch information
c503ghosh committed Feb 29, 2024
1 parent 9f795e9 commit c1347e8
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions custom_components/dirigera_platform/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def supported_features(self):

@property
def motor_state(self) -> int:
return self._json_data.motor_state
return self._json_data.attributes.motor_state

@property
def percentage(self) -> int:
Expand All @@ -131,47 +131,47 @@ def percentage(self) -> int:

@property
def fan_mode_sequence(self) -> str:
return self._json_data.fan_mode_sequence
return self._json_data.attributes.fan_mode_sequence

@property
def preset_modes(self):
return [ e.value for e in FanModeEnum]

@property
def preset_mode(self) -> str:
return self._json_data.fan_mode
return self._json_data.attributes.fan_mode

@property
def speed_count(self):
return 50

@property
def motor_runtime(self):
return self._json_data.motor_runtime
return self._json_data.attributes.motor_runtime

@property
def filter_alarm_status(self) -> bool:
return self._json_data.fan_alarm_status
return self._json_data.attributes.filter_alarm_status

@property
def filter_elapsed_time(self) -> int:
return self._json_data.filter_elapsed_time
return self._json_data.attributes.filter_elapsed_time

@property
def filter_lifetime(self) -> int:
return self._json_data.filter_lifetime
return self._json_data.attributes.filter_lifetime

@property
def current_p_m25(self) -> int:
return self._json_data.current_p_m25
return self._json_data.attributes.current_p_m25

@property
def status_light(self) -> bool:
return self._json_data.status_light
return self._json_data.attributes.status_light

@property
def child_lock(self) -> bool:
return self._json_data.child_lock
return self._json_data.attributes.child_lock

@property
def is_on(self):
Expand All @@ -183,7 +183,7 @@ def set_percentage(self, percentage: int) -> None:
# Convert percent to speed
desired_speed = math.ceil(percentage * 50 / 100)
logger.debug("set_percentage got : {}, scaled to : {}".format(percentage, desired_speed))
self.json_data.set_motor_state(desired_speed)
self._json_data.set_motor_state(desired_speed)

def set_status_light(self, status:bool) -> None:
logger.debug("set_status_light : {}".format(status))
Expand All @@ -195,18 +195,18 @@ def set_child_lock(self, status: bool) -> None:

def set_fan_mode(self, preset_mode: FanModeEnum) -> None:
logger.debug("set_fan_mode : {}".format(preset_mode.value))
self.json_data.set_fan_mode(preset_mode)
self._json_data.set_fan_mode(preset_mode)

def set_preset_mode(self, preset_mode: str):
logger.debug("set_preset_mode : {}".format(preset_mode))
mode_to_set = None
if preset_mode == FanModeEnum.AUTO:
if preset_mode == 'auto':
mode_to_set = FanModeEnum.AUTO
elif preset_mode == FanModeEnum.HIGH:
elif preset_mode == 'high':
mode_to_set = FanModeEnum.HIGH
elif preset_mode == FanModeEnum.MEDIUM:
elif preset_mode == 'medium':
mode_to_set = FanModeEnum.MEDIUM
elif preset_mode == FanModeEnum.LOW:
elif preset_mode == 'low':
mode_to_set = FanModeEnum.LOW

if mode_to_set is None:
Expand Down Expand Up @@ -316,7 +316,7 @@ def update(self):

@property
def icon(self):
return "mdi:air-filter"
return self._icon

@property
def name(self):
Expand Down Expand Up @@ -357,6 +357,10 @@ def __init__(self, device:ikea_starkvind_air_purifier_device, device_class: Bina
def update(self):
self._device.update()

@property
def icon(self):
return self._icon

@property
def name(self):
return self._device.name + " " + self._prefix.replace("_"," ")
Expand Down Expand Up @@ -398,6 +402,10 @@ def __init__(self, device:ikea_starkvind_air_purifier_device, prefix: str, is_on
def update(self):
self._device.update()

@property
def icon(self):
return self._icon

@property
def name(self):
return self._device.name + " " + self._prefix.replace("_"," ")
Expand Down

0 comments on commit c1347e8

Please sign in to comment.