HA is one of those few self hostable apps that is always synced across all devices.
Is it possible to make it run some custom code/routines on a specific device?
My use case is to toggle whether my android phone charges its battery to 70% or 100%. The ACCA app takes care of this, I just need HA to run some custom bash commands.
I do this to maximize life span its lithium battery.
if you can hook it into tasker or using the android intent system this might be achievable…youll need to do some research to see what is possible with that app.
EDIT: btw i used this method for bluetooth because the HA app cannot control BT on android 13 and avove but Macrodroid can. Agree with others you can also use intents for your use case.
This command format does not match what you linked me to. The intent extra is not setup properly either its missing the variable name, all you have as of now is variable value. The only thing correct above is the package name and intent action.
reading further into the page, looks like termux has their own custom permission they are expecting the app to request. Unfortunately this requires the app to hardcode an app specific permission and not a general android permission so the app will not have support for the custom permission.
Judging by teh above link you’ll probably need to link tasker to termux for this.
But I thought it might be useful for the companion app to add a custom sensor/switch, i.e. we can configure it to call (root) commands to retrieve values that are send back to HA as a sensor, and have a switch that runs a ON and OFF command.
The following works for me using the Tasker Function “TermuxCommand”.
“su -c” didn’t work for me so I installed tsu to get sudo and I use sudo as the command.
To install tsu in Termux run the following command:
Give permission for Task to use Termux as follows (copied from here):
Add a Tasker Function to your task, select TermuxCommand from the list. Tasker will then prompt you for
the command to run
the parameters
working directory (optional, you can leave this blank)
run in background or not
To run a command as root specify $PREFIX/bin/sudo when asked for the command, and specify the command you want to run as the first parameter, followed by the command parameters.
This will create a Tasker Function that looks like this:
Note that there are two adjacent commas followed “false” at the end. The adjacent commas mean there was no working directory specified and false is for “Run in background”.