Weather API Client
A Python class (and support files) to link to the weather API so that one can submit weather readings easily Functions include:
- Easy setup through single registration file with token authentication
- Single line submision of a reading
- Error commincation back to your script for easy debugging
- Saving ability to sve readings in exportable JSON format for importing into other software
- Ensure that database is setup as per Database file.
- Run register.py
- Submit the credential / password for creating a new user on your weather system (setup when installing server side files)
- Provide the Device Name (e.g. Raspbery Pi), Then Version (e.g. Model 1/3/4), then its Location (e.g. attic, lounge, outside etc)
- The system will generate an identifier (a key for the readings - useful in case you reinstall later on and want to carry on readings after re-registration)
- Either accept (N) or create a new identifier (Y)
- Proceed
- Test this setup by running test_api_setup.py
- import weather_api
- create an instance:
- api = weather_api.API()
- if api.ready == True: You're ready to go using one of the following files / methods
- Template File for this: test_save_reading.py
- import weather_api, create an instance,
- Then:api.save_reading( paramater, value )
- Then: api.save()
- This saves the readings to a local file
- This does not require network access
- Template File for this: test_load_saved_readings.py
- This will load and print out the saved readings
- This requires a network connection
- Template File for this: test_send_reading.py
- Very simple mechanism to just send one reading
- Just pass (paramater, reading) and it will send
- Template File for this: test_send_multiple.py
- This is for sending multiple readings together (will have the same timestamp
- Anticipate usage will be for taking e.g. Temperature + Humidity at the same time and then send them together
- Not for, for example, storing multiple readings over time and then send them together as their timestamps will not be sent correctly
- Template File for this: test_send_saved_readings.py
- This will open the saved_readings.json file, load in the readings, and then attempt to send them
- This will either lead to Success - in which case they have all been sent
- Or it will lead to failure either due to a server issue OR
- If you have saved a parameter that your server is not configured to accept, it will let you know
- It will then offer you the option of saving the "failed readings" into a new json file for later manipulation
- If you choose not to do this, the failed readings will be lost.
- temperature
- humidity