[問題] LINE bot回傳數值的問題

作者: TheSims4 (模擬市民4)   2022-01-04 17:03:05
不好意思我是Python新手
目前在做LINE bot回傳raspberry pi溫度監測數值的作業
網路上的資源大多都教直接回傳原訊息
我的是收到user傳送來的特定字元時會偵測sensor的溫度並回傳
因為不太熟 app跟functino一直想不出來 想請各位大神指點
app.py
reply = event.message.text
if message.count('temp'):
function.temperature()
temperature = function.temperature
reply = temperature
function.py
dht = adafruit_dht.DHT(board.D17)
def temperature():
temperature = dht.temperature
print (temperature)
return temperature
======
function.py的print是為了驗證能顯示出來結果真的可以在設備上看到溫度
但是執行時有這個錯誤不知道怎麼排除
Object of type function is not JSON serializable
作者: miku3920 (初音ミク)   2022-01-04 17:06:00
回傳格式錯誤你仔細檢查看看哪裡打錯了有可能是 key 沒打到
作者: lycantrope (阿寬)   2022-01-04 18:31:00
temperature = function.temperature() # call funcfunction.temperature()可以不用叫兩次

Links booklink

Contact Us: admin [ a t ] ucptt.com