-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #1 - fixes for new api.weatherstem.com
- Loading branch information
loraxipam
committed
Aug 17, 2020
1 parent
cff27b0
commit 54d2394
Showing
3 changed files
with
17 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.swp | ||
weatherstem.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,16 @@ When you just want a quick peek at the local weather, here's a tool to query wea | |
|
||
You'll need to create a small config file with your weatherstem.com API key and the local domain URL that you will use. You might have one or two favorite stations to query, so you will need their short name. Here's the example config file. Call it `weatherstem.json` and put it in your `.config` directory. Or leave it in your current directory. Or put it in `~/.weatherstem.json` and it will work. | ||
|
||
`{"version":"2.0","api_key":"yourKeyGoesHere","stations":["firstOne","maybeTwo","doubtfulThree"],"api_url":"https://domain.weatherstem.com","me":{"lat":45.0,"lon":-123.0}}` | ||
``` | ||
{"version": "3.0", | ||
"api_key": "yourKeyGoesHere", | ||
"stations": | ||
["[email protected]", | ||
"[email protected]", | ||
"[email protected]"], | ||
"api_url": "https://api.weatherstem.com/api", | ||
"me": {"lat": 45.0, "lon": -123.0}} | ||
``` | ||
|
||
FYI, if you run it with no config file, it will complain and show you an example as above. Cut and paste for the win. | ||
|
||
|
@@ -36,4 +45,4 @@ If you want boring compass rose directions, use `-rose`. | |
|
||
I use the alternate compass rose because I love to say the word "Tramontana." | ||
|
||
If you want to query stations in different domains, you'll need two directories with separate config files. | ||
The new (Aug 2020) v1 API station ID format allows querying stations in different domains using the same config file. :raised_hands: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ import ( | |
|
||
const ( | ||
// Version of the configuration file layout | ||
configSettingsVersion = "2.0" | ||
configSettingsVersion = "3.0" | ||
) | ||
|
||
// WeatherInfo struct | ||
|
@@ -300,7 +300,9 @@ func (config *configSettings) getConfigSettings(inputFile string) (err error) { | |
log.Panicln("Cannot unmarshal config", inputFile) | ||
} | ||
} else if configVersion <= configSettingsVersion { | ||
log.Printf("WARNING: Using a version %s config file in a version %s app. Your location could become NYC.\n", configVersion, configSettingsVersion) | ||
log.Printf("WARNING: Using a version %s config file in a version %s app.\n", configVersion, configSettingsVersion) | ||
log.Printf("Version 2 added your geolocation. Your location could become NYC.\n") | ||
log.Printf("Version 3 uses the Aug 2020 API v1 '[email protected]' syntax.\n") | ||
err = json.Unmarshal(configJSON, &config) | ||
if err != nil { | ||
log.Panicln("Cannot unmarshal config", inputFile) | ||
|
@@ -470,7 +472,7 @@ func main() { | |
err = findConfigSettings(&myConfig) | ||
if err != nil { | ||
log.Println("Config file not found. It should look like this and be in 'weatherstem.json', either in the current or in your $HOME/.config directory.") | ||
log.Println(`{"version":"2.0","api_url":"https://domain.weatherstem.com/api","api_key":"yourApiKey","stations":["station1","stationX"],"me":{"lat":43.14,"lon":-111.275}}`) | ||
log.Println(`{"version":"3.0","api_url":"https://api.weatherstem.com/api","api_key":"yourApiKey","stations":["station1@domain.weatherstem.com","stationX@domain.weatherstem.com"],"me":{"lat":43.14,"lon":-111.275}}`) | ||
os.Exit(3) | ||
} | ||
|
||
|