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

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: https://gist.github.com/meijerwynand/d2627fd2d45299ac70330f957de2d545

1 Like

Hi
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 0.0.0.0
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/__init__.py", 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/__init__.py", 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/__init__.py", 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/data_entry_flow.py", 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/data_entry_flow.py", 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/data_entry_flow.py", 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/config_flow.py", 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/__init__.py", 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/__init__.py", 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/__init__.py", 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/data_entry_flow.py", 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/data_entry_flow.py", 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/data_entry_flow.py", 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/config_flow.py", 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.

I have and old Samsung S2 with 5.1 Os. I gonna try, thanks!

If you have any problems regarding resolv.conf don’t forget to install:

pkg install resolv-conf
1 Like

@vladosam
could you please check on your backup installation on Android if upgrading to 2021.5.x brings errors with dhcp and zeroconf? I know about one more user having it too, everything else is working fine.
edit: only now I see you couldn´t install hass on Termux anymore, nevermind, time to move on, thanks, it´s been a ride!

1 Like

You can still run it on android versons < 10. But eventually it will hit the wall. It’s a shame i always had termux as a backup if something happens to my main machine.

Just out of interest, what main machine do you use? And which from several oficially supported options would you recommend as most future-proof in your opinion?

I used rpi 2-3 and now i’m on libre computer le potato board. My setup is small an without cameras, so i don’t need to much power. A couple of my friends runs everything on unraid machines. And they say it works great for them. So in the future i will probably go in that direction.

1 Like