Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sensor bug when washing machine is offline #115

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading