From f2d1fafc944379c1476b8096f4c2dfea085f82ef Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 27 Feb 2024 13:58:35 -0500 Subject: [PATCH] Updates to weather to make it much more powerful and accurate. --- README.md | 8 ++++++-- src/talking-clock | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0e632a0..ab53a96 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,11 @@ To set a custom voice enter the command as in: -v 'espeak -v en-us+klatt2' Note that rhvoice requires a - followed by the voice name you want, for example, rhvoice-bdl or rhvoice-alan. zipcode and flite_time are incompatable. If you have zipcode set the temperature will not be read while using flite_time. --z --zipcode Postal code: Will speak the temperature along with the time so long as you do not have nospeak set. E.G. -z 90210. +-z --zipcode Postal code: Will speak the temperature along with the time so long as you do not have nospeak set. E.G. -z 90210. With a recent change in the weather provider, you can now use airport codes, or the name of a location, remember to put anything with spaces in quotes, so zipcode="city state". Also, postal codes seem to be less reliable than location names or airport codes. For more information on what types of locations are accepted, run the following command: + +curl https://wttr.in/:help + +Although zipcode should more accurately be called location, the old zipcode is kept for compatibility. With the new changes, it is much more powerful and accurate. talking clock can also read settings from the following files? /etc/talking-clockrc global settings @@ -45,7 +49,7 @@ sound=play -q soundpack=/home/USER/thunderstorm chime=true speak=true -zipcode=90210 +zipcode="Raleigh North Carolina" Soundpack should be the path to a directory. Do not include the trailing / talking-clock adds it for you. voice=espeak -v en-us+klatt2 -s 300 Be careful when using custom voice commands, if it is not valid the program will not work. You do not have to specify parameters for voice commands if you want to use the defaults. You can use voice=espeak (this is the default), voice=cepstral, voice=speech-dispatcher, voice=rhvoice-bdl, or voice=festival. diff --git a/src/talking-clock b/src/talking-clock index 1a5f4fe..56746d5 100755 --- a/src/talking-clock +++ b/src/talking-clock @@ -356,6 +356,8 @@ if [ "$speakTime" == "true" ] ; then fi #Add temperature if zipcode is set if [ -n "$zipcode" ] ; then + zipcode="${zipcode//[[:space:]]/+}" + zipcode="${zipcode#ip}" temperature="$(curl -s "https://wttr.in/${zipcode}?format=%t%20degrees%20and%20%C")" temp="${temperature//[^-[:digit:]]/}" temperature="${temp} ${temperature#* }"