Update Whirlpool to 0.20.0 (#142119)

This commit is contained in:
Abílio Costa 2025-04-03 15:35:37 +01:00 committed by GitHub
parent cf005feace
commit b2af1084f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 19 additions and 48 deletions

View File

@ -7,5 +7,5 @@
"integration_type": "hub",
"iot_class": "cloud_push",
"loggers": ["whirlpool"],
"requirements": ["whirlpool-sixth-sense==0.19.1"]
"requirements": ["whirlpool-sixth-sense==0.20.0"]
}

View File

@ -25,12 +25,12 @@ from .entity import WhirlpoolEntity
SCAN_INTERVAL = timedelta(minutes=5)
WASHER_TANK_FILL = {
"0": "unknown",
"1": "empty",
"2": "25",
"3": "50",
"4": "100",
"5": "active",
0: "unknown",
1: "empty",
2: "25",
3: "50",
4: "100",
5: "active",
}
WASHER_DRYER_MACHINE_STATE = {
@ -70,7 +70,7 @@ STATE_DOOR_OPEN = "door_open"
def washer_dryer_state(washer_dryer: WasherDryer) -> str | None:
"""Determine correct states for a washer/dryer."""
if washer_dryer.get_attribute("Cavity_OpStatusDoorOpen") == "1":
if washer_dryer.get_door_open():
return STATE_DOOR_OPEN
machine_state = washer_dryer.get_machine_state()
@ -110,9 +110,7 @@ WASHER_SENSORS: tuple[WhirlpoolSensorEntityDescription, ...] = (
entity_registry_enabled_default=False,
device_class=SensorDeviceClass.ENUM,
options=list(WASHER_TANK_FILL.values()),
value_fn=lambda washer: WASHER_TANK_FILL.get(
washer.get_attribute("WashCavity_OpStatusBulkDispense1Level")
),
value_fn=lambda washer: WASHER_TANK_FILL.get(washer.get_dispense_1_level()),
),
)
@ -224,9 +222,7 @@ class WasherDryerTimeSensor(WhirlpoolEntity, RestoreSensor):
if machine_state is MachineState.RunningMainCycle:
self._running = True
new_timestamp = now + timedelta(
seconds=int(self._wd.get_attribute("Cavity_TimeStatusEstTimeRemaining"))
)
new_timestamp = now + timedelta(seconds=self._wd.get_time_remaining())
if self._value is None or (
isinstance(self._value, datetime)

2
requirements_all.txt generated
View File

@ -3067,7 +3067,7 @@ webmin-xmlrpc==0.0.2
weheat==2025.2.26
# homeassistant.components.whirlpool
whirlpool-sixth-sense==0.19.1
whirlpool-sixth-sense==0.20.0
# homeassistant.components.whois
whois==0.9.27

View File

@ -2469,7 +2469,7 @@ webmin-xmlrpc==0.0.2
weheat==2025.2.26
# homeassistant.components.whirlpool
whirlpool-sixth-sense==0.19.1
whirlpool-sixth-sense==0.20.0
# homeassistant.components.whois
whois==0.9.27

View File

@ -141,18 +141,6 @@ def fixture_mock_aircon_api_instances(mock_aircon1_api, mock_aircon2_api):
yield mock_aircon_api
def side_effect_function(*args, **kwargs):
"""Return correct value for attribute."""
if args[0] == "Cavity_TimeStatusEstTimeRemaining":
return 3540
if args[0] == "Cavity_OpStatusDoorOpen":
return "0"
if args[0] == "WashCavity_OpStatusBulkDispense1Level":
return "3"
return None
def get_sensor_mock(said: str, data_model: str):
"""Get a mock of a sensor."""
mock_sensor = mock.Mock(said=said)
@ -165,7 +153,9 @@ def get_sensor_mock(said: str, data_model: str):
mock_sensor.get_machine_state.return_value = (
whirlpool.washerdryer.MachineState.Standby
)
mock_sensor.get_attribute.side_effect = side_effect_function
mock_sensor.get_door_open.return_value = False
mock_sensor.get_dispense_1_level.return_value = 3
mock_sensor.get_time_remaining.return_value = 3540
mock_sensor.get_cycle_status_filling.return_value = False
mock_sensor.get_cycle_status_rinsing.return_value = False
mock_sensor.get_cycle_status_sensing.return_value = False

View File

@ -30,20 +30,6 @@ async def update_sensor_state(
return hass.states.get(entity_id)
def side_effect_function_open_door(*args, **kwargs):
"""Return correct value for attribute."""
if args[0] == "Cavity_TimeStatusEstTimeRemaining":
return 3540
if args[0] == "Cavity_OpStatusDoorOpen":
return "1"
if args[0] == "WashCavity_OpStatusBulkDispense1Level":
return "3"
return None
async def test_dryer_sensor_values(
hass: HomeAssistant, mock_sensor2_api: MagicMock, entity_registry: er.EntityRegistry
) -> None:
@ -258,7 +244,7 @@ async def test_washer_sensor_values(
mock_instance.get_machine_state.return_value = MachineState.Complete
mock_instance.attr_value_to_bool.side_effect = None
mock_instance.get_attribute.side_effect = side_effect_function_open_door
mock_instance.get_door_open.return_value = True
state = await update_sensor_state(hass, entity_id, mock_instance)
assert state is not None
assert state.state == "door_open"
@ -338,8 +324,7 @@ async def test_callback(hass: HomeAssistant, mock_sensor1_api: MagicMock) -> Non
state = hass.states.get(f"sensor.washerdryer_{MOCK_SAID3}_end_time")
assert state.state == thetimestamp.isoformat()
mock_sensor1_api.get_machine_state.return_value = MachineState.RunningMainCycle
mock_sensor1_api.get_attribute.side_effect = None
mock_sensor1_api.get_attribute.return_value = "60"
mock_sensor1_api.get_time_remaining.return_value = 60
callback()
# Test new timestamp when machine starts a cycle.
@ -348,13 +333,13 @@ async def test_callback(hass: HomeAssistant, mock_sensor1_api: MagicMock) -> Non
assert state.state != thetimestamp.isoformat()
# Test no timestamp change for < 60 seconds time change.
mock_sensor1_api.get_attribute.return_value = "65"
mock_sensor1_api.get_time_remaining.return_value = 65
callback()
state = hass.states.get(f"sensor.washerdryer_{MOCK_SAID3}_end_time")
assert state.state == time
# Test timestamp change for > 60 seconds.
mock_sensor1_api.get_attribute.return_value = "125"
mock_sensor1_api.get_time_remaining.return_value = 125
callback()
state = hass.states.get(f"sensor.washerdryer_{MOCK_SAID3}_end_time")
newtime = utc_from_timestamp(as_timestamp(time) + 65)