我在使用此代码将频道ID和值上传到xively时遇到问题,有人可以就我出错的地方向我提供一些指导吗?
temp = read_temp()
data = json.dumps({"version":"1.0.0", "datastreams":[{"id":"SolarFlow","current_value":temp_0}]})
data = json.dumps({"version":"1.0.0", "datastreams":[{"id":"SolarReturn","current_value":temp_1}]})
data = json.dumps({"version":"1.0.0", "datastreams":[{"id":"BufferIn","current_value":temp_2}]})
data = json.dumps({"version":"1.0.0", "datastreams":[{"id":"BufferOut","current_value":temp_3}]})
data = json.dumps({"version":"1.0.0", "datastreams":[{"id":"UFH_Flow","current_value":temp_4}]})
data = json.dumps({"version":"1.0.0", "datastreams":[{"id":"GSHP_Flow","current_value":temp_5}]})
data = json.dumps({"version":"1.0.0", "datastreams":[{"id":"GSHP_WellReturn","current_value":temp_6}]})
data = json.dumps({"version":"1.0.0", "datastreams":[{"id":"GSHP_LoopsReturn","current_value":temp_7}]})
data = json.dumps({"version":"1.0.0", "datastreams":[{"id":"HotWaterTank","current_value":temp_8}]})
data = json.dumps({"version":"1.0.0", "datastreams":[{"id":"HotWaterPreHeatTank","current_value":temp_9}]})
with open("temp.tmp", "w") as f:
f.write(data)
subprocess.call(['curl --request PUT --data-binary @temp.tmp --header "X-ApiKey: AR4soQUW2uG3t2pTVl3FVPPKZPfH66tJ0Z8SjBlEzhvFXpIK" http://api.cosm.com/v2/feeds/2002766727'], shell=True)
os.remove("temp.tmp")
干杯
史蒂夫
答案 0 :(得分:0)
实现此目标的最佳方法是使用Xively提供的official Python module。
以下几个原因没有按照你刚才描述的方式进行: