Install Home Assistant, Mosquitto broker and Node-Red on android

This is Homeassistant, MQTT broker - Mosquitto, Node-RED installation. Requires Android 5.0 and up. Works without root. Install Termux and Termux:API from play store or F-droid. Install Hacker’s keyboard. This works for me, why you have a problem with this i don’t have a clue. :)

Start Termux

Update packages

packages update
packages upgrade
packages list-installed
packages install python python-dev coreutils nano ndk-stl clang mosquitto nodejs openssh termux-api

Install HA, Mosquitto, Node-RED

npm i -g --unsafe-perm node-red
npm i -g --unsafe-perm pm2
pip install homeassistant

####Start:

node-red
Stop node-red with ctrl +c or volume down + c

mosquitto
Stop Mosquitto with ctrl +c or volume down + c

hass
Wait for a installation to complete then stop HA with ctrl +c or volume down + c

Start at login

pm2 start mosquitto -- -v -c /data/data/com.termux/files/usr/etc/mosquitto/mosquitto.conf
pm2 start node-red --node-args="--max-old-space-size=128" -- -v
pm2 start hass --interpreter=python -- --config /data/data/com.termux/files/home/.homeassistant
pm2 save

pm2 show hass
pm2 logs hass

If you make mistake in pm2 configuration…

pm2 stop {hass or node-red...}
pm2 delete {hass or node-red...}

nano ~/.bashrc
pm2 resurrect

Enjoy

22 Likes

Hi,
First of all, I would like to thanks for this awesome tutorial.

I am unable to find configuration.yaml file, I searched on both internal memory and SD.

Can you please help me to find it and it would be good if I am unable to edit in my PC?

Thanks

My configuration.yaml file is in /data/data/com.termux/files/home/.homeassistant.

1 Like

but there is not data folder in my SD card and Internal storage.
I phone is not rooted.

any idea how can I edit configuration.yaml file??

My phone isn’t rooted. When you start termux app and enter pwd what do you get?

1 Like

I got:
/data/data/com.termux/files/home

If you started homeassistant with hass after you installed it with pip install homeassistant. There should be a .homeassistant folder. ls -A to see hidden folders.

1 Like

when I run home assistant with hass, it shows Config directory:
/data/data/com.termux/files/home/.homeassistant

but in storage there is no such folders?

Run termux-setup-storage. Then you can copy configuration.yaml from termux with cp /data/data/com.termux/files/home/.homeassistant/configuration.yaml /data/data/com.termux/files/home/storage/shared. Now it shows on my phone in /storage/emulated/0. When you finish with editing just copy it back to .homeassistant folder.

2 Likes

Great!
Its working now.

Thank you.

One more question I can run Mosquitto and hass simultaneously.

I mean if I run hass after that I can’t run mosquitto?

Yes you can. Run mosquitto first so that hass don’t give you error for mqtt.

1 Like

When I run mosquitto or hass then I can’t run other command.
Please see attachment:

Run it with
pm2 start mosquitto – -v -c /data/data/com.termux/files/usr/etc/mosquitto/mosquitto.conf

2 Likes

everything is working now.

Thanks

What is default username and password of mosquitto and how to change it?

There is no username and password in default mosquitto config. It allows anonymous connections. You can set password with mosquitto_passwd. Google is your friend. :slight_smile:

Thanks :slight_smile:

1 Like

Is it just me or is mosquitto having a wrong timestamp (-2 hours for me, Europe/Berlin) ? Maybe because of a missing timezone file? Any idea how to fix this?

It’s not just you. :smiley: I asked on temux github about timestamp problem and if i get answer i will post it here.