VSIDO Community

VSIDO Support => Scripts and How To's => Scripts => Topic started by: hakerdefo on July 22, 2015, 05:54:43 PM

Title: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: hakerdefo on July 22, 2015, 05:54:43 PM


(07 May 2017) Update  Begins:

Removed the dependencies on Perl and cURL.
Cleaned-up the script a bit.

Don't forget to read the set-up instructions posted down below if you are a new user  ;)

Here is updated pmwf script


#!/usr/bin/env bash
###################
local_latitude=
local_longitude=
local_unit=
api_key=
local_rm=$(which rm)
printf "\033c"
wget --user-agent="Mozilla/5.0 Gecko/20100101" --quiet --timeout=30 "http://api.openweathermap.org/data/2.5/weather?lat=$local_latitude&lon=$local_longitude&units=$local_unit&mode=json&APPID=$api_key" --output-document "/tmp/current.json"
wget --user-agent="Mozilla/5.0 Gecko/20100101" --quiet --timeout=30 "http://api.openweathermap.org/data/2.5/forecast/daily?lat=$local_latitude&lon=$local_longitude&cnt=4&units=$local_unit&mode=json&APPID=$api_key" --output-document "/tmp/forecast.json"
printf "\033c"
if [[ ! -f "/tmp/current.json" ]]; then
    echo ""
    echo -e "Can not connect to openweathermap.org!"
    echo -e "Please check your internet connection!"
    echo ""
    exit 1
else
    place=$(jq -r '.city.name' "/tmp/forecast.json")
    nation=$(jq -r '.city.country' "/tmp/forecast.json")
    time2=$(jq -r '.list[1].dt' "/tmp/forecast.json")
    time3=$(jq -r '.list[2].dt' "/tmp/forecast.json")
    time4=$(jq -r '.list[3].dt' "/tmp/forecast.json")
    time22=$(date -d @"$time2" +'%A, %d %B %Y')
    time33=$(date -d @"$time3" +'%A, %d %B %Y')
    time44=$(date -d @"$time4" +'%A, %d %B %Y')
    tempcurrent=$(jq -r '.main.temp' "/tmp/current.json")
    min2=$(jq -r '.list[1].temp.min' "/tmp/forecast.json")
    min3=$(jq -r '.list[2].temp.min' "/tmp/forecast.json")
    min4=$(jq -r '.list[3].temp.min' "/tmp/forecast.json")
    max2=$(jq -r '.list[1].temp.max' "/tmp/forecast.json")
    max3=$(jq -r '.list[2].temp.max' "/tmp/forecast.json")
    max4=$(jq -r '.list[3].temp.max' "/tmp/forecast.json")
    pressurecurrent=$(jq -r '.main.pressure' "/tmp/current.json")
    pressure2=$(jq -r '.list[1].pressure' "/tmp/forecast.json")
    pressure3=$(jq -r '.list[2].pressure' "/tmp/forecast.json")
    pressure4=$(jq -r '.list[3].pressure' "/tmp/forecast.json")
    humidcurrent=$(jq -r '.main.humidity' "/tmp/current.json")
    humid2=$(jq -r '.list[1].humidity' "/tmp/forecast.json")
    humid3=$(jq -r '.list[2].humidity' "/tmp/forecast.json")
    humid4=$(jq -r '.list[3].humidity' "/tmp/forecast.json")
    windcurrent=$(jq -r '.wind.speed' "/tmp/current.json")
    wind2=$(jq -r '.list[1].speed' "/tmp/forecast.json")
    wind3=$(jq -r '.list[2].speed' "/tmp/forecast.json")
    wind4=$(jq -r '.list[3].speed' "/tmp/forecast.json")
    direcurrent=$(jq -r '.wind.deg' "/tmp/current.json")
    dire2=$(jq -r '.list[1].deg' "/tmp/forecast.json")
    dire3=$(jq -r '.list[2].deg' "/tmp/forecast.json")
    dire4=$(jq -r '.list[3].deg' "/tmp/forecast.json")
    condicurrent=$(jq -r '.weather[].description' "/tmp/current.json")
    condi2=$(jq -r '.list[1].weather[].description' "/tmp/forecast.json")
    condi3=$(jq -r '.list[2].weather[].description' "/tmp/forecast.json")
    condi4=$(jq -r '.list[3].weather[].description' "/tmp/forecast.json")
    if [[ "$local_unit" == imperial ]]; then
windcurrent1="$windcurrent"
wind22="$wind2"
wind33="$wind3"
wind44="$wind4"
symb=$(echo -e "\u2109")
symb2="mph"
    else
windcurrent1=$(awk "BEGIN {print $windcurrent * 3.6}")
wind22=$(awk "BEGIN {print $wind2 * 3.6}")
wind33=$(awk "BEGIN {print $wind3 * 3.6}")
wind44=$(awk "BEGIN {print $wind4 * 3.6}")
symb=$(echo -e "\u2103")
symb2="kph"
    fi
    printf "\033c"
    echo -e '\e[01m'""
    echo -e "Location - $place, $nation:"
    echo ""
    echo -e "Current weather conditions:"
    echo -e '\e[0m'""
    echo -e "Temperature - $tempcurrent $symb"
    echo -e "Atmospheric Pressure - $pressurecurrent hPa"
    echo -e "Humidity - $humidcurrent %"
    echo -e "Wind speed - $windcurrent1 $symb2"
    echo -e "Wind direction - $direcurrent°"
    echo -e "Weather condition - $condicurrent"
    echo -e '\e[01m'""
    echo -e "Forecast for $time22:"
    echo -e '\e[0m'""
    echo -e "Minimum Temperature - $min2 $symb"
    echo -e "Maximum Temperature - $max2 $symb"
    echo -e "Atmospheric Pressure - $pressure2 hPa"
    echo -e "Humidity - $humid2 %"
    echo -e "Wind speed - $wind22 $symb2"
    echo -e "Wind direction - $dire2°"
    echo -e "Weather condition - $condi2"
    echo -e '\e[01m'""
    echo -e "Forecast for $time33:"
    echo -e '\e[0m'""
    echo -e "Minimum Temperature - $min3 $symb"
    echo -e "Maximum Temperature - $max3 $symb"
    echo -e "Atmospheric Pressure - $pressure3 hPa"
    echo -e "Humidity - $humid3 %"
    echo -e "Wind speed - $wind33 $symb2"
    echo -e "Wind direction - $dire3°"
    echo -e "Weather condition - $condi3"
    echo -e '\e[01m'""
    echo -e "Forecast for $time44:"
    echo -e '\e[0m'""
    echo -e "Minimum Temperature - $min4 $symb"
    echo -e "Maximum Temperature - $max4 $symb"
    echo -e "Atmospheric Pressure - $pressure4 hPa"
    echo -e "Humidity - $humid4 %"
    echo -e "Wind speed - $wind44 $symb2"
    echo -e "Wind direction - $dire4°"
    echo -e "Weather condition - $condi4"
    echo -e ""
    "$local_rm" -f "/tmp/forecast.json"
    "$local_rm" -f "/tmp/current.json"
fi
exit 0
###################



Cheers!!!


(07 May 2017) Update Ends:






(19 November 2015) Update  Begins:

Starting from 9 October 2015 OpenweatherMap API requires a valid APPID for access. So you'll need to register at openWeatherMap and get your API key. It's simple and free plan is good enough for most cases. I've updated the script and instructions to reflect these changes. you can get the latest version of pmwf and read updated install instructions on GitHub page here,

pmwf on GitHub (https://github.com/hakerdefo/pmwf)

I want to thank PackRat and ozitraveller for bringing this to attention. You guys rock  8)

(19 November 2015) Update Ends:



As per suggestion by VastOne I've modified the original script to display current weather conditions and a 3 days weather forecast.


#!/bin/bash

clear

latit=
longi=
uneet=

curl -s --connect-timeout 30 -o /tmp/current.json "http://api.openweathermap.org/data/2.5/weather?lat=$latit&lon=$longi&units=$uneet&mode=json"
curl -s --connect-timeout 30 -o /tmp/forecast.json "http://api.openweathermap.org/data/2.5/forecast/daily?lat=$latit&lon=$longi&cnt=4&units=$uneet&mode=json"

if [ ! -f /tmp/forecast.json ]; then
echo ""
echo -e "Unable to connect to openweathermap.org!"
echo -e "Check your internet connection!"
echo ""

exit 1

else
place=$(cat /tmp/forecast.json | jq -r '.city.name')
nation=$(cat /tmp/forecast.json | jq -r '.city.country')
time2=$(cat /tmp/forecast.json | jq -r '.list[1].dt')
time3=$(cat /tmp/forecast.json | jq -r '.list[2].dt')
time4=$(cat /tmp/forecast.json | jq -r '.list[3].dt')
time22=$(date -d @"$time2" +'%A, %d %B %Y')
time33=$(date -d @"$time3" +'%A, %d %B %Y')
time44=$(date -d @"$time4" +'%A, %d %B %Y')
tempcurrent=$(cat /tmp/current.json | jq -r '.main.temp')
min2=$(cat /tmp/forecast.json | jq -r '.list[1].temp.min')
min3=$(cat /tmp/forecast.json | jq -r '.list[2].temp.min')
min4=$(cat /tmp/forecast.json | jq -r '.list[3].temp.min')
max2=$(cat /tmp/forecast.json | jq -r '.list[1].temp.max')
max3=$(cat /tmp/forecast.json | jq -r '.list[2].temp.max')
max4=$(cat /tmp/forecast.json | jq -r '.list[3].temp.max')
pressurecurrent=$(cat /tmp/current.json | jq -r '.main.pressure')
pressure2=$(cat /tmp/forecast.json | jq -r '.list[1].pressure')
pressure3=$(cat /tmp/forecast.json | jq -r '.list[2].pressure')
pressure4=$(cat /tmp/forecast.json | jq -r '.list[3].pressure')
humidcurrent=$(cat /tmp/current.json | jq -r '.main.humidity')
humid2=$(cat /tmp/forecast.json | jq -r '.list[1].humidity')
humid3=$(cat /tmp/forecast.json | jq -r '.list[2].humidity')
humid4=$(cat /tmp/forecast.json | jq -r '.list[3].humidity')
windcurrent=$(cat /tmp/current.json | jq -r '.wind.speed')
wind2=$(cat /tmp/forecast.json | jq -r '.list[1].speed')
wind3=$(cat /tmp/forecast.json | jq -r '.list[2].speed')
wind4=$(cat /tmp/forecast.json | jq -r '.list[3].speed')
direcurrent=$(cat /tmp/current.json | jq -r '.wind.deg')
dire2=$(cat /tmp/forecast.json | jq -r '.list[1].deg')
dire3=$(cat /tmp/forecast.json | jq -r '.list[2].deg')
dire4=$(cat /tmp/forecast.json | jq -r '.list[3].deg')
condicurrent=$(cat /tmp/current.json | jq -r '.weather[].description')
condi2=$(cat /tmp/forecast.json | jq -r '.list[1].weather[].description')
condi3=$(cat /tmp/forecast.json | jq -r '.list[2].weather[].description')
condi4=$(cat /tmp/forecast.json | jq -r '.list[3].weather[].description')

if [ "$uneet" == imperial ]
then
windcurrent1="$windcurrent"
wind22="$wind2"
wind33="$wind3"
wind44="$wind4"
symb=°F
symb2=mph
else
windcurrent1=$(perl -le 'print $ARGV[0] * 3.6' "$windcurrent")
wind22=$(perl -le 'print $ARGV[0] * 3.6' "$wind2")
wind33=$(perl -le 'print $ARGV[0] * 3.6' "$wind3")
wind44=$(perl -le 'print $ARGV[0] * 3.6' "$wind4")
symb=°C
symb2=kph
fi

echo ""
echo -e "Location - $place, $nation:"
echo ""
echo -e "Current weather conditions:"
echo ""
echo -e "Temperature - $tempcurrent $symb"
echo -e "Atmospheric Pressure - $pressurecurrent hPa"
echo -e "Humidity - $humidcurrent %"
echo -e "Wind speed - $windcurrent1 $symb2"
echo -e "Wind direction - $direcurrent°"
echo -e "Weather condition - $condicurrent"
echo ""
echo ""
echo -e "Forecast for $time22:"
echo ""
echo -e "Minimum Temperature - $min2 $symb"
echo -e "Maximum Temperature - $max2 $symb"
echo -e "Atmospheric Pressure - $pressure2 hPa"
echo -e "Humidity - $humid2 %"
echo -e "Wind speed - $wind22 $symb2"
echo -e "Wind direction - $dire2°"
echo -e "Weather condition - $condi2"
echo ""
echo ""
echo -e "Forecast for $time33:"
echo ""
echo -e "Minimum Temperature - $min3 $symb"
echo -e "Maximum Temperature - $max3 $symb"
echo -e "Atmospheric Pressure - $pressure3 hPa"
echo -e "Humidity - $humid3 %"
echo -e "Wind speed - $wind33 $symb2"
echo -e "Wind direction - $dire3°"
echo -e "Weather condition - $condi3"
echo ""
echo ""
echo -e "Forecast for $time44:"
echo ""
echo -e "Minimum Temperature - $min4 $symb"
echo -e "Maximum Temperature - $max4 $symb"
echo -e "Atmospheric Pressure - $pressure4 hPa"
echo -e "Humidity - $humid4 %"
echo -e "Wind speed - $wind44 $symb2"
echo -e "Wind direction - $dire4°"
echo -e "Weather condition - $condi4"
echo ""

rm /tmp/forecast.json
rm /tmp/current.json

fi

exit 0



For this script to work you'll need to install one little tool first. Don't worry, it's easy. Just do this in your terminal,


sudo apt-get install jq


Next go to following website and search for the latitude-longitude of your place,

Tageo WorldWide Index (http://www.tageo.com/index.php?show=search)

Open the script in your favorite text editor. Right at the beginning of the file you will find three empty variables 'latit', 'longi', and 'uneet'. You need to assign latitude of your location to the variable 'latit', longitude of your location to the variable 'longi' and your preferred units system to the variable 'uneet'. There are two main units systems in use. metric and imperial. Which one should you use? If you prefer to measure temperature in Celsius (Centigrade) & distance in Kilometres (km), use metric. And if you prefer to measure temperature in Fahrenheit & distance in Miles (mi), use imperial.

For example for a VSIDO user in London, UK it would look like this,


latit=51.500
longi=-0.117
uneet=metric


And for someone in New York, US it would look like,


latit=40.714
longi=-74.006
uneet=imperial


Save the script after making the necessary changes with the name 'pmwf' somewhere in your $PATH and 'chmod 755' it.
Whenever you wish to see some weather info for your place simply open terminal, type pmwf, hit Enter and you'll have current weather conditions with a 3 day weather forecast right in terminal.

Cheers!!!
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: VastOne on July 22, 2015, 06:13:13 PM
This is a fantastic script hakerdefo... It will allow me to eliminate a nasty but effective plugin from Iceweasel

I appreciate your dedication and work on this, your skills are remarkable

I will also add this to VSIDO and reference this post for setup help

Thank you!
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: PackRat on July 23, 2015, 01:13:43 AM
Well done.  8)
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: Snap on July 23, 2015, 05:46:43 AM
Thanks, hackerdefo.
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: PackRat on November 04, 2015, 12:17:37 AM
Script is broken on my system -

parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
date: invalid date '@'
date: invalid date '@'
date: invalid date '@'
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8
parse error: Invalid numeric literal at line 1, column 8

Location - , :

Current weather conditions:

Temperature -  °C
Atmospheric Pressure -  hPa
Humidity -  %
Wind speed - 0 kph
Wind direction - °
Weather condition -


Forecast for :

Minimum Temperature -  °C
Maximum Temperature -  °C
Atmospheric Pressure -  hPa
Humidity -  %
Wind speed - 0 kph
Wind direction - °
Weather condition -

<snip>


anyone else having this issue?
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: VastOne on November 04, 2015, 12:38:02 AM
I'll test it when I get home a little bit later
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: ozitraveller on November 04, 2015, 04:56:04 AM
http://api.openweathermap.org/data/2.5/weather?lat=$latit&lon=$longi&units=$uneet&mode=json
http://api.openweathermap.org/data/2.5/weather?lat=51.500&lon=-0.117&units=metric&mode=json
returns : Invalid API key. Please see http://openweathermap.org/faq#error401 for more info.

http://api.openweathermap.org/data/2.5/forecast/daily?lat=$latit&lon=$longi&cnt=4&units=$uneet&mode=json
http://api.openweathermap.org/data/2.5/forecast/daily?lat=51.500&lon=-0.117&cnt=4&units=metric&mode=json
returns: Invalid API key. Please see http://openweathermap.org/faq#error401 for more info.

Q: API calls return an error 401
A: Starting from 9 October 2015 our API requires a valid APPID for access. Note that this does not mean that our API is subscription-only now - please take a minute to register a free account to receive a key.

We are sorry for inconvenience but this is a necessary measure that will help us deliver our services to you faster and more reliably.

For FOSS developers: we welcome free and open source software and are willing to help you. If you want to use OWM data in your free software application please register an API key and file a ticket describing your application and API key registered. OWM will review your request lift access limits for your key if used in open source application.

Hope that helps

Ozi


A bit more...

How to use API key in API call

Description:

To get access to weather API you need an API key whatever account you chose from Free to Enterprise.

We keep right to not to process API requests without API key.

API call:

http://api.openweathermap.org/data/2.5/forecast/city?id=524901&APPID={APIKEY}
Parameters:

APPID {APIKEY} is your unique API key
Example of API call:

api.openweathermap.org/data/2.5/forecast/city?id=524901&APPID=1111111111
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: Snap on November 04, 2015, 07:15:16 AM
So this is why it stopped working... Thanks, ozi*
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: PackRat on November 04, 2015, 11:19:05 AM
Thanks ozi

Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: hakerdefo on November 19, 2015, 10:11:38 AM
Thanks a metric ton PackRat and ozitraveller  8)
I've belatedly updated the things. Sorry for the delay  :(

http://vsido.org/index.php?topic=1035.msg11681#msg11681

Cheers!!!
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: PackRat on November 19, 2015, 01:04:15 PM
Script works as advertised.

After signing up, be sure to look at the My Services page of your account to see your limitations (calls per day etc  ....) - look to be pretty generous for just checking the weather; but running a conky on your desktop all day may cause some issues.
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: VastOne on November 19, 2015, 10:15:17 PM
Got the API key ...

Not understanding this from the instructions:

Assign this key to 'apkey' variable in the file

Are we to add/create a variable apkey and then assign the value? What is the context?
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: ozitraveller on November 19, 2015, 11:16:39 PM
Cool hakerdefo!  :) No worries.

Your change looks as I expected. :)


#!/bin/bash

clear

latit=
longi=
uneet=
apkey=

curl -s --connect-timeout 30 -o /tmp/current.json "http://api.openweathermap.org/data/2.5/weather?lat=$latit&lon=$longi&units=$uneet&mode=json&APPID=$apkey"
curl -s --connect-timeout 30 -o /tmp/forecast.json "http://api.openweathermap.org/data/2.5/forecast/daily?lat=$latit&lon=$longi&cnt=4&units=$uneet&mode=json&APPID=$apkey"

...
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions 3 days forecast
Post by: hakerdefo on November 20, 2015, 05:36:53 AM
Quote from: VastOne on November 19, 2015, 10:15:17 PM
Got the API key ...

Not understanding this from the instructions:

Assign this key to 'apkey' variable in the file

Are we to add/create a variable apkey and then assign the value? What is the context?
VastOne, I've updated the script and there is this empty 'apkey' variable in this version of the script right at the top. Just add your API key to it.
Cheers!!!
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: hakerdefo on November 20, 2015, 05:38:40 AM
Quote from: ozitraveller on November 19, 2015, 11:16:39 PM
Cool hakerdefo!  :) No worries.

Your change looks as I expected. :)


#!/bin/bash

clear

latit=
longi=
uneet=
apkey=

curl -s --connect-timeout 30 -o /tmp/current.json "http://api.openweathermap.org/data/2.5/weather?lat=$latit&lon=$longi&units=$uneet&mode=json&APPID=$apkey"
curl -s --connect-timeout 30 -o /tmp/forecast.json "http://api.openweathermap.org/data/2.5/forecast/daily?lat=$latit&lon=$longi&cnt=4&units=$uneet&mode=json&APPID=$apkey"

...

Cheers mate!!!
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: VastOne on November 20, 2015, 07:40:42 PM
Added all data as described in How To thread and all is working perfectly now

Thanks hakerdefo!!!
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: PackRat on December 23, 2015, 04:28:56 PM
I can confirm that this script works with Arch linux

(https://cdn.scrot.moe/images/2015/12/22/SShot-December_1450811039_1366x768.th.png) (https://scrot.moe/image/9dYY)

all the dependencies were available in the Extras so no messing with the AUR (hurray!)
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: PackRat on May 06, 2017, 08:11:47 PM
Your new version isn't working for me - not grabbing the weather data.

Since you're back to actively developing this, I'll make a request  ;D

My script gives:

Current Weather
Forecast for next Day
Forecast for Day 2
Forecast Day 3
Forecast Day 4

It would be more useful (to me anyway) if it was:

Current Weather
Forecast for Current Day
Forecast Next Day
Forecast for Day 2
Foarecast for Day 3

I tried to edit myself once and borked the script really bad.
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: VastOne on May 06, 2017, 08:21:15 PM
^ That works best for me as well...
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: hakerdefo on May 07, 2017, 02:38:47 PM
Will add the forecast for current day asap!
The updated script is not working for you?
Did you edit the script and add the values to the following variables,


local_latitude=
local_longitude=
local_unit=
api_key=


Cheers!!!
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: PackRat on May 07, 2017, 03:51:30 PM
Yes, I just plugged them in from my original script.

That api_key value should still work shouldn't it? Looks like the main change was switching to wget from curl.

ran it in a terminal and get this error:

conky: window type - desktop
conky: drawing to created window (0x1600001)
conky: drawing to double buffer
conky: forked to background, pid is 1369

date: invalid date '@'
date: invalid date '@'
date: invalid date '@'
awk: cmd. line:1: BEGIN {print  * 3.6}
awk: cmd. line:1:               ^ syntax error
awk: cmd. line:1: BEGIN {print  * 3.6}
awk: cmd. line:1:               ^ syntax error
awk: cmd. line:1: BEGIN {print  * 3.6}
awk: cmd. line:1:               ^ syntax error
awk: cmd. line:1: BEGIN {print  * 3.6}
awk: cmd. line:1:               ^ syntax error


Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: PackRat on May 07, 2017, 06:48:17 PM
Fixed a couple typos on my part -

in terminal still failes with:

date: invalid date '@'
date: invalid date '@'
date: invalid date '@'
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: hakerdefo on May 07, 2017, 07:21:57 PM
This is a locale issue. You can easily fix it by adding the following line at the top of the pmwf script,


export LC_TIME=C


Cheers!!!
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: PackRat on May 07, 2017, 08:44:12 PM
No change.
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: hakerdefo on May 07, 2017, 09:03:21 PM
Then try and add the following line right at the top (Right after the interpreter line),


export LC_ALL=C


The beginning of the pmwf will look something like this after the changes,


#!/usr/bin/env bash
###################
export LC_TIME=C
export LC_ALL=C
local_latitude=
local_longitude=
local_unit=
api_key=
local_rm=$(which rm)


Cheers!!!
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: PackRat on May 07, 2017, 10:05:00 PM
^ thanks.

Appears to be a issue with the computer. Just did a clean install the other day.

The new script works fine on my other computers - Void and VSIDO - so it's not a Void v. Debian under the hood issue.

Edit - did areconfiguration of locale, script works as is now
Title: Re: pmwf (Poor Man's Weather Forecast) - current conditions + 3 days forecast
Post by: jedi on May 09, 2017, 12:08:00 AM
Just so happened to have a brand new VSIDO uEFI build going (and loving it!) and have completed all the necessary steps to make it my official 'goto' and as usual, your script works beautifully!  Suddenly minus one conky on the desktop now.  hmmm.  Let's see what happens.  I'm pretty fond of conky...  (not that this can't be utilized fully inside a conky file,  ::) and probably somebody here has already done it!!!)

Beautiful scripting as usual hakerdefoe!  8)

EDIT: Scrot or it didn't happen!

(http://en.zimagez.com/miniature/20170508a.jpg) (http://en.zimagez.com/zimage/20170508a.php)