Unveiling WeDroid a weather assistant module for Python 3

descriptionStandard

Presenting WeDroid a weather summary & announcement utility, cross platform (runs on anything that can run Python 3.9+) with additional bonuses for Android users through support for Tasker and/or Termux.

The WeDroid project page on oddineers.co.uk is being re-designed; when ready it will include examples on running WeDroid with Tasker + Termux and include additional information for configuring those application. The Tasker section will provide a template Profile and a set of Task’s for interacting with WeDroid through Termux.

Background and history

WeDroid was originally a weather reporting script that returned the current weather status in a short message form. It was written right after the Metal Gear Solid V: The Phantom Pain’s release and was heavily influenced by the iDroid weather reports that Venom Snake would receive in-game. These reports would indicate drastic changes like sandstorms, rain, or the weather clearing.

Originally written for Python 3 via SL4A (Scripting layer 4 Android), which at the time allowed access to device feature such as GPS and TTS. The keen eyed will spot traces in the source code; over time I’ve refined and adapted WeDroid refining it and adding more functionality, the ability to customise the weather messages. Additions for items such as: weather status, temperature, humidity, wind, sunrise and sunset and more.

I’ve wanted to release this for quite some time; I still use this daily and hope you too will enjoy it!

WeDroid + Termux + Tasker + Android

The Tasker integration allows WeDroid to update variables declared in Tasker (through an Intent); you can use these Tasker variables to then trigger additional tasks for example Text-to-speech. Termux is used to provide a shell and enable the installation of Python 3 with Termux-API it is used to access the device location; View the source code for Termux integation in WeDroid.

If you’re eager to try it for yourself (that is: running WeDroid on Android via Termux using Tasker as the controller/trigger); it’s relatively straight forward and the information below should help you get started:

REMINDER: This section will make more sense once the examples (video also coming) are ready and Tasker Profiles + Tasks have been made available.

Update 15-09-2024: Examples and setup instructions for configuring WeDroid with Tasker and Termux can be found at: Utilising WeDroid with Termux + Tasker

Requirements (Android)

  • Tasker
  • Termux (other shells are likely supported where you can install Python 3)
  • Termux:API
  • Termux Tasker plugin
  • Termux requirements:
    • Termux configured to access local storage
    • Termux:API configured to allow GPS access (if you intend to let WeDroid access the devices location)

These instructions are somewhat vague at the moment and will be expanded soon in greater details in ReadTheDocs.

When used with Tasker on Android you can define a task and/or profile which can run the WeDroid announcement service.

To run the script under Tasker via Termux check the following:

  • Python 3 via the Termux.
    • Termux is installed.
    • Python 3 package is installed.
    • The Task in Tasker is specifically “Run Termux Script” & the script to run is called launcher.py enabled and pass the following variables: %WD_LAST_TEMP, %WD_LAST_CODE.
  • In Tasker assign the value 0 to %WD_LAST_TEMP, %WD_LAST_CODE.
  • Run script to finish configuration and create default configuration.
  • Open settings.json and add your OWM API key, create one here.

Upon first run the following Tasker variables are created:

%WD_LAST_CODE
%WD_SUNRISE
%WD_SUNSET
%WD_LAST_TEMP
%WD_LAST_TIME
%WD_LAST_WIND_SPEED
%WD_LAST_WIND_DIRECTION
%WD_LAST_HUMIDITY
%WD_DAY_STATE
# The main announcement
%WD_ANNOUNCEMENT
# Announcement parts separated
%WD_TIME_MSG
%WD_WEATHER_MSG
%WD_TEMP_MSG
%WD_WIND_MSG
%WD_SUN_MSG
%WD_HUMIDITY_MSG

At this point the configuration aspect is complete, but we need to configure a run schedule within Tasker.

Tasker Profile Creation

The simplest method is to create a Tasker Profile using the Time profile.

  1. Create new profile > Time > Define range and re-occurrence.
  2. Next link the profile to a new task “Run Termux Script” as defined earlier.

If you made it this far; thank you for taking the time to read this. All the best Steven.

Final words

On my personal blog I’ve made several post discussing various uses of Termux, Tasker, Android Intents they may be of interest: