JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.02k stars 2.37k forks source link

OpenWeatherMap segments are not working #1947

Closed bjagasia closed 2 years ago

bjagasia commented 2 years ago

Code of Conduct

What happened?

Hi,

I can't seem to get the Open Weather Map segment to work. I've tested my API key already and upped the timeout on my profile. I'm currently using the sonicboom_light.json theme. I've added the config below:

{ "powerline_symbol": "\ue0b6", "foreground": "#ffffff", "background": "#389c09", "invert_powerline": true, "properties": { "apikey": "377f51bf77a0f614ef980d1e5bcfa2f9", "location": "BASTOGNE,BE", "units": "imperial", "enable_hyperlink": true, "http_timeout": 500, "cache_timeout": 15, "template": "[{{.Weather}} ({{.Temperature}}{{.UnitIcon}})]({{.URL}})" }, "type": "owm", "style": "powerline" },

Theme

sonicboom_light.json

What OS are you seeing the problem on?

Windows, Linux

Which shell are you using?

bash, powershell

Log output

Windows Powershell 7:

Version: 7.41.0

Segments:

ConsoleTitle(false)  -   8 ms - 
root(false)          -   0 ms - 
os(true)             -   0 ms -   
path(true)           -   0 ms -   
git(false)           -   3 ms - 
executiontime(true)  -   1 ms -  0s 
owm(false)           -   0 ms - 
session(true)        -   0 ms -  bjagasia  BJAGASIA-DIGITALSTORM
time(true)           -   0 ms -   9:58:28 AM 
exit(true)           -   0 ms - ﬌ 

Run duration: 14.4654ms

Cache path: C:\Users\Admin\AppData\Local\oh-my-posh

Logs:

2022/03/19 09:58:28 Flags duration: 0s, args: 
2022/03/19 09:58:28 Flags duration: 0s, args: 
2022/03/19 09:58:28 debug: Getenv

2022/03/19 09:58:28 Getenv duration: 0s, args: OMP_CACHE_DISABLED
2022/03/19 09:58:28 Root duration: 0s, args: 
2022/03/19 09:58:28 Shell duration: 7.8006ms, args: 
2022/03/19 09:58:28 ErrorCode duration: 0s, args: 
2022/03/19 09:58:28 IsWsl duration: 0s, args: 
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 debug: Home
C:\Users\Admin
2022/03/19 09:58:28 PathSeparator duration: 0s, args: 
2022/03/19 09:58:28 PathSeparator duration: 0s, args: 
2022/03/19 09:58:28 User duration: 0s, args: 
2022/03/19 09:58:28 Host duration: 0s, args: 
2022/03/19 09:58:28 GOOS duration: 0s, args: 
2022/03/19 09:58:28 TemplateCache duration: 7.8006ms, args: 
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 debug: Home
C:\Users\Admin
2022/03/19 09:58:28 Root duration: 0s, args: 
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 debug: Home
C:\Users\Admin
2022/03/19 09:58:28 GOOS duration: 0s, args: 
2022/03/19 09:58:28 TemplateCache duration: 0s, args: 
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 debug: Home
C:\Users\Admin
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 Flags duration: 0s, args: 
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 debug: Home
C:\Users\Admin
2022/03/19 09:58:28 GOOS duration: 0s, args: 
2022/03/19 09:58:28 GOOS duration: 0s, args: 
2022/03/19 09:58:28 PathSeparator duration: 0s, args: 
2022/03/19 09:58:28 Flags duration: 0s, args: 
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 debug: Home
C:\Users\Admin
2022/03/19 09:58:28 GOOS duration: 0s, args: 
2022/03/19 09:58:28 GOOS duration: 0s, args: 
2022/03/19 09:58:28 PathSeparator duration: 0s, args: 
2022/03/19 09:58:28 PathSeparator duration: 0s, args: 
2022/03/19 09:58:28 GOOS duration: 0s, args: 
2022/03/19 09:58:28 IsWsl duration: 0s, args: 
2022/03/19 09:58:28 StackCount duration: 0s, args: 
2022/03/19 09:58:28 TemplateCache duration: 0s, args: 
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 debug: Home
C:\Users\Admin
2022/03/19 09:58:28 GOOS duration: 0s, args: 
2022/03/19 09:58:28 HasCommand duration: 3.6287ms, args: git.exe
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 error: HasParentFilePath
CreateFile C:\.git: The system cannot find the file specified.
2022/03/19 09:58:28 HasParentFilePath duration: 0s, args: .git
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 debug: Home
C:\Users\Admin
2022/03/19 09:58:28 ExecutionTime duration: 0s, args: 
2022/03/19 09:58:28 TemplateCache duration: 0s, args: 
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 debug: Home
C:\Users\Admin
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 debug: Home
C:\Users\Admin
2022/03/19 09:58:28 debug: Getenv

2022/03/19 09:58:28 Getenv duration: 0s, args: SSH_CONNECTION
2022/03/19 09:58:28 debug: Getenv

2022/03/19 09:58:28 Getenv duration: 0s, args: SSH_CLIENT
2022/03/19 09:58:28 TemplateCache duration: 0s, args: 
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 debug: Home
C:\Users\Admin
2022/03/19 09:58:28 TemplateCache duration: 0s, args: 
2022/03/19 09:58:28 debug: Pwd
C:\Users\Admin
2022/03/19 09:58:28 Pwd duration: 0s, args: 
2022/03/19 09:58:28 debug: Home
C:\Users\Admin
2022/03/19 09:58:28 ErrorCode duration: 0s, args: 
2022/03/19 09:58:28 TemplateCache duration: 0s, args: 
2022/03/19 09:58:28 TemplateCache duration: 0s, args: 
2022/03/19 09:58:28 debug: Getenv
C:\Users\Admin\AppData\Local
2022/03/19 09:58:28 Getenv duration: 0s, args: LOCALAPPDATA
2022/03/19 09:58:28 CachePath duration: 0s, args: 

Linux Ubuntu Shell did not return anything.
bjagasia commented 2 years ago

Just as I submitted the issue, I changed some colors around and suddenly the weather module showed up. I'm not exactly sure what I did, trying to retrace my steps but the weather module finally seems to be working after changing some colors around in another text segment. Weird..

JanDeDobbeleer commented 2 years ago

@bjagasia I'll check as it doesn't seem to do anything. On mobile right now and I need a bigger display to see what the issue might be 😬

bjagasia commented 2 years ago

No worries! Thank you so much. Oh My Posh is great! Appreciate the prompt response. Got it working, definitely was something with the colors for me!

JanDeDobbeleer commented 2 years ago

@bjagasia can you set the timeout really high? As it works on my end.

JanDeDobbeleer commented 2 years ago

This is the segment I added:

{
  "powerline_symbol": "\ue0b0",
  "foreground": "#ffffff",
  "background": "#389c09",
  "properties": {
    "apikey": "377f51bf77a0f614ef980d1e5bcfa2f9",
    "location": "BASTOGNE,BE",
    "units": "metric",
    "http_timeout": 500,
    "cache_timeout": 15,
    "template": " {{ url (printf \"%s%.f%s\" .Weather .Temperature .UnitIcon) .URL }} "
  },
  "type": "owm",
  "style": "powerline"
}
image
bjagasia commented 2 years ago

Hi, yes -- I had the timeout really high, but what fixed it for me was changing the colors around in another segment. Really weird, but everything seems to be good now. Thank you so much! I'll close out the ticket for now :)

bmkaiser commented 2 years ago

I also found that you have to enter the City, State, and Country for the location. If you use only the City and State, it won't return anything.

For example, BOSTON,MA doesn't work, but BOSTON,MA,US does work.

github-actions[bot] commented 9 months ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.