openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.58k forks source link

[miio] Incorrect `cleaning#last_clean_start_time` and `cleaning#last_clean_end_time` after upgrading to v4.2.1 #17321

Open Markkuuss opened 3 weeks ago

Markkuuss commented 3 weeks ago

Expected Behavior

The cleaning#last_clean_start_time and cleaning#last_clean_end_time should display the correct timestamps of the last cleaning operation.

Current Behavior

After upgrading from openHAB v4.1.3 to v4.2.1, the times cleaning#last_clean_start_time and cleaning#last_clean_end_time both display 01.01.70 01:33:44, which is incorrect.

In the cleaning#last_clean_record, the following data is observed:

{
  "start": "2024",
  "begin": null,
  "end": "2024",
  "duration": 0,
  "area": 0.77,
  "clean_time": null,
  "error": 0,
  "finished": 0,
  "complete": null,
  "start_type": 2,
  "clean_type": 3,
  "finish_reason": 60,
  "dust_collection_status": null,
  "map_flag": null
}

It appears that the Unix timestamps from the XiaomiRobotVacuumProtocol (as seen in the debug log below) are not being parsed correctly. Instead of being fully interpreted, only the year is extracted, which is then incorrectly treated as a timestamp. This results in the channels not displaying the correct datetime.

The associated debug log shows:

Received response for device 0F989D8D type: CLEAN_RECORD_GET, result: [[1724174413,1724174459,46,770000,0,0,2,3,60]], fullresponse: {"result":[[1724174413,1724174459,46,770000,0,0,2,3,60]],"id":7028}

Possible Solution

It seems the issue might be related to the way the start and end fields are parsed as timestamps. In the debug log, the CLEAN_RECORD_GET response contains two Unix timestamps, 1724174413 and 1724174459, which should be correctly parsed. These correspond to the dates:

Adjusting the parsing logic to correctly handle these values should resolve the issue.

Steps to Reproduce (for Bugs)

  1. Upgrade openHAB from v4.1.3 to v4.2.1.
  2. Start and complete a cleaning operation with the Roborock S5 Max.
  3. Check the cleaning#last_clean_start_time and cleaning#last_clean_end_time after the cleaning operation.

Your Environment

openhab-bot commented 3 weeks ago

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/miio-binding-roborock-s4max-no-longer-getting-last-cleaning-details/153260/21