Install Home Assistant (HASS) on Android (NO ROOT)

This configuration is very useful to install Home Assistant (HASS) on your Android Phone without Rooting. Can be very useful for controlling your domotic house with a centralized server that you can relocate and modify easily. I’m using a backup old phone (a Xiaomi Mi 4C, at least Android 7.0) for it and it works smoothly :).

Note: Sijuissacp responded me that the minimum version required is Android 7.0. I’m not entirely sure of that, but it’s worth mentioning.

Let’s begin:

Let’s start saying that I suggest you to dedicate an Android Phone which means you need to keep it under charge all the time and with the screen on if you need it to show some stuff (I personally use it for showing some temperatura data and so on). If you don’t need this, you just need to keep it under charge.

You can achieve that with a power charge always connected (surprised uh?) and under Android’s Developer Options, enable the option “Keep screen awake while charging”.

Now take your phone and let’s work it.

Note: there’s some copy-paste here and there but with my personal modifications. Credits to every website that helped me to achieve this. If some authors feel weird about that drop me a message and I’ll fix ;).

# Guide for HASS on Android

This will install:

  • Homeassistant
  • Mosquitto MQTT Broker (if you need it)

## Preparation:

  1. Install F-droid (an alternative store, full of free and useful stuff)
  2. Install Termux from F-droid
  3. Termux:API from F-droid
  4. [OPTIONAL] Install Hacker’s Keyboard from F-droid

note: there apps are available also on Play Store, it’s up to you where to download.

## Guide:

As a general rule check always the log in the boot of HASS to understand if some versions of dependencies change (for example PyNaCl). Sometimes you need the specific version, not even the higher is fine (like in the case of PyNaCl).

### 1. Start Termux App;

### 2. Insert the following commands in order:

  • pkg update
  • apt-get update
  • pkg upgrade
  • pkg install python
  • pkg install nano
  • pkg install mosquitto (if it says ‘package not found’ issue ‘pkg update’ again and then try again)
  • pkg install nodejs
  • pkg install openssh
  • pkg install termux-api
  • apt install make
  • pip install PyNaCl==1.3.0 (go make a coffee, it takes a loooong time) (also, 1.3.0 may change, but I needed the exact version HASS wanted to make it work)
  • pip install aiohttp_cors
  • pip install homeassistant

### 4. Starting the environment:

  • mosquitto

If you need to stop Mosquitto you can ‘ctrl +c’ or ‘volume down + c’.

Now open a new session of termux (use the sidebar) and let’s boot Home Assistant with the command:

  • hass -v (-v is for verbose and it’s useful to understand what’s going on during boot)

Wait for the installation to complete then stop HA with ctrl +c or volume down + c and launch it again.

Access your web hass surfing the website:

http://localhost:8123

If you want to access it from another computer you may port forward the port 8123 and also may want to set a static IP Address for that device.

### EXTRA:

#### TO AUTO-BOOT THE ENVIRONMENT:

[IN PROGRESS] If you need to boot everything up when android starts you just need to open termux and issue the commands ‘mosquitto’ and ‘hass’ but you could do it automatically using termux::boot (available on playstore).

There should be also the pm2 option that is a way to achieve that, but I don’t know much about it.

I’ll write a guide about it asap. Boyscout promise.

#### TO OPEN-SSH YOUR PHONE:

That’s essential to the HASS community:

follow this guide first https://ibnuhx.com/remote-ssh-to-android-termux

then to copy files between local and remote you can use:

  • scp -r -P 8022 /path/local/dir user@remotehost:/path/remote/dir

#### SET UP DNS SERVER TO ACCESS HASS REMOTELY (OUTSIDE LAN)

Instead of accessing using the ip like https://192.168.XXX.XXX you may want to access the website in the more common normal way using a simple address like https://mysweethass.com

In order to do that you need a name address from https://www.noip.com/ that is the website to get a free dynamic dns address.

Create an address using their guide: https://www.noip.com/support/knowledgebase/getting-started-with-no-ip-com/

Then you could use your provider’s router that probably has a Dynamic DNS section where you can set the link between the address created using no-ip and the ip address of your phone.

Configuration may vary from router to router so I can’t give you a general guide.

An alternative to configuring your provider’s router is to install a (free) DNS Dynamic app to do that on your phone like this one. In this way you bypass the router configuration. https://play.google.com/store/search?q=dns+update

Drop me a line if you need help.

EDIT: check the comments on this Medium for meaningful troubleshooting. I.E. Looks like Pillow is giving problems to be installed, there’s a potential fix published by Jamie in there.

Update: A reader, Mohammed, made me notice that the command ‘pip install netdisco’ may be required in order to fix Pillow dependency.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store