abmantis / whirlpool-sixth-sense

Whirlpool unofficial API for 6th Sense appliances
MIT License
13 stars 12 forks source link

Feature request: wet laundry status #46

Closed austinmroczek closed 3 months ago

austinmroczek commented 11 months ago

Thanks for building this library. I have a feature request. I could code it and submit a PR with a little guidance.

My request is for a Washer "wet laundry" sensor in Home Assistant. This is when the washer cycle is complete, but the washer door has not been opened. This can tell or remind me that someone needs to move the wet clothes into the dryer.

I assume I'd create a function WasherDryer.is_laundry_wet() that returns a boolean.

Should I add a self._last_status and set it in get_machine_state, and then

def is_laundry_wet():
    return (self._last_status == MachineState.Complete and self._door_status == Closed)

Or do you have a better suggestion ?

abmantis commented 11 months ago

Hi,

The purpose of the library is to simply expose what the Whirlpool API provides, but not do much extra logic over it. So I would suggest simply adding the support for door status since I don't think we have that already. Are you sure the API provides that info? Then, on HA side you can just define a template binary sensor that combines the machine state with the door state.

NodeJSmith commented 5 months ago

FYI, I don't think this is possible anyway. It looks like only two statuses regarding the door are Cavity_OpStatusDoorLocked and Cavity_OpStatusDoorOpen. I'm not sure how the HA integration works, but I'm guessing it polls on a regular interval, meaning that if the door was opened and then closed between polls we wouldn't capture the status.

Depending on how long between polls it may not be likely for that to happen, but I don't know if we would want to implement something that could be flaky.

abmantis commented 5 months ago

@NodeJSmith the HA integration gets updates from the integration (the event socket handles that on the lib side), it does not poll IIRC. So yeah, it should be doable on HA, but I don't think it should be part of the integration since there is no "wet" info from the machine, and the user can do it with a binary sensor helper.

mkmer commented 3 months ago

Following the API "conventions", this type of logic should be done on the HA (or other client) side, not in the integration. The API should only present the I/O of the machine, and the logic controller (HA or other) does the rest ;)