TaskerPy is a tool for creating Android automations using Python, simplifying the integration and control of tasks via Tasker.
Install directly from GitHub:
pip install git+https://github.com/brunodavi/tasker.py
Here’s a simple demonstration of how to create an automation with TaskerPy from Android:
from tasker.py import TaskerPy, Task
from tasker.actions.alert import Flash as Toast, Beep
app = TaskerPy()
# Displays a message and plays three beeps
@app.add_task(name='Show Popup')
def hello_world():
yield Toast('Hello, World', long=True)
yield Beep(frequency=8_000, duration=100)
yield Beep(frequency=9_000, duration=100)
yield Beep(frequency=10_000, duration=100)
# Imports the task and executes it
hello_world.play()
hello_world.export() # Exports as XML to /sdcard/Tasker/tasks/Show_Popup.tsk.xml
Contributions are welcome! Check the pending tasks on Projects.
We use PDM as the package manager. To set up the environment:
# Install dependencies
pdm install
# Activate the virtual environment
eval $(pdm venv activate)
# On Windows (PowerShell)
Invoke-Expression (pdm venv activate)
Need libxml2
and libxslt
The scripts defined in the pyproject.toml
include:
- test: To run tests.
- docs: To generate documentation.
- lint: To check code quality.
- format: To format the code.
# Run tests
pdm test
# Run tests ignoring Tasker actions
pdm test -k 'not action'
If the tasker.py project is already imported and running in Tasker, it should work on your phone by default. The default IP is localhost
.
To run outside the phone, configure the .env
file with your Android device’s IP:
TASKER_PY_ADDRESS=192.168.1.25
After importing the project in Tasker, click "Save" (✓), then tap the three dots to exit the editor.