Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weather API question #9

Open
veloraptor opened this issue Apr 23, 2023 · 2 comments
Open

Weather API question #9

veloraptor opened this issue Apr 23, 2023 · 2 comments

Comments

@veloraptor
Copy link

just loaded weather.jsx into widget folder. OpenWeather API key inserted, but widget fails with 176 {data.current.feels_like.toFixed(1)}° listed with "undefined is not an object" comment

@wcage03
Copy link

wcage03 commented Nov 20, 2023

I got the same error. The problem for me was the geolocation lookup. I pulled that out and replaced that functionality with static values in the config section at the top. Got the Lat and Lon for my location from https://www.latlong.net/.

Here are the changes that I made that fixed it for me. In the Options section at the top of weather.jsx I added these values
I could not get the geolocation to work on my computer so I entered the values for my city here.

// enter the values for your location
const lat = 33.54
const lon = -86.78
const address = 'Birmingham, AL'

Obviously put in what is appropriate for your location. I stripped down the command function to eliminate the calls for the geolocation. Replace the existing function with the following

export const command = (dispatch) => {
  const proxy = 'http://127.0.0.1:41417'
  const server = 'https://api.openweathermap.org'
  const path = `/data/3.0/onecall?lat=${lat}&lon=${lon}&exclude=minutely&appid=${KEY}&units=${UNITS}&lang=${LANG}`

  fetch(`${proxy}/${server}${path}`)
    .then((response) => {
      return response.json()
    })
    .catch((error) => {
      return dispatch({ type: 'FETCH_FAILED', error: error })
    })
    .then((data) => {
      return dispatch({
        type: 'FETCH_SUCCEDED',
        data: data,
        city: address
      })
    })
}

You should note the code is the same as before, but the geolocation calls are removed.
Lastly, the widget makes use of the interaction feature. It will open up with only the hourly forecast showing with a triangle for a dropdown. You will need to enable interaction in the Ubersicht preferences to be able to open up and see the 7 day forecast.

I hope this helps. I am trying to figure out how to get the geolocation to work. I did the permissions to allow Ubersicht access to the location services, but that didn't solve it for me. If I figure that out, I will make the changes and post.

@veloraptor
Copy link
Author

veloraptor commented Nov 29, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants