Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set charging limits to preserve battery life. #393

Closed
beatstick opened this issue Feb 21, 2021 · 12 comments
Closed

Set charging limits to preserve battery life. #393

beatstick opened this issue Feb 21, 2021 · 12 comments
Labels
impossible this can't be fixed or implemented

Comments

@beatstick
Copy link

Hi,
would it be possible to set charging limits to preserve the life of the battery?

I know there must be a setting already somewhere, as the bot returns to charge, when the battery hits 20%.

I'd like mine to return at 30%.
Also as it will always be plugged into the charger, I'd like to charge up to 85%, then stop charging until the battery has dropped to 40% and than resume charging.
That way the batteries will last a couple of years longer, or so I heard.
Maybe we could set this somewhere on ubuntu. A gui would be nice to have but it's not strictly neccessary as it would be good enough to set this up once vie ssh I think.

@rand256
Copy link
Owner

rand256 commented Feb 21, 2021

Feel free to patch low level firmware and provide your findings to vacuumz image builder.
I'd like to have these changes too, but it's most likely impossible from valetudo's side.

@beatstick
Copy link
Author

Ah I see. It was possible to implement this on my laptop rather easily via apt package, but I just read it's only working on thinkpads.
I'll have a look at it as soon as my roborock arrives but I fear low level firmware patches are way beyond my expertise.

@keiner99
Copy link

If you use Home Assistant or something else, you could use a smart Plug and write a Script to Turn Off electricity If the Vacuum cleaner reaches 85% of battery :)

@LEJOUI
Copy link

LEJOUI commented Feb 24, 2021

If you use Home Assistant or something else, you could use a smart Plug and write a Script to Turn Off electricity If the Vacuum cleaner reaches 85% of battery :)

This could be helpfull. Did you already made a script and care to share?

@pidator
Copy link
Contributor

pidator commented Feb 24, 2021

write a Script to Turn Off electricity If the Vacuum cleaner reaches 85% of battery :)

I'm not 100% sure, but I think the linux system will shut down if it isn't connected to a power source for a while. It could be possible that you'll have to start the robot manually then. So then there's also no resuming when reaching 40% of capacity...

@dkisselev
Copy link
Contributor

In my experience, the S5 tends to turn off and doesn't turn back on if it's off the charger for more than ~48 hours. I suspect that the battery gets drained while idle so cycling the charger on and off could cause the battery to wear out faster.

@beatstick
Copy link
Author

beatstick commented Feb 26, 2021

If you use Home Assistant or something else, you could use a smart Plug and write a Script to Turn Off electricity If the Vacuum cleaner reaches 85% of battery :)

I think the robo speaks mqtt. I could set up a server on my openwrt router I guess. Maybe the server can tell the robot to move an inch away from the charger after it has charged up to 80%. I would turn off the charger at night when I go to bed and back on, whenever I power on my desktop pc. The bot uses around 30% of battery to clean my flat it seems. So it would charge from around 50% to 80%. That seems fairly reasonable.

Another way might be even better: Use the don't return to dock after cleaning option from the webui. Just have it move to a spot close to the dock. Then send it to the charger, once it reaches 40% battery. Send it away at 85%. I've never used mqtt but that should be doable, right?
The bot seems to use /opt/rockrobo/firmware/uart_test for commands if I understand correctly. Could these be called from outside, or would the mqtt server be logged in via ssh to control the bot?

The charging unit could then be powered by a "smart" switch, one of those old school ones you set via rotary to switch on during certain times of the day/week. A real smart switch just consumes to much power imho, I've got one from china that consumes around 1w on idle, it's probably the wifi (and operating system openwrt) that consumes power.

Edit: I think it should work with the miIO Device Library (https://github.com/aholstenson/miio).
We should be able to get the battery percentage and start and action that way. Maybe the middle man (mqtt) can be cut out that way. Just have a script running in the background that moves the robot to another spot/back to the dock when battery reached a certain percentage. There should be a way to run a cronjob on the bot itself to issue a move to spot comand or am I mad?

@keiner99
Copy link

keiner99 commented Mar 2, 2021

If you use Home Assistant or something else, you could use a smart Plug and write a Script to Turn Off electricity If the Vacuum cleaner reaches 85% of battery :)

This could be helpfull. Did you already made a script and care to share?

I created a mqtt sensor in the configuration.yaml in homeassistant for the vacuum to get the battery percentage:

`sensor:

  • platform: mqtt
    name: "Battery vacuum"
    state_topic: "valetudo/rockrobo/state"
    unit_of_measurement: '%'
    value_template: "{{ value_json.battery_level }}"`

and then I created a node red automation with an timestamp:

image

you could change the state of the battery_status to 85 and you are good to go ;)

@keiner99
Copy link

keiner99 commented Mar 2, 2021

write a Script to Turn Off electricity If the Vacuum cleaner reaches 85% of battery :)

I'm not 100% sure, but I think the linux system will shut down if it isn't connected to a power source for a while. It could be possible that you'll have to start the robot manually then. So then there's also no resuming when reaching 40% of capacity...

I use an Xiaomi Vacuum Gen1. mine charges the battery to 100%, then the vacuum dock electricity will turn off and vacuum goes to standby. next time I start it, i have to turn on the vacuum dock electricity, then the vacuum starts automatically. after one week the vacuum has an battery life about 75% because it is in stanby, when the dock is turned off.

@beatstick
Copy link
Author

beatstick commented Mar 2, 2021

If you use Home Assistant or something else, you could use a smart Plug and write a Script to Turn Off electricity If the Vacuum cleaner reaches 85% of battery :)

This could be helpfull. Did you already made a script and care to share?

I created a mqtt sensor in the configuration.yaml in homeassistant for the vacuum to get the battery percentage:

`sensor:

* platform: mqtt
  name: "Battery vacuum"
  state_topic: "valetudo/rockrobo/state"
  unit_of_measurement: '%'
  value_template: "{{ value_json.battery_level }}"`

and then I created a node red automation with an timestamp:

image

you could change the state of the battery_status to 85 and you are good to go ;)

Cool, cheers for the help!
I decided to install the mosquitto broker on an openwrt access point, but Homeassistant is a bit too heavy on resources for an AP. So I am using an android app called mqtt dash on my old phone at the moment. Here is how it works for me:
The robot should move away from the charger when the charge has reached 80% and return to the charger when the battery drops below 30%.

-> connect to your robot via webapp -> zones -> goto locations -> choose a spot a few inches away from the charger, call it: No charging

-> connect roborock & mqtt dash to the broker -> On dash subscribe to the topic: valetudo/rockrobo/state -> on receive enter the following code:

var data = JSON.parse(event.payload); if ((data.battery_level > 80) && (data.state == "docked")) { app.publish('valetudo/robot/custom_command',JSON.stringify({"command": "go_to", "spot_id": "No charging"}), false, 2); } else if ((data.battery_level < 31) && (data.state == "idle") || (data.battery_level < 31) && (data.state == "cleaning")) { app.publish('valetudo/robot/command', 'return_to_base', false, 2); } else { app.publish('valetudo/robot/mate', 'all_systems_nominal', false, 0); }

I edited the code above. It should now work as expexted. (I added conditions so the robo does not try to move to the charger when it's already docked. Maybe I'll connect an intelligent plug to the charger at some point, but I think I can turn the charger off and on by hand for now.

@keiner99
Copy link

keiner99 commented Mar 2, 2021

@beatstick Nice! :) but I would turn off the charger if possible, mine needs 12w of electricity also when the vacuum is not docked..

@beatstick
Copy link
Author

beatstick commented Mar 2, 2021

Oh, interesting. I just measured mine. It only seems to consume 0.3 Watts, (that's less than my intelligent plug which takes around 1w). So it should be all right if I forget to turn it off after cleaning and switch it off in the evening. Maybe you should measure yours again. 12w on idle seems very steep.

@rand256 rand256 added the impossible this can't be fixed or implemented label Apr 10, 2021
@rand256 rand256 closed this as completed Apr 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impossible this can't be fixed or implemented
Projects
None yet
Development

No branches or pull requests

6 participants