Skip to main content

WeDroid Python 3 Package

The weather announcement assistant. We(ather)Droid; for more information please visit: WeDroid Download.

Fetching weather reports

WeDroid can run either observation or forecasts styled reports.

  • Observations include a summary of the weather, temperature, time.
  • Forecasts return the weather status for a given interval + limit; for example 3h as the interval and 4 as the limit. Would produce a report with 4 observations with 3 hours intervals.

Forecast styled report

python3 launcher.py -t "forecast" -i "3h" -l 12 

Observation styled report

python3 launcher.py  -t "observation" -lt "14.0" -lc 812

Observation styled report with custom configuration

python3 launcher.py  -t "observation" -lt "14.0" -lc 812 -c "/path/to/some/where/settings.json"

Building the distributable and/or wheel:

Build the distributable:

python setup.py sdist 

Building the wheel:

python setup.py bdist_wheel

Clean build directory, build the distributable and wheel:

python setup.py clean sdist bdist_wheel

Cleaning build directory:

python setup.py clean --all

Example for installing the wheel:

pip install WeDroid-1.x.x-py3-none-any
pip install <path_to_file>\wedroid\dist\WeDroid-1.x.x-py3-none-any
pip install Z:\git\python3\wedroid\dist\WeDroid-1.x.x-py3-none-any.whl

Configuration

You will need an Open Weather Map API key to use this script.

You defined the configuration settings for WeDroid as a dictionary. You can either define this dictionary in the file calling the WeDroid class or you can optionally define it as a separate file.

An example for storing the settings in an optional file; create a new file for example: settings.json and insert the following:

{
    "run_type": "tasker",
    "intercept_task_name": "WeDroid Received",
    "owm_api_key": "<own-api-key>",
    "announce_temp": true,
    "announce_time": true,
    "announce_humidty": false,
    "announce_wind": false,
    "announce_sun": true,
    "sl4a_gtts": false,
    "bot_name": "WeDroid",
    "mattermost_url": "<web-hook-url>",
    "device_location": true,
    "longitude": -3.0,
    "latitude": 53.0,
    "log_level": "DEBUG",       // Value can be: INFO, DEBUG, ERROR
    "location_provider": "gps", // Value can be: gps, network, passive
    "location_request": "once"  // Value can be: once, last, updates
}

Usage as an package

When initiating WeDroid; pass the newly created configuration file:

Example:

import os
from wedroid.core import WeDroid

custom_config = "./settings.json"
if os.path.isfile(custom_config):
  # Pass in to WeDroid
  weather = WeDroid(custom_config)

From here you can access functions:

# A Forecast for 4 results split by a 3h interval
message = weather.generate_forecast_announcement("3h", "4")
# A weather observation now (compares previously values)
message = weather.generate_weather_announcement()

Customising messages and weather statuses

The messages and weather responses can be customised under ./wedroid/translations/* if working with the source directly:

  • annoucements.json contains various message part that make-up a report, example:
    •   "sunrise-future": "The Sun will rise in {}.",
        "sunset-past": "The Sun set {} ago.",
        "sunset-future": "The Sun will set in {}.",
      
  • weather.json contains a dict where the weather status codes map to a: title, icon, description, example
    •   "781": {
          "title": "Tornado",
          "icon": "50d",
          "description": "tornado"
        }
      

As a package you can pass the path the translations directory as follows, ensure that it contains announcements.json & weather.json:

wedroid = WeDroid(translation_path="./some/where/translations")

Tasker - Android

Requirements

  • 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 ensure 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.

Documentation from source

Regenerating documentation

Change to docs directory

cd docs

Building docs

sphinx-apidoc -f -o source/ ../wedroid
make clean
make html

Linux one-liner

sphinx-apidoc -f -o source/ ../wedroid && make clean && make html

Windows one-liner

sphinx-apidoc -f -o source/ ../wedroid & make clean & make html

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wedroid-1.3.4.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

WeDroid-1.3.4-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

Details for the file wedroid-1.3.4.tar.gz.

File metadata

  • Download URL: wedroid-1.3.4.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for wedroid-1.3.4.tar.gz
Algorithm Hash digest
SHA256 9373a766fc4f27e2663a421e0638f6a7e564f89a45674617e05256222077d8f8
MD5 afe8ce622f1fd461a386405d56d94a61
BLAKE2b-256 11f7c9b5c68cefa1f24a895cb76f0d1d38e01caf6840af60dca89cbaf2810641

See more details on using hashes here.

File details

Details for the file WeDroid-1.3.4-py3-none-any.whl.

File metadata

  • Download URL: WeDroid-1.3.4-py3-none-any.whl
  • Upload date:
  • Size: 29.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for WeDroid-1.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 71a6e94029a0b0855000c3622d6538892723b5c70c39f71cbf9009c92ffc0a4f
MD5 33aed572e980e940bb7745162bb5e836
BLAKE2b-256 c067e5e6c2aeb134948723eb4214111c47dbc0a7de6080576ae545586ac91e7a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page