Tasshack / dreame-vacuum

Home Assistant integration for Dreame robot vacuums with map support
https://community.home-assistant.io/t/custom-component-dreame-vacuum
MIT License
887 stars 110 forks source link

delay off for state docked #748

Closed latel closed 1 month ago

latel commented 1 month ago

Is your feature request related to a problem? Please describe. Dreame vacuum have many states, for example 零食柜, docked and returning to base. when vacuum need to go back to base to wash, the state flow is: returning->docked->washing, obviously state docked is not correct, and docked state persist only about 1 seconds.

Describe the solution you'd like It's better docked state is ommited, the better state flow is: returning->washing. similar to binary_sensor's delay_off feature.

Describe alternatives you've considered noop

Additional context noop

Tasshack commented 1 month ago

I needs logs to understand the issue you are describing.

Tasshack commented 1 month ago

Default HA vacuum entity does not have enough or correct states for handling Dreame vacuum states. Integration converts Dreame vacuum states to HA vacuum states.

STATE_CODE_TO_STATE: Final = {
    DreameVacuumState.UNKNOWN: STATE_UNKNOWN,
    DreameVacuumState.SWEEPING: STATE_CLEANING,
    DreameVacuumState.IDLE: STATE_IDLE,
    DreameVacuumState.PAUSED: STATE_PAUSED,
    DreameVacuumState.ERROR: STATE_ERROR,
    DreameVacuumState.RETURNING: STATE_RETURNING,
    DreameVacuumState.CHARGING: **STATE_DOCKED**,
    DreameVacuumState.MOPPING: STATE_CLEANING,
    DreameVacuumState.DRYING: **STATE_DOCKED**,
    DreameVacuumState.WASHING: STATE_CLEANING,
    DreameVacuumState.RETURNING_TO_WASH: STATE_RETURNING,
    DreameVacuumState.BUILDING: **STATE_DOCKED**,
    DreameVacuumState.SWEEPING_AND_MOPPING: STATE_CLEANING,
    DreameVacuumState.CHARGING_COMPLETED: **STATE_DOCKED**,
    DreameVacuumState.UPGRADING: STATE_IDLE,
    DreameVacuumState.CLEAN_SUMMON: STATE_CLEANING,
    DreameVacuumState.STATION_RESET: STATE_IDLE,
    DreameVacuumState.RETURNING_INSTALL_MOP: STATE_RETURNING,
    DreameVacuumState.RETURNING_REMOVE_MOP: STATE_RETURNING,
    DreameVacuumState.WATER_CHECK: **STATE_DOCKED**,
    DreameVacuumState.CLEAN_ADD_WATER: STATE_CLEANING,
    DreameVacuumState.WASHING_PAUSED: STATE_PAUSED,
    DreameVacuumState.AUTO_EMPTYING: **STATE_DOCKED**,
    DreameVacuumState.REMOTE_CONTROL: STATE_CLEANING,
    DreameVacuumState.SMART_CHARGING: **STATE_DOCKED**,
    DreameVacuumState.SECOND_CLEANING: STATE_CLEANING,
    DreameVacuumState.HUMAN_FOLLOWING: STATE_CLEANING,
    DreameVacuumState.SPOT_CLEANING: STATE_CLEANING,
    DreameVacuumState.RETURNING_AUTO_EMPTY: STATE_RETURNING,
    DreameVacuumState.SHORTCUT: STATE_CLEANING,
    DreameVacuumState.WAITING_FOR_TASK: STATE_IDLE,
    DreameVacuumState.STATION_CLEANING: STATE_CLEANING,
    DreameVacuumState.RETURNING_TO_DRAIN: STATE_RETURNING,
    DreameVacuumState.DRAINING: STATE_CLEANING,
    DreameVacuumState.AUTO_WATER_DRAINING: STATE_CLEANING,
    DreameVacuumState.SHORTCUT: STATE_CLEANING,
    DreameVacuumState.MONITORING: STATE_CLEANING,
    DreameVacuumState.MONITORING_PAUSED: STATE_PAUSED,
}

So one of the vacuum states must be wrong that also causes vacuum state to be reported as docked so I need to know exact Dreame vacuum state at that time to fix this issue.

latel commented 1 month ago

I record the original state and mapped state.

original state: sweeping_and_mopping->returning_to_wash->charging->washing->clean_add_water->washing->clean_add_water->washing->sweeping_and_mopping

[
{
            "state": "sweeping_and_mopping",
            "last_changed": "2024-10-09T03:17:33.295555+00:00"
        },
        {
            "state": "returning_to_wash",
            "last_changed": "2024-10-09T03:31:56.350043+00:00"
        },
        {
            "state": "charging",
            "last_changed": "2024-10-09T03:32:36.355196+00:00"
        },
        {
            "state": "washing",
            "last_changed": "2024-10-09T03:32:39.368078+00:00"
        },
        {
            "state": "clean_add_water",
            "last_changed": "2024-10-09T03:32:49.370617+00:00"
        },
        {
            "state": "washing",
            "last_changed": "2024-10-09T03:33:07.367798+00:00"
        },
        {
            "state": "clean_add_water",
            "last_changed": "2024-10-09T03:33:16.371480+00:00"
        },
        {
            "state": "washing",
            "last_changed": "2024-10-09T03:33:52.373127+00:00"
        },
        {
            "state": "sweeping_and_mopping",
            "last_changed": "2024-10-09T03:35:57.390605+00:00"
        }
]

mapped state: cleaning->returning->docked->cleaning

{
            "state": "cleaning",
            "last_changed": "2024-10-09T03:14:14.353003+00:00"
        },
        {
            "state": "returning",
            "last_changed": "2024-10-09T03:31:56.351075+00:00"
        },
        {
            "state": "docked",
            "last_changed": "2024-10-09T03:32:36.356429+00:00"
        },
        {
            "state": "cleaning",
            "last_changed": "2024-10-09T03:32:39.369074+00:00"
        }

it seems when vacuum going back to base to wash, it has temporary charging state, which is mapped to docked state.

Tasshack commented 1 month ago

There is nothing wrong with these states. Vacuum state should return docked when the device is charging.