Closed EdwinB12 closed 9 months ago
@mhauru wrote a lovely minimal use-case of how to implement the weather ingress:
import requests from ingress_utils import backend_call, backend_login CONST_OPENWEATHERMAP_FORECAST_URL = "https://api.openweathermap.org/data/3.0/onecall?lat=0&lon=0&units=metric&appid=<INSERT API KEY HERE>" response = requests.get(CONST_OPENWEATHERMAP_FORECAST_URL) openweather_data = response.json() print(openweather_data) access_token = backend_login(USERNAME, PASSWORD) sensor_type_payload = { "name": "Weather", "measures": [...], } backend_call( "post", "/sensor/insert-sensor-type", sensor_type_payload, access_token=access_token ) sensor_payload = { "sensor_type": "Weather", "unique_identifier": "The Weather Sensor", "name": "blah", ..., } backend_call( "post", "/sensor/insert-sensor", sensor_type, access_token=access_token ) readings_payload = { "unique_identifier": "The Weather Sensor", "readings": ..., "timestamps": ..., } backend_call( "post", "/sensor/insert-sensor-readings", readings_payload, access_token=access_token )
With a quick clean up and some comments, we could upload this as either an example or a readme maybe?
@mhauru wrote a lovely minimal use-case of how to implement the weather ingress:
With a quick clean up and some comments, we could upload this as either an example or a readme maybe?