Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Anybody need any work?
#21
It supports every 15 seconds.
Reply
#22
Do you really need it to be that quick, or would once a minute work for your needs?
Dean Roddey
Software Geek Extraordinaire
Reply
#23
The only driver I'm interested in at this point that we don't have is for the Irrigation Caddy, although that won't be needed again until the Spring.
Reply
#24
OK, remind me again then if we haven't already gotten to it.
Dean Roddey
Software Geek Extraordinaire
Reply
#25
Dean Roddey Wrote:Do you really need it to be that quick, or would once a minute work for your needs?

Once a minute would probably be fine for generating graphs.

my public channel is here: https://thingspeak.com/channels/11954

I am updating it using this URL:https://api.thingspeak.com/update?api_ke...&field1=18
Reply
#26
OK, I'll take a look at it tomorrow and let you know what I think.

Ultimately, this is the kind of thing that sort of cries out for something that's been on the list for a while but we haven't been able to get to it. Basically it's something that's not really a driver (which isn't optimal for watching other drivers' fields) and not really a scheduled event. Something I've called 'Monitors', or something like that, which would probably run in the event server and would just register a set of fields it wants to watch and would be called any time one changes, and possibly every so often if no fields have changed. This kind of thing would be the perfect application for that kind of thing.

Oh well, maybe we'll be able to do it for 4.7 and then we could move this thingy over to that.
Dean Roddey
Software Geek Extraordinaire
Reply
#27
Okay, one thing to note is that everything is open source. I am working on getting the sever installed on a Rpi or linux VM to keep the data local.
Reply
#28
Actually, let's wait until post-4.6. JKish has been after me to do the Monitor thing for a while, for things like his irrigation stuff. So I'll tackle getting a basic implementation of that in place, it can be elaborated more over time, and then we can do this thingy in terms of that.
Dean Roddey
Software Geek Extraordinaire
Reply
#29
Leaving this here for posterity. Its a python script that posts smarthings data to thingspeak.

http://amazingrcvideos.blogspot.com/2013...cript.html

Code:
# Import module statements
import re, sys, httplib, urllib
from bs4 import BeautifulSoup
from mechanize import ParseResponse, urlopen, urljoin

# To read the information about a device, you will need the proper device ID. Enter device ID from the web URL in place of XXXXXXXXXX.
if len(sys.argv) == 1:
    uri = "https://graph.api.smartthings.com/device/show/XXXXXXXXXX"
else:
    uri = sys.argv[1]

# Open URL and parse out information to see what forms are required to login
response = urlopen(urljoin(uri, ""))
forms = ParseResponse(response, backwards_compat=False)
form = forms[0]
# Uncomment line below to print out the form names used for logging in
#print form

# Enter information for username and password. Must put information in quotes.
form["j_username"] = "username"
form["j_password"] = "password"

# Send login information and read webpage data
text_data = urlopen(form.click()).read()

# START DATA PARSING
# Get HTML code of web page to parse through
soup = BeautifulSoup(text_data)

# Find line that has desired data. This case grabs the line with temperature.
text = soup.find_all(text=re.compile("temperature"))

# Get indices to parse out desired data
start_idx = text[0].index(':')+2
end_idx = text[0].index('F')-1

# Store information in a variable
var1 = text[0][start_idx:end_idx]

# Repeat for other sensors
text_data = urlopen('https://graph.api.smartthings.com/device/show/YYYYYYYY').read()
soup = BeautifulSoup(text_data)
text = soup.find_all(text=re.compile("temperature"))
start_idx = text[0].index(':')+2
end_idx = text[0].index('F')-1
var2 = text[0][start_idx:end_idx]

# SEND DATA TO THINGSPEAK
# Package data together in the next line. The temp data is low by about 4 degrees so I added 4. Get your API KEY from the Channel you set up on ThingSpeak.
params = urllib.urlencode({'field1': str(int(var1)+5), 'field2': str(int(var2)+5), 'key':'YOUR API KEY'})

# Other code to send information to ThingSpeak
headers = {"Content-type": "application/x-www-form-urlencoded","Accept":"text/plain"}
conn = httplib.HTTPConnection("api.thingspeak.com:80")
conn.request("POST", "/update", params, headers)
response = conn.getresponse()
#print response.status, response.reason
data = response.read()
conn.close()
Reply
#30
I've made some progress on the event monitor thing. I should have a viable first cut before long. Maybe this can be the inaugural flight for it or something.
Dean Roddey
Software Geek Extraordinaire
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)