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

That won’t work on termux. A see on internet some posts about termux and acme_tiny working with nginx reverse proxy. You can try to explore that.

Is it possible to connect a zigbee gateway directly like conbee on termux with an OTG cable ?

No. There is no support for usb devices. Only usb disks or keyboards.

what is the right pocedere to upgrade homeassistant to the actual version homeassistant 2021.3.1 from 2021.1.3? Please can you help me? Also I need Information for automatical startup via pm2.

If you install hass in venv activate it and than run this command

python -m pip install --upgrade homeassistant

To install pm2 first you need to install nodejs-lts. See post 313.

Hello vladosan,
thanks a lot for your friendly help, the procedere for the upgrade was working very well.
Regards Andy

1 Like

Greetings all,

Thank you @vladosam for this thread and introducing us to the termux/ha environment. It feels like it is one of the hidden gems and highly underrated.

I would like to contribute to this with a thread with a recent requirement I had and got working within the termux/ha ecosystem: Adding letsencrypt certs (wildcard) to your ha deployment running under termux and have them autorew.

This is not a beginners guide and it assumes the user is familiar with:

  • command line, pip, cron
  • has access to DNS (for TXT record changes)
  • make changes to their configuration.yaml for http on their own
  • is capable of using a search engine

This should serve as a sufficient starting point to adopt the commands issue a single domain cert.

In short:

  • Create venv for certbot
  • Install requirements for certbot to compile (rust)
  • Install certbot via pip
  • Run certbot with command line arguments to generate wildcard cert
  • Install crontab to update certs (untested to see if it does updates correctly)

The details are here:

1 Like

My mosquitto broker is not working anymore. I may have deleted some conf file. It is starting on boot with pm2. I tried mosquitto -v

How can I restart mosquitto ?
I tried pkg uninstall mosquitto and pkg install mosquitto.
Can someone help me ?

That looks like mosquitto is already stared. pm2 restart mosquitto or just restart termux.

I restarded mosquitto but I can’t see my topic in hass

If I use localhost it seems to works but I can’t use my ip 's adress broker

From 2.0 version of mosquitto you need to define listeners to bind on specific interface or on all interfaces. If listener is not defined mosquitto listens only on localhost. You need to add something like this in mosquitto config to listen on all interfaces:

listener 1883
allow_anonymous true

Mosquitto local network access

Thank you it is working now

when i try to run hass the following error appears:

(homeassistant) ~/.homeassistant $ pm2 logs hass
[TAILING] Tailing last 15 lines for [hass] process (change the value with --lines option)
/data/data/com.termux/files/home/.pm2/logs/hass-out.log last 15 lines:
2|hass     | Unable to find configuration. Creating default one in /data/data/com.termux/files/home/.homeassistant

/data/data/com.termux/files/home/.pm2/logs/hass-error.log last 15 lines:
2|hass     |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/components/ssdp/", line 51, in _async_initialize
2|hass     |     await scanner.async_scan(None)
2|hass     |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/components/ssdp/", line 91, in async_scan
2|hass     |     await self._process_entries()
2|hass     |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/components/ssdp/", line 138, in _process_entries
2|hass     |     await asyncio.gather(*tasks)
2|hass     |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/", line 150, in async_init
2|hass     |     flow, result = await task
2|hass     |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/", line 176, in _async_init
2|hass     |     result = await self._async_handle_step(flow, flow.init_step, data, init_done)
2|hass     |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/", line 257, in _async_handle_step
2|hass     |     result: FlowResult = await getattr(flow, method)(user_input)
2|hass     |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/components/fritz/", line 115, in async_step_ssdp
2|hass     |     "name": self._name.replace("FRITZ!Box ", "")
2|hass     | AttributeError: 'NoneType' object has no attribute 'replace'

ok after doing some changes these are the only 3 errors I get while running hass. Can someone help me?

1|hass  | 2021-05-10 22:03:23 WARNING (Recorder) [homeassistant.components.recorder.util] The system could not validate that the sqlite3 database at //data/data/com.termux/files/home/.homeassistant/home-assistant_v2.db was shutdown cleanly
1|hass  | 2021-05-10 22:03:23 WARNING (Recorder) [homeassistant.components.recorder.util] Ended unfinished session (id=2 from 2021-05-10 19:58:59.400018)
1|hass  | 2021-05-10 22:04:40 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: http, input_datetime, timer, input_number, system_health, scene, scene.homeassistant, media_source, counter, zone, tag, input_select, input_text, input_boolean, group, logbook

after deleting home-assistant_v2.db I get following error messages:

1|hass  | 2021-05-10 22:40:03 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
1|hass  | Traceback (most recent call last):
1|hass  |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/components/ssdp/", line 51, in _async_initialize
1|hass  |     await scanner.async_scan(None)
1|hass  |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/components/ssdp/", line 91, in async_scan
1|hass  |     await self._process_entries()
1|hass  |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/components/ssdp/", line 138, in _process_entries
1|hass  |     await asyncio.gather(*tasks)
1|hass  |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/", line 150, in async_init
1|hass  |     flow, result = await task
1|hass  |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/", line 176, in _async_init
1|hass  |     result = await self._async_handle_step(flow, flow.init_step, data, init_done)
1|hass  |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/", line 257, in _async_handle_step
1|hass  |     result: FlowResult = await getattr(flow, method)(user_input)
1|hass  |   File "/data/data/com.termux/files/home/homeassistant/lib/python3.9/site-packages/homeassistant/components/fritz/", line 115, in async_step_ssdp
1|hass  |     "name": self._name.replace("FRITZ!Box ", "")
1|hass  | AttributeError: 'NoneType' object has no attribute 'replace'

Hi, some idea how to solve it? Thanks!

Sorry but i can’t help you. My phone is now on android 10 version and it’s not rooted. And google is locking down android with every new version. Now i can’t install hass on termux :frowning: I’m afraid homeassistant install in termux will become impossible eventually.

Hmmm :confused:
It seems incredible to me that this is practically the only post (and therefore you the only good person) to do a tutorial on this.
Everyone takes for granted using a Rasberry Pi, while an old android could cost even less, be more beautiful (aesthetically) and functional. Sin!
Thanks anyway for trying!

I installed HomeAsisstant based on this tutorial and everything worked! (GitHub - alexanderhale/home-assistant: Home Assistant setup on a Nexus 7 tablet.). I use Android 9 on my phone tho so I’m not sure if it works for android 10 as well.