Archive for March, 2018

This is my first python program ever, so bare with me if it’s not perfect.
This allows you to execute commands to mirobo so you can interact with the Xiaomi vacuum robot.

I use this small program to start/stop the robot, get status from it, etc from my (old) wall mounted tablet that runs Imperihome.

Here is the code:

# app.py file:

from flask import Flask, request
import subprocess
import logging

app = Flask (__name__)

log = logging.getLogger(‘werkzeug’)

def status():
command = “status”
return executeMiroboCommand(command)

def consumables():
command = “consumables”
return executeMiroboCommand(command)

def start():
command = “start”
return executeMiroboCommand(command)

def stop():
command = “stop”
return executeMiroboCommand(command)

def spot():
command = “spot”
return executeMiroboCommand(command)

def find():
command = “find”
return executeMiroboCommand(command)

def home():
command = “home”
return executeMiroboCommand(command)

# 38 quiet, 60 balanced , 77 turbo , 90 max. Different value than app may cause app button to stop working
def fanspeed(speed):
command = “fanspeed %s” % speed
return executeMiroboCommand(command)

def cleaning_history():
command = “cleaning_history”
return executeMiroboCommand(command)

# todo dnd, volume?


def executeMiroboCommand(command):
result_success = subprocess.check_output(“mirobo ” + command, shell=True)

except subprocess.CalledProcessError as e:
return “An error occurred”
#Read more at https://www.pluralsight.com/guides/python/running-shell-commands-with-flask#iaQlrC0rPigBRpcK.99

decodedResult = result_success.decode().replace(‘\n’, ‘<br>’)
return decodedResult
if __name__ == ‘__main__’:
app.run(debug=True, host=’′)


How to use
Start it by running python3 app.py

then connect to it by using the different commands like
http://<ip adress>:5000/mirobo/<command name>

<command name> could be any in the last part routes above, for instance status.

For example:



Read Full Post »

Well, I finally got it working! Do as follows to install Swedish language on you Xiaomi Vaccum Robot v1 (does not work on v2).

  • Get hold of the secret key for communicating with the robot, this can be obtained by installing an old version of the Xiaomi app (newer ones has fixed this obvious bug) on you Android phone and then run the program MiToolKit¬†on a pc to extract the database from the app.
    After that you need a browser for SQLite and open the miio2.db database file. Look for the column token, which holds the secret key in the devicerecord table. You can also see the ip adress of the robot in this table, which you need later.
  • Download dustclouds package and install that on a Linux enviroment (instructions can be found on the supplied link). By using the token and the ip of the robot you now can control is using the mirobo commands.
  • Go into the folder sound_generator/languages and copy one of the existing files which contains the texts that generator will use. Open you’re copied file and translate the texts to Swedish.
  • Run the sound_generator in python by using the command ‘py sound_generator.py’, select the language for Swedish and the selected tts engine.
  • Go into the newly created folder for the laguage, and run the command “md5sum sv.pkg”, this will give you the md5 the mirobo uses to install the sound.
  • Run the mirobo install_sound, with the created sv.pkg and the md5 value you got from the md5sum command. The sid can be any number >0, for instance 666. I have troubles running the command as a self containing server, so I had to put the sv.pkg up on a webserver and run the install against that server.

Read Full Post »

var myString = Regex.Replace(myString, @"\s+", " ");

Read Full Post »