avryhof / ambient_api

Python module for accessing the Ambient Weather API
MIT License
32 stars 18 forks source link

get_data() responding with { } or None #11

Closed apowers5321 closed 1 year ago

apowers5321 commented 1 year ago

Not sure why this is occurring, as this works fine on my PC and my laptop seems to draw empty data. Followed the code provided. I'm still a novice coder at best so I'm still learning to troubleshoot this sort of stuff.

Screenshot 2023-05-25 155441

avryhof commented 1 year ago

If it works on your PC, but not on your laptop, my first guess would be to make sure you migrated your API credentials correctly, and didn't do something like copy over invisible characters.

Following that, I would set the AMBIENT_LOG_LEVEL to debug, and watch your console. The HTTP Status codes return different messages. It might be helpful to see if you are rate limited, or something.

That's where I would start.

apowers5321 commented 1 year ago

I will definitely double check the credentials, and as for setting the log level to debug, is that set as another environment variable or is that an argument within the API? (I'm at best a novice coder and know much about API's).

avryhof commented 1 year ago

The easiest way is to pass it as a keyword argument

api = AmbientAPI(log_level="debug")

If debug doesn't work, you can also pass in console, which will just dump the errors with print() for old-school debugging :)

There are a few different arguments you can fiddle with.

Anything that uses kwargs.get(...) in the constructor can be passed in that way.

https://github.com/avryhof/ambient_api/blob/08194b5d8626801f2c2c7369adacb15eace54802/ambient_api/ambientapi.py#L94

apowers5321 commented 1 year ago

Thanks for the help! I was able to diagnose and fix the issue. Just needed some extra time to collect the data before outputting it to avoid the 429 limit.