Skip to content

Split washer and dryer class #96

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

Merged
merged 16 commits into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions cli_dryer_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def print_menu():

def print_status(dr: Dryer):
print(f"online: {dr.get_online()}")
print(f"state: {dr.get_machine_state()}")
print(f"door open: {dr.get_door_open()}")
print(f"est time remaining: {dr.get_est_time_remaining()}")
print(f"extra power changeable: {dr.get_status_extra_power_changeable()}")
Expand Down Expand Up @@ -46,6 +47,8 @@ def print_status(dr: Dryer):
print(f"set dryness: {dr.get_dryness()}")
print(f"set manual dry time: {dr.get_manual_dry_time()}")
print(f"set cycle select: {dr.get_cycle_select()}")
print(f"set temperature: {dr.get_temperature()}")
print(f"set wrinkle shield: {dr.get_wrinkle_shield()}")

def attr_upd():
print("Attributes updated")
Expand Down
70 changes: 38 additions & 32 deletions tests/test_dryer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,47 @@
from whirlpool.appliancesmanager import AppliancesManager
from whirlpool.auth import Auth
from whirlpool.backendselector import BackendSelector
from whirlpool.dryer import MachineState
from whirlpool.dryer import (
CycleSelect,
Dryness,
MachineState,
Temperature,
WrinkleShield,
)


async def test_attributes(appliances_manager: AppliancesManager):
dryer1 = appliances_manager.dryers[0]
assert dryer1.get_machine_state() == MachineState.Standby
assert dryer1.get_door_open() is False
assert dryer1.get_est_time_remaining() == 1800
assert dryer1.get_drum_light_on() == 0
assert dryer1.get_status_extra_steam_changeable() == 1
assert dryer1.get_status_cycle_select() == 0
assert dryer1.get_status_dryness() == 1
assert dryer1.get_status_manual_dry_time() == 1
assert dryer1.get_status_temperature() == 1
assert dryer1.get_status_wrinkle_shield() == 1
assert dryer1.get_dryness() == 10
assert dryer1.get_manual_dry_time() == 1800
assert dryer1.get_cycle_select() == 11
assert dryer1.get_airflow_status() == 0
assert dryer1.get_cool_down() == 0
assert dryer1.get_damp() == 0
assert dryer1.get_drying() == 0
assert dryer1.get_limited_cycle() == 0
assert dryer1.get_sensing() == 0
assert dryer1.get_static_reduce() == 0
assert dryer1.get_steaming() == 0
assert dryer1.get_wet() == 0
assert dryer1.get_cycle_count() == 195
assert dryer1.get_running_hours() == 148
assert dryer1.get_total_hours() == 6302
assert dryer1.get_rssi_antenna_diversity() == -51
assert dryer1.get_damp_notification_tone_volume() == 0
assert dryer1.get_alert_tone_volume() == 0
assert dryer1.get_temperature() == 2
assert dryer1.get_wrinkle_shield() == 0
dryer = appliances_manager.dryers[0]
assert dryer.get_machine_state() == MachineState.Standby
assert dryer.get_door_open() is False
assert dryer.get_est_time_remaining() == 1800
assert dryer.get_drum_light_on() == 0
assert dryer.get_status_extra_steam_changeable() == 1
assert dryer.get_status_cycle_select() == 0
assert dryer.get_status_dryness() == 1
assert dryer.get_status_manual_dry_time() == 1
assert dryer.get_status_temperature() == 1
assert dryer.get_status_wrinkle_shield() == 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets remove the status_ from these, since it does not seem to add much context. maybe add _enabled as a suffix? at least for the ones that are setting toggles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure about these. It "seems" that they are telling the caller whether that specific attribute can be changed or not. Maybe they should be more like:

assert dryer.get_extra_steam_changeable() == 1
assert dryer.get_cycle_select_changeable() == 0
assert dryer.get_dryness_changeable() == 1
assert dryer.get_manual_dry_time_changeable() == 1
assert dryer.get_temperature_changeable() == 1
assert dryer.get_wrinkle_shield_changeable() == 1

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah! they inform the app if it should allow the user to change those settings trough the app?
if so, lets rename it like you suggest then.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these where not updated.

btw, if I got it right, these tell if the user can change the respective settings on the app?
so, if get_status_wrinkle_shield() == False, then ATTR_WRINKLE_SHIELD is read only?

assert dryer.get_dryness() == Dryness.High
assert dryer.get_manual_dry_time() == 1800
assert dryer.get_cycle_select() == CycleSelect.Timed_Dry
assert dryer.get_airflow_status() == 0
assert dryer.get_cool_down() == 0
assert dryer.get_damp() == 0
assert dryer.get_drying() == 0
assert dryer.get_limited_cycle() == 0
assert dryer.get_sensing() == 0
assert dryer.get_static_reduce() == 0
assert dryer.get_steaming() == 0
assert dryer.get_wet() == 0
assert dryer.get_cycle_count() == 195
assert dryer.get_running_hours() == 148
assert dryer.get_total_hours() == 6302
assert dryer.get_rssi_antenna_diversity() == -51
assert dryer.get_damp_notification_tone_volume() == 0
assert dryer.get_alert_tone_volume() == 0
assert dryer.get_temperature() == Temperature.Cool
assert dryer.get_wrinkle_shield() == WrinkleShield.Off


@pytest.mark.parametrize(
Expand Down
61 changes: 15 additions & 46 deletions tests/test_washer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,30 @@
from aioresponses import aioresponses
from yarl import URL

from whirlpool.aircon import Aircon, FanSpeed, Mode
from whirlpool.appliancesmanager import AppliancesManager
from whirlpool.auth import Auth
from whirlpool.backendselector import BackendSelector
from whirlpool.washer import MachineState


async def test_attributes(appliances_manager: AppliancesManager):
aircon1 = appliances_manager.aircons[0]
washer = appliances_manager.washers[0]

assert aircon1.get_online() is False
assert aircon1.get_power_on() is False
assert aircon1.get_display_on() is False
assert aircon1.get_current_temp() == 23
assert aircon1.get_current_humidity() == 56
assert aircon1.get_temp() == 30
assert aircon1.get_humidity() == 40
assert aircon1.get_mode() == Mode.Heat
assert aircon1.get_sixthsense_mode() is False
assert aircon1.get_fanspeed() == FanSpeed.Off
assert aircon1.get_h_louver_swing() is True
assert aircon1.get_turbo_mode() is False
assert aircon1.get_eco_mode() is False
assert aircon1.get_quiet_mode() is False

aircon2 = appliances_manager.aircons[1]
assert aircon2.get_online() is True
assert aircon2.get_power_on() is True
assert aircon2.get_display_on() is True
assert aircon2.get_current_temp() == 30
assert aircon2.get_current_humidity() == 31
assert aircon2.get_temp() == 29
assert aircon2.get_humidity() == 45
assert aircon2.get_mode() == Mode.Fan
assert aircon2.get_sixthsense_mode() is True
assert aircon2.get_fanspeed() == FanSpeed.Auto
assert aircon2.get_h_louver_swing() is False
assert aircon2.get_turbo_mode() is True
assert aircon2.get_eco_mode() is True
assert aircon2.get_quiet_mode() is True
assert washer.get_machine_state() == MachineState.Standby
assert washer.get_sensing() is False
assert washer.get_filling() is False
assert washer.get_soaking() is False
assert washer.get_washing() is False
assert washer.get_rinsing() is False
assert washer.get_spinning() is False
assert washer.get_dispense_1_level() == 4
assert washer.get_door_open() is True
assert washer.get_time_remaining() == 4080


@pytest.mark.parametrize(
["method", "argument", "expected_json"],
[
(Aircon.set_power_on, True, {"Sys_OpSetPowerOn": "1"}),
(Aircon.set_power_on, False, {"Sys_OpSetPowerOn": "0"}),
(Aircon.set_temp, 30, {"Sys_OpSetTargetTemp": "300"}),
(Aircon.set_humidity, 45, {"Sys_OpSetTargetHumidity": "45"}),
(Aircon.set_mode, Mode.Cool, {"Cavity_OpSetMode": "1"}),
(Aircon.set_fanspeed, FanSpeed.Auto, {"Cavity_OpSetFanSpeed": "1"}),
(Aircon.set_h_louver_swing, True, {"Cavity_OpSetHorzLouverSwing": "1"}),
(Aircon.set_turbo_mode, False, {"Cavity_OpSetTurboMode": "0"}),
(Aircon.set_eco_mode, False, {"Sys_OpSetEcoModeEnabled": "0"}),
(Aircon.set_quiet_mode, False, {"Sys_OpSetQuietModeEnabled": "0"}),
(Aircon.set_display_on, True, {"Sys_DisplaySetBrightness": "4"}),
],
)
async def test_setters(
Expand All @@ -71,11 +40,11 @@ async def test_setters(
argument: Any,
expected_json: dict,
):
aircon = appliances_manager.aircons[0]
washer = appliances_manager.washers[0]
expected_payload = {
"json": {
"body": expected_json,
"header": {"said": aircon.said, "command": "setAttributes"},
"header": {"said": washer.said, "command": "setAttributes"},
}
}

Expand All @@ -92,7 +61,7 @@ async def test_setters(

# add call, call method
aioresponses_mock.post(url, payload=expected_payload)
await method(aircon, argument)
await method(washer, argument)

# assert args and length
aioresponses_mock.assert_called_with(**post_request_call_kwargs)
Expand Down
Loading
Loading