Skip to content

Commit

Permalink
Merge pull request #115 from JyunWei-Su/master
Browse files Browse the repository at this point in the history
Fix sensor bug when washing machine is offline
  • Loading branch information
osk2 authored Aug 8, 2024
2 parents 089cd81 + 191da3d commit 062136c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
25 changes: 6 additions & 19 deletions custom_components/panasonic_smart_app/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,9 @@ async def async_setup_entry(hass, entry, async_add_entities) -> bool:
)

if len(current_device_commands) > 0:
is_on_timer_supported = (
len(
[
command
for command in current_device_commands[0]["JSON"][0]["list"]
if command["CommandType"] == "0x55"
]
)
> 0
is_on_timer_supported = any(
command["CommandType"] == "0x55"
for command in current_device_commands[0]["JSON"][0]["list"]
)

if is_on_timer_supported:
Expand All @@ -79,7 +73,6 @@ async def async_setup_entry(hass, entry, async_add_entities) -> bool:
)

if device_type == DEVICE_TYPE_AC:

numbers.append(
PanasonicACOffTimer(
coordinator,
Expand All @@ -90,15 +83,9 @@ async def async_setup_entry(hass, entry, async_add_entities) -> bool:
)

if len(current_device_commands) > 0:
is_on_timer_supported = (
len(
[
command
for command in current_device_commands[0]["JSON"][0]["list"]
if command["CommandType"] == "0x0b"
]
)
> 0
is_on_timer_supported = any(
command["CommandType"] == "0x0b"
for command in current_device_commands[0]["JSON"][0]["list"]
)

if is_on_timer_supported:
Expand Down
5 changes: 5 additions & 0 deletions custom_components/panasonic_smart_app/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,14 @@ def state(self) -> int:
raw_mode_list = list(
filter(lambda c: c["CommandType"] == "0x50", self.commands)
)[0]["Parameters"]

if not raw_mode_list:
return STATE_UNAVAILABLE

_current_status = list(
filter(lambda m: m[1] == int(washing_status), raw_mode_list)
)[0][0]

_LOGGER.debug(f"[{self.label}] state: {_current_status}")
return _current_status

Expand Down

0 comments on commit 062136c

Please sign in to comment.