Hi everyone,
I am trying to preserve the battery of my new robot. It should move away from the charger when the charge has reached 80% and return to the charger when the battery drops below 30%.
The topic: valetudo/rockrobo/state
returns: {"state":"idle","battery_level":93,"fan_speed":"mop"}
I subscribed to this topic on mqtt dash.
The topic: valetudo/rockrobo/custom_command
{
"command": "go_to",
"spot_id": "Somewhere"
}
Sends the device to the specified pre-saved spot location
The topic: valetudo/robot/command
payload: return_to_base
Makes the device returning to charging station.
I set up the script like this. on receive:
if (event.payload < 31) {
app.publish('valetudo/robot/custom_command',{"command": "go_to",
"spot_id": "No charging"}, false, 0);
} else if (event.payload > 80) {
app.publish('valetudo/robot/command', 'return_to_base', false, 0);
} else {
app.publish('messages/alert', 'NORMAL', false, 0);
}
The else could maybe completely left out?
The script does not seem to work. The payload returns more than the number as I showed above. Maybe that is the problem here? I am very new to this kind of scripting so any help would be appreciated.