Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import forecastio
- from influxdb import InfluxDBClient
- client = InfluxDBClient(host='YOUR_IP',
- port=8086,
- database='YOURDB',
- username='username',
- password='password',
- verify_ssl=False)
- api_key = "forecast.io api-key"
- lat = -80.253391
- lng = -59.897461
- forecast = forecastio.load_forecast(api_key, lat, lng)
- current = forecast.currently()
- temp = float(current.temperature)
- humidity = float(current.humidity * 100)
- points = []
- point = {
- "measurement": 'temp',
- "tags": {
- "sensor": "Outside-forecastio"
- },
- "fields": {
- "value": temp
- }
- }
- points.append(point)
- point = {
- "measurement": 'humidity',
- "tags": {
- "sensor": "Outside-forecastio"
- },
- "fields": {
- "value": humidity
- }
- }
- points.append(point)
- client.write_points(points)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement