A script that outputs local weather information to a text file, for use with an Allsky camera to display local weather conditions in Allsky images.
This script uses the OpenWeatherMap API - a free API key needs to be generated in order to use this script.
On the machine or device where you need to use this script, do the following:
- Download the contents of this repository into a new folder
- Install Node.js
- Run
npm installto install the required packages - Test the script by running the command below, or add a Cron job or scheduled task that calls the script at a set interval, in order to generate the text file with fresh data:
node index.js --output=/home/pi/allskyweather/weather.txt --key=YOUR_API_KEY --city=London --region=Europe/London
For example, I use this Cron entry for running the script every even minute (every two minutes) on a Raspberry Pi (see the documentation here for how to set this up on Raspberry Pi):
*/2 * * * * /usr/bin/node /home/pi/allskyweather/index.js --output=/home/pi/allskyweather/weather.txt --key=YOUR_API_KEY --city=London --region=Europe/London
--output- The full path where to generate the text file--key- Your API key for the OpenWeatherMap API service (please note: API keys take a few minutes before they become active after creation)--city- The location you want to generate weather information--region- This is the timezone region for generating the correct local sunrise and sunset times. For valid values, refer to the date-fns-tz package
Update the settings_ZWO.json file in your Allsky folder by adding the location of the extratext file:
"extratext":"/home/pi/allskyweather/weather.txt"