FHEM - Hausautomations-Systeme > Sonstige Systeme

Xiaomi WiFi Devices Modul (Vacuum/Airpurifier/Fan) - 72_XiaomiDevice (Support)

(1/478) > >>

Markus M.:
Aktuelle Version im Update

Das Ermitteln des Staubsauger/Lampen Tokens ist bei den aktuellen Firmwares (ab FW 3074) nur noch über das Auslesen aus einem App Backup möglich.
Token mit 32 Zeichen (unverschlüsselt) oder 96 Zeichen (verschlüsselt, manuelle Enschlüsselung siehe 3. Post) können verwendet werden.

Dieses Modul unterstützt aktuell folgende Devices:
- Xiaomi Smart Vacuum Cleaner / V2 / S5
- Mi Air Purifier 2 / 3H
- Mi Smart Fan / 1X / 1C / P9
- Mi UV Humidifier / MSSQ / Evaporation
- Xiaomi LED (Desk) Lamp / Eyecare
- Rice Cooker
- Water Purifier
- Power Plug

Benötigte Perl Module:
- JSON  libjson-perl
- Digest::MD5  libdigest-md5-perl
- Crypt::CBC  libcrypt-cbc-perl
- Crypt::Cipher::AES oder Crypt::Rijndael_PP CPAN
- Crypt::ECB  libcrypt-ecb-perl (bei verschlüsseltem Token)

define NAME XiaomiDevice IP [TOKEN]

--- Code: (vacuum) ---define vacuum XiaomiDevice 12345678901234567890123456789012
attr vacuum subType VacuumCleaner

--- Ende Code ---

--- Code: (airpurifier) ---define airpurifier XiaomiDevice 12345678901234567890123456789012
attr airpurifier subType AirPurifier
--- Ende Code ---

Es muss für alle neuen Geräte der Token ermittelt werden.
Der Air Purifier kann aktuell auch ohne Token eingerichtet werden, ebenso der Ventilator und die Lampe.
Beim Vacuum ist es zwingend erforderlich, den Token aus der App auszulesen (Anleitung s.u.).

Aktuelle Version:
2020/09 - new fan devices
2018-04-26 - fix vacuum timers
2018-03-01 - reset filter time
2018-02-26 - carpet mode fix
2018-02-23 - volume, V2 carpet mode, cleaning mode, wakeup
2018-02-18 - carpet mode test
2018-01-02 - accept ascii packed tokens
2017-12-05 - water purifier test
2017-10-18 - json data length fix
2017-10-10 - fully tested support for Mi UV Humidifier
2017-09-18 - support for encrypted tokens (96 chars)
2017-09-01 - unknown message errors on verbose 2/3
2017-08-09 - reconnect changes
2017-08-08 - air purifier status
2017-07-30 - vacuum history limit (10)
2017-07-24 - clean history delete fix, lamp toggle & off brightness
2017-07-23 - Vacuum timezone fix, EyeCare subType
2017-07-22 - EyeCare Settings
2017-07-21 - EyeCare Readings, Serial Number Fix, debugging
2017-07-20 - fixed history for multiple daily runs
2017-07-19 - remove json error on info for offline devices
2017-07-14 - get/set timer power & program, get/set timezone, reconnects
2017-07-10 - 2min interval during cleaning, auto-read history
2017-07-09 - History Cleanup
2017-07-08 - History Readings, Logging
2017-07-04 - timezone init
2017-07-02 - More lamps, clean records
2017-06-29 - Mi Smart Fan & Smart Lamp
2017-06-18 - Crypt::Rijndael_PP fix + bugfix
2017-06-14 - added wifi_setup, device_info & wifi_stats
2017-06-11 - firmware 3.3.9_003074, commandref, AirPurifier connection state

Markus M.:
    define <name> XiaomiDevice <ip> [<token>]
    Example: define vacuum XiaomiDevice 12345678901234567890123456789012
    Example: define airpurifier XiaomiDevice
    Local IP of the device

    Token of the device (mandatory for VacuumCleaner)

    Manually trigger data update

    Manually read settings

    Manually read clean summary data

    reconnect the device

    start (VacuumCleaner)
    Start cleaning

    spot (VacuumCleaner)
    Start spot cleaning

    pause (VacuumCleaner)
    Pause cleaning

    stop (VacuumCleaner)
    Stop cleaning

    charge (VacuumCleaner)
    Return to dock

    locate (VacuumCleaner)
    Locate the vacuum cleaner

    fan_power [1..100] (VacuumCleaner)
    Set suction power. (Quiet=38, Balanced=60, Turbo=77, Full Speed=90)

    remotecontrol start/stop (VacuumCleaner)
    Start or stop remote control mode

    move direction velocity [time] (VacuumCleaner)
    Move the vacuum in remotecontrol mode
      direction: -100..100
      velocity: 0..100
      time: time in ms (default=1000)

    reset_consumable filter/mainbrush/sidebrush/sensors (VacuumCleaner)
    Reset the consumables

    timer hh:mm days (VacuumCleaner)
    Set a new timer

    timerN on/off/delete (VacuumCleaner)
    Enable, disable or delete an existing timer

    timerN_time hh:mm (VacuumCleaner)
    Change the time for an existing timer

    timerN_days days (VacuumCleaner)
    Change the days for an existing timer

    dnd_enabled on/off (VacuumCleaner)
    Enable/disable DND mode

    dnd_start hh:mm (VacuumCleaner)
    Set DND start time

    dnd_end hh:mm (VacuumCleaner)
    Set DND end time

    on / off (AirPurifier)
    Turn the device on or off

    mode (AirPurifier)
    Set the device mode (auto,silent,favorite)

    favorite (AirPurifier)
    Set the speed for favorite mode (0..16)

    preset (AirPurifier)
    Set a preset from attribute preset ('mode auto')

    buzzer (AirPurifier)
    Set the buzzer (on,off)

    led (AirPurifier)
    Set the LED (bright,dim,off)

    child_lock (AirPurifier)
    Set the child lock (on,off)

    turbo (AirPurifier)
    Set the turbo mode (on,off)

    Current state

    fan_power (VacuumCleaner)
    Fan power in %

    error_code (VacuumCleaner)
    Error code

    consumables_X (VacuumCleaner)
    Consumables time remaining in %

    dnd (VacuumCleaner)
    Current DND mode state

    X_clean_area (VacuumCleaner)
    Area cleaned in m²

    X_clean_time (VacuumCleaner)
    Time cleaned in h

    total_cleans (VacuumCleaner)
    Total number of cleaning cycles

    serial_number (VacuumCleaner)
    Serial number of the vacuum

    timerN_X (VacuumCleaner)
    Timer details

    pm25 (AirPurifier)
    PM2.5 value in µg/m³

    pm25_average (AirPurifier)
    Average PM2.5 value in µg/m³

    temperature (AirPurifier)
    Temperature in ˚C

    humidity (AirPurifier)
    Humidity in %

    speed (AirPurifier)
    Fan speed in rpm

    usage (AirPurifier)
    Usage time in h

    volume (AirPurifier)
    Total air volume in m³

    filter (AirPurifier)
    Filter life in %

    VacuumCleaner / AirPurifier

    Disables the module

    Interval for data update (min 60 sec)

    Interval for settings update (min 300 sec)

    preset (AirPurifier)
    Custom preset for dynamic mode changes (defaults to 'mode auto')

Markus M.:
Neue/unbekannte Geräte:

Russische App zur Datenanalyse:

Verzeichnis /sdcard/vevs/logs auf dem Telefon anlegen und neu starten
Dann sollte die App alle Kommandos mitloggen, d.h. alle Funktionen einmal bedienen und dann dort ins Log schauen


Hier eine Anleitung von reddit, die für alle Geräte funktionieren sollte:

*     For the vacuum to be updated on the emulated android, your phone and the emulator must share server, e.g. region. If you, like me, are from Europe, this wasn't an option back in Mi Home 5.0.0. The first thing to do is to change your app location to someplace that the emulator also can connect. I went with "Other". Obs: You have to reconnect the vacuum as part of this process, which also gives it a new token.

*     Now time to emulate. I used this one: https://www.memuplay.com/ Download and install.

*     Download a downgraded version of Mi Home: https://www.apkmirror.com/apk/xiaomi-inc/mihome/mihome-5-0-0-release/

*     Open Memu. In the black bar on the right hand side, click the "Install APP" icon (the one with apk on it). Find the downgraded Mi Home that you just downloaded.

*     When it finishes installing, open the app and sign in to the same user as on your phone. Make sure to choose the same region. If the same region is not available, you have to redo step 1. When the vacuum loads as active and you can open it and see the map, you have done it right.

*     Now close the app (small circle at the right hand black menu). Click on memu's setting icon (gear symbol on the right side). Under the tab "Others", Enable Root Mode. This will restart the emulator.

*     Open the Memu's File Manager. Click the Hamburger to open the left side panel, go to setting (gear at bottom), General Settings, and change Access Mode to Root.

*     You now have access to the Root Folder. Click on it, and go to /data/data/com.xiaomi.smarthome/databases and select miio2.db. Keep this file selected.

*     We now want to copy this to a folder that is shared between the emulator and your computer. By Default, you can find one of these in the emulator at Home/sdcard/Download . The corresponding folder on your computer has been created by Memu in your Download-folder on Windows, called "MEmu Download". To see other Shared folders, click on "Shared folder" on the right hand side in Memu. Copy miio2.db here by clicking the symbol with small squares in the top bar of the File Manager.

*     Now you have the database. Last thing to do, is to get some program that runs SQL and get your token. I used http://sqlitebrowser.org/ . Download and install.

*     Open "DB Browser for SQLite", and click "Open Database". Locate miio2.db on your computer.

*     Go to "Execute SQL"-tab, and write: "select token from devicerecord where localIP is ''" Change with you vacuum's IP address. Run the code with the blue-play button, and you have your token.

MiHome Versionen ab September 2017 verschlüsseln den Token in der DB, sollte das Auslesen nicht klappen könnt ihr auch eine ältere Version der App ausprobieren.
- Android Version 4.2.0 (apk installieren)
- iOS Version 3.0.0 (mit Cydia Impactor installieren)

Den Token für die Einrichtung des Staubsaugers bekommt ihr danach so:

Android: (alle FWs)
 - Aus DB unter /data/data/com.xiaomi.smarthome/databases/miio2.db
 - Aus Android Backup mit MiToolkit, zu finden unter https://github.com/ultrara1n/MiToolkit

iOS mit Jailbreak: (alle FWs)
- Aus DB unter /var/mobile/Containers/Data/Application/514106F3-C854-45E9-A45C-119CB4FFC235/Documents/USERID_mihome.sqlite
- Gerätetokens finden sich in der  Datenbank

iOS: (alle FWs)
- Unverschlüsseltes iTunes Backup auf den Rechner kopieren
- Mit http://www.imactools.com/iphonebackupviewer/ Free öffnen
- RAW, com.xiaomi.home, USERID_mihome.sqlite -> Extrahieren
- Token aus der Datei lesen

Android Flole App: (FW < .3074)
- Installation der alternativen App von https://xiaomi.flole.de/ auf Android
- (Löschen der App-Daten, falls diese schon mal installiert wurde)
- (WiFi-Reset des Staubsaugers, falls er schon eingerichtet war)
- Verbinden mit dem AP des Staubsaugers
- Roboter in der App suchen
- App-Settings exportieren
- 32-stelligen Token aus der so erzeugten Datei kopieren, z.B.:
   [{"c":"::1","d":12345678,"e":"12345678901234567890123456789012","f":"Mi Vacuum","g":0}]

Python Script: (FW < .3074)
- Script xpn.py aus dem Anhang runterladen
- (WiFi-Reset des Staubsaugers, falls er schon eingerichtet war)
- Verbinden mit dem AP des Staubsaugers
- Script Aufruf zum Auslesen über
  python xpn.py -info

Einrichtung ohne App: (FW < .3074)
- Token auslesen und WLAN-Anmeldung ohne die Xiaomi App vornehmen mit folgendem Request:

Der Token ändert sich bei jedem (WiFi-)Reset des Staubsaugers und muss danach (nach der Einrichtung) neu ausgelesen werden.

96-stelligen Token entschlüsseln:

1. 96-stelligen Token auslesen und dann bei [ Input text ] einfügen
2. unter dem Feld den Button [ Hex ] auswählen
3. Bei [ Key ] 32x eine 0 (Null) einfügen
4. unter dem Feld den Button [ Hex ] auswählen
5. Auf das grüne [ Decrypt ] klicken
6. unten rechts steht der entschlüsselte Token

Bei copy&paste müssen die Leerzeichen aus dem entschlüsselten Token noch entfernt werden.

- shairport-sync verwandelt den Sauger nebenbei in einen Airport Speaker

Vielen dank für die ganze mühe!!!
Jetzt läuft auch bei mir das Modul wieder einwandfrei.

 :'( :'( :'(
Bei mir läuft es leider nicht. (Foto)
Ich habe aktuell die 3074 auf dem Staubi.


[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln