rand256 / valetudo

Valetudo RE - experimental vacuum software, cloud free
Apache License 2.0
665 stars 73 forks source link

Feature Request: Provide Bin Out Timestamp via MQTT/UI #304

Closed robotastic-io closed 3 years ago

robotastic-io commented 3 years ago

Idea

Having the timestamp for bin out would allow advanced bin empty features. e.g:

Possible Solutions:

a) You could monitor the sysout of 'lsof | grep /mnt/data/rockrobo/sounds/bin_in.wav' or bin_out.wav and store the time of access into a variable which gets reported via mqtt and/or accessed via webui.

b) Alternatively in /mnt/data/rockrobo/RoboController.cfg a variable 'bin_in_time' is stored. The variable represents the clean time since the last bin empty in seconds.

With this value and cleaning history we can estimate the time the bin was last removed.

Pseudo Code:

let binInTime = readValueFromRoboControllerConf('bin_in_time');
let historyArray = getCleaningHistory;
let record;

// No History
if(historyArray.length == 0){
    return -1;
}

// Iterate Cleaning History
while(binInTime > 0 && historyArray.length > 0){
    record = historyArray.shift();
    binInTime -= record.duration;
}

// Bin was emptied between runs
if(binInTime == 0){
    record = historyArray.shift();
    return record.endTime;
}

// Bin was emptied during run
if(binInTime < 0 && record){
    return record.startTime - binInTime;
}
else{ // Fallback
    record = historyArray.shift();
    return record.endTime;
}    
pidator commented 3 years ago

Perhaps this repo could help with your idea?

robotastic-io commented 3 years ago

Thanks for the suggestion. It follows a different assumption though. The repo assumes that the bin is full after x minutes of cleaning. It does not give the exact timestamp of bin out. This should work fine as an approximation if you run the robot on a daily shedule.

If however you dont run it on a daily shedule the assumption does not work. The amount of dirt inside the bin correlates with the amount of dirt the robot can pick up from the space it cleans not the cleaning time. Or mathematically speaking:

averageAmountOfDirtGeneratedBySpacePerHour * timeSinceLastBinEmpty = amountOfDirtInBinAfterRun.

Installing a second mqtt client also seems like a little overkill.