rand256 / valetudo

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

[Feature Request] Add cleaning history visible via mqtt #200

Open jokerigno opened 4 years ago

jokerigno commented 4 years ago

Hi,

I love Valetudo Re. I use it to clean my house and me, my wife and my daugher are very happy with it.

I use it often via voice using Home Assistant as middle man so I was wondering if there's a way to send cleaning history to mqtt so HA can "see" if a zone has been cleaned today (started by my wife for example) avoid a second clean.

Thank you!

rand256 commented 4 years ago

How exactly do you suggest to implement this? There's no issues with sending cleaning history stats, but they doesn't include names of the zones that were cleaned. And I suppose it shouldn't send binary mapdata to overwrite the current map state.

pidator commented 4 years ago

so HA can "see" if a zone has been cleaned today ...

Shouldn't this functionality be implemented in your HA system to know if a specific cleaning run was already submitted this day (via HA)? Or is the robot controlled by valetudo gui also and not by HA system only?

jokerigno commented 4 years ago

How exactly do you suggest to implement this?

Well, this is my attributes on mqtt:

{"cleanTime":"174.2","cleanArea":"5520.0","cleanCount":408,"last_run_stats":{"startTime":1586161138000,"endTime":1586163481000,"duration":2343,"area":"11.3","errorCode":0,"errorDescription":"No error","finishedFlag":true},"currentCleanTime":"39.0","currentCleanArea":"11.3","mainBrush":"125.0","sideBrush":"25.0","filter":"104.4","sensor":"0.0","state":"docked","valetudo_state":{"id":8,"name":"Charging"}}

maybee adding a voice inside "last_run_stats" with a id that is the last zone cleaned (if name is not possible)?

It would be great also to have same solution (id or name) inside "valetudo_state".

Let me know your thoughts.

jokerigno commented 4 years ago

so HA can "see" if a zone has been cleaned today ...

Shouldn't this functionality be implemented in your HA system to know if a specific cleaning run was already submitted this day (via HA)? Or is the robot controlled by valetudo gui also and not by HA system only?

I usually control it by web interface. But my wife use voice instead (manage trought HA).

rand256 commented 4 years ago

maybee adding a voice inside "last_run_stats" with a id that is the last zone cleaned (if name is not possible)?

What is "a voice" and which id did you mention? The data for "last_run_stats" is taken directly from the device's firmware, and firmware doesn't know anything about zone names or ids, even neither it saves the coordinates for the zones it was cleaning. It has only the data you see in "last_run_stats", and also it is possible to get the map snapshot with the path it went during the cleaning. However it is not clear how to put that map into mqtt: before there was an issue where cleaning history map was sent via mqtt instead of a current map when one was browsing cleaning history in web interface, but that was fixed in 0.9.2.

jokerigno commented 4 years ago

maybee adding a voice inside "last_run_stats" with a id that is the last zone cleaned (if name is not possible)?

What is "a voice" and which id did you mention? The data for "last_run_stats" is taken directly from the device's firmware, and firmware doesn't know anything about zone names or ids, even neither it saves the coordinates for the zones it was cleaning. It has only the data you see in "last_run_stats", and also it is possible to get the map snapshot with the path it went during the cleaning. However it is not clear how to put that map into mqtt: before there was an issue where cleaning history map was sent via mqtt instead of a current map when one was browsing cleaning history in web interface, but that was fixed in 0.9.2.

I was suggestion to create an ID similar to the one that returns vacuum status. OK that fw doesn't know of zones but valetudo re does, right? In Cleaning history I can see many info except zone name. So also this info come from fw against valetudo?

rand256 commented 4 years ago

I was suggestion to create an ID similar to the one that returns vacuum status. OK that fw doesn't know of zones but valetudo re does, right? In Cleaning history I can see many info except zone name. So also this info come from fw against valetudo?

Sorry, it is a bit difficult to read your posts.

It is important to understand that in most cases valetudo is only a GUI for default device's firmware. The only thing it currently writes to the disk is it's own settings, no more than that! All the cleaning history is stored by the firmware itself, not by valetudo, and the only data it stores can be seen at Settings->Cleaning History. While it is definitely possible make valetudo write our own additional cleaning history and mess with synchronizing it with the native one, I'm really not sure whether it is worth the efforts needed.

Regarding the initial question, it is still not clear for me what to publish via mqtt. The only way I could imagine is to make a separate mqtt topic to publish (by request) a list of last 20 cleanings there, and make valetudo listen for another mqtt requests with the id of exact cleaning from that list. Upon receiving that id, valetudo should publish a binary map snapshot of the requested cleaning to a new separate mqtt topic dedicated to cleaning history. Then we need to edit valetudo-mapper so it would listen to that topic, so it could either parse the binary map into JSON or make a PNG picture of that map, or something alike. It probably can be done, but I'm not using any HA-like software and don't know if the scheme I've described above makes any sense for the practical use.

jokerigno commented 4 years ago

Sorry for the late reply. Now I understand better what valetudo is. And understand also the effort to implement solution to a new mqtt topic with cleaning history. In my case is not necessary have complete map snapshot of latest cleaning but just the room names or zone ID will be great. So I could implement a variable in HA that store last 3 state of that sensor (as I do with movement using this solution = https://diyfuturism.com/index.php/2017/12/15/useful-sensor-motion-last-seen-________/)

What's your opining? it's worth it?

rand256 commented 4 years ago

This link doesn't work for me, it says ERR_CONNECTION_REFUSED. Probably they banned my country from visiting the site.

jokerigno commented 4 years ago

Here's the pastebin with yaml code.

https://pastebin.com/bCRPTtHY

jokerigno commented 2 years ago

Hi, any update on this?