Hack Mi Smart Clock to display lovelace ui

Once FullyKiosk is installed with local remote access I install all APKs via that, really easy to do

Did you or somebody else find a permanent solution for the wifi problem? I don’t want to set my Wifi to WPA2.

1 Like

The Wifi WPA2 problem would be a deal breaker for me also. :cry:

I can’t for the life of me get the bootloader to unlock.

“python mtk da seccfg unlock” seems to be working just fine and gives me a bunch of messages that payload has been sent, that preloader and security check have been patched and that stage 2 has been uploaded successfully.

It does report that a “V4 lockstate” has been detected, that “SEJ Legacy Hardware seems not to be configured correctly” and then throws me a bunch of Tracebacks. When I reboot, I don’t see any information about “Orange State”, yet I can enter fastboot mode. There, fastboot fails (“not allowed in locked state”).

I’ve been trying this on and off more months now, but I simply can’t figure out where I’m going wrong. I’m following the guide on the Github and I’m using an Ubuntu machine for it.

Managed to install Lineage 20 as per the instructions in the link. Everything works fine in terms of Fully Kiosk and Home Assistant. However, I would like to keep the Google Assistant capabilities, so I can keep using the clock as a Google speaker.

I tried to install this (both the ARM and ARM64 versions for Android 13) according to the instructions in the video provided below:

Unfortunately, after rebooting, Google Apps are not anywhere. Has anyone tried the same thing and managed to get the Mi Clock working as a Google speaker?

Thanks!

Hi

I really can’t help on your question, but you may be my saving grace. I got this a few weeks back and I tried to follow guides after guides and I am not getting anywhere. My biggest fear is brick my device. I posted on the HA discord for help, but like vocolinc devices, its very unreliable. I was hoping maybe you could help me out getting mine up and running. If your in the HA discord, can you DM Pak11. Simply pointing to docs and links I get very very lost as I am more of a “watch a step by step guide” person due to being a slow learner. I get into these things cus I love to tinker and learn, but 80% of guides are not idiot friendly and they assume you are an expert. Anyhow, looking for help and was hoping since youve got yours running, you could provide a little or a lot of guidance. Thanks!!

Hi @Pak11,

I understand your frustration. I also struggled to reach the final point because guides, tutorials and reddit threads about this topic are a bit messy for someone who is not familiar with terminal commands and certain “advanced” procedures.

Having said that, I am trying to help with a kind of step by step guide, although I am making it from memory, so perhaps I am missing some steps. Try to move forward and let me know if you get stuck at some point.

You should be able to do everything with the “DVD” stated in the first point. You can burn it into a USB instead of a DVD and move forward from there. ISO has not been updated for sometime, so you will probably get some errors or glitches at some point, but it is possible to make everything from there.

SETUP

  1. Download the Live DVD V6 .iso that you will find here:
    https://github.com/bkerler/mtkclient#installation
  2. Burn it into a USB with Balena Etcher or similar.
  3. Get ANOTHER USB drive that you can use for storing your backup and other necessary files for flashing the Mi Clock. Do not use the boot/live USB for this. The boot USB must not be disconnected from the computer until everything is done.
  4. According to the XDA thread stated earlier in this forum topic, download LineageOS from here;
    https://androidfilehost.com/?fid=10620683726822080854, unzip it and copy the three .img files somewhere into the USB drive.
  5. Download Fully Kiosk apk and copy it somewhere into the USB drive too. Yon can find it here. The one you should download is in the "Download APK files box just in the right of the web page and it is named "Fully Kiosk Browser APK ver. 1.56.3 (for Android/Fire), or whatever latest version is available.
  6. Insert the Live DVD USB in a computer and boot from the USB.
  7. After a few minutes, login screen will be shown. User is “user” and password is “user”). Once done, desktop will load.
  8. Disable the automatic suspend mode to avoid any issues when backing up or flashing: Right click on the desktop, click on “Display Settings” > Power > Switch off “Automatic Suspend” and also change to “Never” the Screen Blank option.
  9. Choose an English keyboard in the menu bar so a standard keyboard is mapped to the physical keyboard: click on the “de” word in the right side of the menu bar and choose the “en” option. If you don’t do this, the “z” key will be the “y” character for instance.
  10. On the desktop, you will see a few icons there that will be probably greyed out. Just right click on the mtkclient.desktop one and click on “Show in files”.

Key points are stated in the following URL. I added a few for easy understanging, so just including the URL for reference. You can just continue to point 11 below:
https://github.com/octathorp/x04g_tools/blob/acec16d5bb252ab5f13fa42f1f91a16b8849d38f/howtos/BackupFlash.md

BACKUP

  1. Double click on “MTK client” GREEN icon to open the MTK GUI,
  2. Grab the Mi Clock and connect it to a USB port of the computer WHILE PUSHING THE VOL+ BUTTON ONLY. After a few seconds, clock will be detected as “MT8167/MT8516/MT8362” phone. Wait until messages finish and “Bootrom mode” is displayed under the phone model.
  3. Connect the USB drive from point 3 somewhere in your computer and wait to be detected and loaded on the desktop.
  4. Backup flash memory: In the “Flash tools” tab click on the “Read flash” button, select the path where you want to save the file (choose the USB drive stated in point 13) and wait patiently as it may take some time, depending on factors such as our USB controller, quality of connection cable or operating system version.
  5. Once this process is finished, we will do the same with “Read preloader” and “Read boot2” buttons. Then, in the “Read partition(s)” tab, check “Select all partitions” and press the “Read partition(s)” button to make a copy of the device’s memory again, this time split into partitions.
  6. In terms of backup, that’s it. You can close the MTKClient App. You won’t need these backup files again unless you need to restore your clock. However, I have not done it yet, so I cannot give instructions nor feedback about this yet.
  7. Unplug the Mi Clock from the computer.

INSTALL LINEAGE 20 IN THE CLOCK
For reference: https://github.com/octathorp/x04g_tools/blob/acec16d5bb252ab5f13fa42f1f91a16b8849d38f/howtos/FlashCustomImages.md

  1. Make sure that the point 3/13 USB is still connected.
  2. Double click on the MTK Client CLI icon (the black and white icon with a terminal prompt graphic). If you closed the MTK Apps window, proceed as per point 10.
  3. Execute the following command:
python mtk.py e metadata,userdata,md_udc
  1. Connect the Mi Clock again while pressing the VOL+ button. After a few seconds, you will see in the terminal that MTK is performing tasks on the clock (erasing partitions). You can release the VOL+ when clock is detected and tasks start.
  2. When the prompt is displayed again, execute the following:
python mtk.py da seccfg unlock
  1. When prompt is back, execute the following to reset the clock:
python mtk.py reset
  1. Close all windows so you don’t get confused.
  2. Disconnect the device, wait for a few seconds and reconnect it. Mi logo will show along with a text indicating that the device is in “Orange State”. Bootloader is now unlocked.
  3. Disconnect the clock from PC, and press three upper buttons to reconnect it. After 5 seconds release the mute button and leave the other two buttons pressed until the text “No command” shows on the screen. Kepp mute pressed and press VOL+ button once to reveal the recovery menu.
  4. Select “Reboot to bootloader”.
  5. After some time, clock will enter fastboot mode (it will be indicated with a small text at the bottom of the clock screen.
  6. Go to the folder in your USB drive where you copied the three .img files as per point 4 by clicking on the USB drive icon in your desktop, but do not enter the folder itself. Right click on such folder (or the USB drive itself if you copied the .img files in USB drive root) and select “Open in Terminal”.
  7. Execute the following commands one after another:
fastboot flash boot boot.img
fastboot flash super super.img
fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img

The .img files are the ones you downloaded in point 4.
NOTE: Even though you are in the same folder where. img files are, I remember that I had to use absolute paths for them. Then, if you get some error upon executing the first fastboot command, try to use absolute paths. This is actually what I had to do for this to work. For example:

fastboot flash boot /media/user/USB_DRIVE/MY_FOLDER/boot.img
fastboot flash super /media/user/USB_DRIVE/MY_FOLDER/super.img
fastboot --disable-verity --disable-verification flash vbmeta /media/user/USB_DRIVE/MY_FOLDER/vbmeta.img
  1. Execute the following command to reboot the clock so it starts Lineage OS for the first time:
fastboot reboot
  1. If everything goes well, Lineage will boot in a few minutes. BE PATIENT! Be advised that Lineage boot times are long. Expect to be seeing the “Orange State” screen displayed for a few minutes, although it says that it will boot in 5 seconds.Furthermore, you will see a blank screen, Lineage logo animation and a white rectangle screen form some time. Again… BE PATIENT! The whole process will take 5-6 minutes from the moment that you plug the device in to the moment where the startup wizard starts at.

NOTE: I had no issues setting up the clock while connected to my computer’s USB port. However, if you have some problems while booting up the clock from this point, try to power it with the clock’s power supply, as advised by @zuz242.

  1. Such wizard will eventually be displayed. Scroll with your fingers to see everything. Select your WiFi network when applicable and wait for the desktop to load.

INSTALL FULLY KIOSK

  1. Slide to the left so you can go to the second desktop. You will see there the settings icon. Click on it. Go to the “Device information” option at the bottom of the screen and click on it. Slide down to the latest option named “Compilation number”. Click on it several times until you see a message confirming that the developer options have been enabled.
  2. Go back to the previous menu. Find the “System” menu and enter. Find the “Developer options” and enter. You won’t be able to slide down on this screen (at least I haven’t been able to), so click on the magnifier icon at the top right of the screen. Type “USB” on the search field. Once results are displayed, scroll down until you find the “USB debugging” option. Enable the option, accept the warning and exit to the desktop clicking on the “circle” icon at the bottom of the screen.
  3. Go back to the computer where the Live DVD/USB is running. Make sure that the Clock is still connected. If you have connected to the power supply for setting up Lineage, unplug it, connect it back to the computer and wait for the clock to load the Lineage desktop.
  4. Once everything is on place, we will install Fully Kiosk on the clock trough adb from the computer. For that, we will use the same “right click > Open in Terminal” option we’ve been using along this guide at the USB folder where the Fully Kiosk apk was copied to (point 5). On the terminal type the following:
adb install Fully-Kiosk-Browser-v1.56.3.apk
  1. Once done, Fully Kiosk is installed. You can go back to the clock, slide the finger up through the screen to reveal the applications and click on the Fully Kiosk Browser menu.
  2. Type your Home Assistant instance URL on the “Start URL” field, make sure that the Fullscreen Mode is enabled, slide down and hit “Start Using Fully”.

And thats it! From this point, you will have to create a user with a specific dashboard for the purpose of being displayed in the small screen of the clock. You will also have to download “Kiosk Mode” from HACS so you can hide the top menu and also a convenient clock card to include it in your dashboard, but I guess you can deal with those HASS related stuff by yourself.

Hope this guide helps. Do feel free to ask if you have any question, and please let me know if you figure out any thing that it is worth it to be included in the guide for other’s reference. I will also be happy to fix or add any importan step that I missed. Please, confirm if you manage to get the clock working as expected. I would love to get feedback from you when done. :slight_smile:

Apart from this, I still have to check how to manage the screen off/on behaviour so it makes sense for a bed clock and other relevant features. It would be great if you or other people update this forum thread accordingly.

Cheers!

3 Likes

All i can say is OMG. Thanks soo soo much for this. The initial issue I was having was that the mtkclient was not installing/working. I jumped from webpage to webpage of “guides” and at one point I had 20 pages open. It actually made it worse because you are following one and jump to the other to only realise neither tells you a specific step to get the next command to work. Only after opening a new page and typing the error you received and doing an hour or 2 of more digging, you find out you needed to add a comma… ffs

Anyhow. I got it up and running. I used a bit of your guide. I didn’t have to use a cd or dvd though. I managed to do the fully backup on windows and the install on mint Linux. The odd thing, (maybe not odd for some) is that Linux seemed to reject mtkclient. I believe this is what had me running mad for hours. I jumped to windows and in 30 minutes, following the steps, I got it backing up. I honestly can’t recall step by step as I just threw everything at it and hope something stuck. Thankfully I setup duel boot on my laptop and kept windows when I switched to Linux or I would be in my driveway right now driving over the clock…

So all that said, I want to throw a helper to anyone who finds there way here while they lock themselves away from friends and family for days fixing this. If you buy the license, you may enable some settings that require android system settings permissions. It may seem obvious to some, but hey I was very lost and can’t only be the only one. So anyhow, android lineage doesnt allow you to adjust “Drawing over other apps”. All you’ll have to do for this is go into your terminal and enter

//Enter ADB shell
adb shell

//Want to grant draw over other apps permission for these apps
pm grant <package-name-here> android.permission.SYSTEM_ALERT_WINDOW

//Example
pm grant com.facebook.orca android.permission.SYSTEM_ALERT_WINDOW

I found this, so credit to Enter hidden Settings for Draw over other Apps | XDA Forums user AmznUser444

For Fully Kiosk Browser use

pm grant de.ozerov.fully android.permission.SYSTEM_ALERT_WINDOW

You can install via adb an android app called Package Name Viewer to get the proper name of the apps.
User h_1995 on reddit posted “replace with package name of the app that you want to display over other app. for example Newpipe has the package name of org.schabi.newpipe , so the entire command would be adb shell pm grant org.schabi.newpipe android.permission.SYSTEM_ALERT_WINDOW. As for finding package name, Package Name Viewer probably could help
this permission list might be handy as well for other blocked settings Manifest.permission  |  Android Developers

Lastly, be very careful how much power you draw while the clock is plugging into the PC for abd edits. You’ll want to enable USB debugging and install everything you need with adb as its the easist and fastest way to get apps installed. But I warn because if you draw a lot of power, you’ll find yourself waiting for the device to reboot itself to try again. Or worse a boot loop. I simply adjusted my brightness and avoided running anything while i needed to be connected to the PC. (power isn’t an issue running a cable to a 5V/2A wall charger outside of using the PC)

Anyhow, thanks again for the great guide. I’m fully (pun intended) up and running and now I just have to figure out what I want to do with it dashboard wise now.

even after applying the command via adb i still get permission required :S