Android Displays
In with the old ♻️ leave the new at the stores, we don't need it 🤟
Side Note: For powering my always on displays I use an adaptive fast charger coupled with a smart plug, and Home Assistant to toggle power based on my battery stats.
- 🔋 = 90% Power Off
- 🔋 = 15% Power On
If you are anything like me there has to be an old tablet in a drawer somewhere not doing anything. Mine happened to be an old Samsung SM-T310 👍️ this device shipped in June 2013 with 2
gig of memory, 1.6
of that is addressable for the OS 😅 trust me, the device is still perfectly usable after some work. This dual-core 1.5 GHz Cortex-A9 chip shipped with Jelly Bean 4.2.2 and a final release of Android 4.4 KitKat 😆... I can hear you right now, "You aren't going to connect that ancient tablet to the internet?!". The answer is no. But I will swing by XDA Developers to snag a more current Android image👌. Looks like Lineage OS 14.1 is built which brings the device to Nougat 7.1, and the device is on a isolated vlan so me thinks we got a winner.
Storage was a concern not for volume but speed since it's an old eMMC flash chip. I decided to grab a new 32
GB micro SD card and format that as system storage. Note: Fully Kiosk will complain about external app storage and I did move that particular app back to internal storage.
Responsiveness of the device after a clean install is adequate but once you launch an app you feel the age. Once Home Assistant loads the dashboard its more than usable for an always on display you just don't want to go designing panels for HA with it, oooof takes forever to load the editor 😆.
No need to go buy some pricey tablet mount. Bet you have a few 3M clips around? If not your local dollar+ store probably does.
WebView nooooo
F-droid for my preferred app store which has Home Assistant ready to go and minimal LineageOS is google free.
This is where the tablets age starts to crap on my dreams. HA loads but there are little UI glitches in menus, markdown cards don't render on panels, certain things just error the display but show on other newer displays. 🤔 Sounds like and issue with Android System WebView to me. I needed Chrome so I could test this theory! I used the Aurora Store app from f-droid to get an anonymous session on Google Play to quickly grab Chrome. Logged into my HA dashboard and ✨ voila! Everything renders as it should. Since upgrading the Android System WebView can be a nightmare to find a compatible version for an old Android base like I have. A better option would be to use Chrome's rendering engine with an app like Fully Kiosk Browser to create a simple always up display.
Fully Kiosk Browser
There are pros and cons to this method. The major con is you loose the sensor data for your logged in device which is how I automate these displays.
As of writing this I have yet to try running HA app in the background to Fully Kiosk but I think its a viable option... Tablets memory constraints are the bottle neck, with the OS + Fully Kiosk in full screen, at idle = 668
MB used. Leaves headroom of little less than 1
gig... We will see soon enough.
Use Chrome's WebView Engine
As long as Chrome is installed on the device you can use that engine to render Fully Kiosk Browser. Go to Settings -> Advanced Web Settings -> Select WebView Implementation.
Start On Boot
For how simple this feature is on any modern operating system, Android really does fight you unless you have Google Services running and a paid Play Store app. But we are Linux nerds here, and Android is just Linux really. I already install Termux as my default terminal and that has Termux: Boot 🧑🍳 delicious.
Termux SSH
Install openssh
within Termux and launch it with sshd
. Default port is 8022
username is admin
but you need to set your password before you can SSH to this device. From your Termux terminal prompt run passwd
to set the admin password.
Termux:Boot
Launch this application once before connecting over SSH.
Important: You MUST SSH into your Android device to create ~/.termux
, you CAN'T adb shell mkdir -p ~/.termux/boot
and create these files.
See side notes here.
SSH to the devices ssh -p 8022 admin@IP
create the directory ~/.termux/boot
. You can now drop scripts into this folder and they are run in order (not sure if alphabetical or lexically) so adding 10
, 30
, 50
... to your naming scheme would order them.
Scripting
It all started with a bang#!
Scripting with Termux:Boot you need to include the following shebang and you can pretty much do whatever you want from here. Launching applications, starting daemon services, triggering events, reading sensor data.
#!/data/data/com.termux/files/usr/bin/sh
to open your scripts and the world is yours 🦹!
#!/data/data/com.termux/files/usr/bin/sh
# prevent the device from sleeping
termux-wake-lock
# start sshd
sshd
# wait for WiFi sometimes
sleep 3
# start Fully Kiosk Browser
am start -n de.ozerov.fully/de.ozerov.fully.MainActivity
~/.termux
is NOT referring to ~/
as a system path of your Android operating system. You will quickly see that ~/
is pointing to /sdcard
a protected path this is a R/O
symlink of /storage/self/primary
owned by root
. Even if you mount this R/W
because you have root
😜 reboots will delete this data unless you persistently mount /sdcard
as R/W
. This is why we install and run SSHD
within Termux
because we are referring to the applications virtual filesystem that interacts with your Androids OS. The Termux:Boot app is listening for the android.intent.action.BOOT_COMPLETED
then executing scripts withing this folder on the Termux Virtual Filesystem.
Application Intent
Scripting can be such a powerful tool when coupled with Androids cli tooling. Activity Manager am
is a god sent when wanting to perform actions on Android and you couple it with an app called Activity Launcher and you can begin to create some great scripts. There is a cheat sheet for am
that I like over here.
Launching Home Assistant:
am start -n io.homeassistant.companion.android.minimal/io.homeassistant.companion.android.launch.LaunchActivity