Moin zusammen,
ich habe ein Python-Script zusammengebastelt um die Temperatur und die Luftfeuchtigkeit mit xively auszuwerten, ich bekomme aber immer folgenden Fehler beim Ablauf:
Code
Traceback (most recent call last):
File "xively.py", line 4, in <module>
import xively
File "/home/pi/lol_dht22/xively.py", line 36, in <module>
api = xively.XivelyAPIClient(API_KEY)
AttributeError: 'module' object has no attribute 'XivelyAPIClient'
Hier einmal der vollständige Code des Scripts:
Code
#!/usr/bin/env python
import os
import re
import xively
import subprocess
import sys
import time
# Xively variables specific to my account.
API_KEY = 'key'
FEED_ID = 'feed'
# Continuously read data from the DHT22 sensor and upload
# Run the DHT program to get the humidity and temperature readings!
while True:
output = subprocess.check_output(["./loldht"]);
# print output
matches = re.search("Temperature =\s+([0-9.]+)", output)
if (not matches):
time.sleep(3)
continue
temp = float(matches.group(1))
# search for humidity printout
matches = re.search("Humidity =\s+([0-9.]+)", output)
if (not matches):
time.sleep(3)
continue
humidity = float(matches.group(1))
print "Temperature: %.1f C" % temp
print "Humidity: %.1f %%" % humidity
# Initialize Xively library and fetch the feed
api = xively.XivelyAPIClient(API_KEY)
feed = api.feeds.get(FEED_ID)
feed.datastreams = [
xively.Datastream(id='temperature', current_value=temp),
xively.Datastream(id='humidity', current_value=humidity),
]
# Upload the data into the Xively feed
feed.update()
# Wait 30 seconds to avoid flooding the Xively feed
time.sleep(30)
Alles anzeigen
Ich konnte den Fehler leider nicht ausmachen.
Ein User hatte auf stockoverflow.com einen Thread mit genau dem gleichen Fehler eröffnet, aber anscheinend wieder geschlossen. Die Seite zum Thread lässt sich nur noch per Google-Cache erreichen.
Hier einmal der Link:
Klick
Gruß