Hi,
I have a raspberry pi with a DHT22 temperature sensor on it. And I had it connect to
endpoints_url = “https://graph.api.smartthings.com/api/smartapps/endpoints/%s?access_token=%s” % (client, access_token)
But I understand this has now been deprecated. Does anyone know the updated site and/or method to connect this device now?
Thank you,
P
Hello @skiwithpete, Could you please provide me with more information/context? How are you integrating your device with SmartThings? Thanks
@Ivan_Luis_Falleau Below is the code I had been using, as you can see, since 2021.
When I plugged the device in and ran it again, I get error 410.
#!/usr/bin/python3
#version 6 - 2021.12.24
#crontab -e
#*/5 * * * * python3 /home/pi/pitherm1.py
import sys
import math
import glob
import re
from io import BytesIO
import json
import pprint
import requests
import time
from datetime import datetime
import subprocess
import Adafruit_DHT
DHT_SENSOR = Adafruit_DHT.DHT22
DHT_PIN = 4
#client id and client secret
client = 'removed for privacy'
access_token='removed for privacy'
niters = 16
interval = 10
now = datetime.now()
run_time = time.time()
start_time = now.strftime("%H:%M:%S")
print("Start Time =", start_time)
def main():
old_temp = -999999999.99
endpoints_url = "https://graph.api.smartthings.com/api/smartapps/endpoints/%s?access_token=%s" % (client,>
r = requests.get(endpoints_url)
if (r.status_code != 200):
print("Error: " + str(r.status_code))
else:
theendpoints = json.loads( r.text )
for counter in range(niters, 0, -1):
humidity, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
temp_c = float("{0:0.1f}".format(temperature))
temp_f = float("{:.2f}".format(temp_c * 9.0 / 5.0 + 32.0))
print (temp_c,temp_f)
for endp in theendpoints:
uri = endp['uri']
temp_url = uri + ("/update/%.2f/F" % temp_f)
headers = { 'Authorization' : 'Bearer ' + access_token }
if ( round(temp_f, 2) != round(old_temp, 2) ):
r = requests.put(temp_url, headers=headers)
old_temp = temp_f
time.sleep(interval)
print ("looping")
main()
end_time = time.strftime("%H:%M:%S")
print("--- %s seconds ---" % (time.time() - run_time))
print ("exit")
When I researched it, it seems graph.api.smartthings was deprecated.
Hence the question.
Hello @skiwithpete, Thanks for the shared data. I was checking and definitely is deprecated, now you have the new API which you can take a look at and try from there.
Also, I noticed that you are using SmartApps. So, you may take a look at this page too.
Hope this may be helpful to you