Download Events Data


(Carlo Mendoza) #1

Is there a way to get the Events list data from SmartThings? Can I export the data from the time I started using SmartThings?


#2

I believe it’s only kept for 7 days.

@Dianoga ?


(Cyril Peponnet) #3

From http://docs.smartthings.com/en/latest/ref-docs/device-ref.html?highlight=days

Event history is limited to the last seven days. Methods that query devices for event history will only query the last seven days. This will be called out in those methods, but is good to be generally aware of.


(Anthony S.) #4

I’m working on something that sends all of smartthings event data to a local server in your home for storage. I’ve got almost 400,000 events from about 45 days of event logging. I created an api to query the data and return JSON, also an alternative oData service to allow easy connection to excel. I really wanted to create a web front end with charts to consume the data but I’m not that great at web design yet. If enough people are interested I am thinking about packaging it up for people to run and install on local PC or server in their home. It would be even better if I could use a hubAction to post the data to the web server. Instead I had to open up the web api to the actually web for it to be accessible by smartthings.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #5

There’s a commercial option … perhaps worth the reasonable price, depending on the purpose of the data collection…


(Anthony S.) #6

Yea i tried it. It’s great, but I like to store my own data and I always like to reinvent the wheel for learning/experience sake :wink:


(Carlo Mendoza) #7

Hi Anthony,

I’m interested in your solution. Are you making it accessible for whoever’s interested?


(Anthony S.) #8

Hello Carlo,

I have no reason I can’t share it. I just need to package it up some before I do. It may take me a bit as this is a busy week at work :slight_smile:


(MelR) #9

Hi Anthony

Just wondering if you were able to package your solution up. I am very interested in being able to store my event logs locally for analysis later.


(Anthony S.) #10

I apologize for not getting this done.
I have been dealing with a project at work. Add to that I’ve been trying to figure out why I can’t control any of my Devices. I have a new hub coming tomorrow. As soon as I get some time I will package it up for you.


(MelR) #11

Hi Anthony

Just checking in to see if you had time to package up your solution.


(Anthony S.) #12

I’m sorry. I’ve been off to a rough start. I will look into this today and see what I can do.


(MelR) #13

Hi Anthony

Any way i can help with this?


#14

So I’ve been trying to tackle this as well. As mentioned above, Initial State does it pretty well, but unless you pay $6 a month you can only see 24 hrs’ worth of data at a time. I want to be able to download the raw data for as far back as possible and work with it in excel, so Initial State won’t due because I’m not willing to subscribe to their pay option.

I came across GroveStreams which is a lot like Initial State, but there doesn’t appear to be a limit on how much data is accessible for their free tier. (I’ve only been using it for a day so far.) They’ve got a smartapp that’s setup to collect temperature and contact sensor data ( here’s a guide for setting it up, as is ). It’s pretty simple, and I was able to modify it to send Thermostat Operating State and Heating Setpoint. Below is the original code with my additions for thermostat set point and operating state. I found another iteration of his smartapp with a lot more data streams (still no thermostat operating state and setpoint though)

     /**
      * SmartThings example Code for GroveStreams
      * A full "how to" guide for this example can be found at https://www.grovestreams.com/developers/getting_started_smartthings.html
      *
      * Copyright 2015 Jason Steele
      *
      * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
      * in compliance with the License. You may obtain a copy of the License at:
      *
      * http://www.apache.org/licenses/LICENSE-2.0
      *
      * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
      * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
      * for the specific language governing permissions and limitations under the License.
      *
      */
  
     definition(
                 name: "GroveStreams w/ Thermostat Info",
                 namespace: "JasonBSteele",
                 author: "Jason Steele",
                 description: "Log to GroveStreams",
                 category: "My Apps",
                 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
                 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
                 iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
  
     preferences {
         section("Log devices...") {
                 input "contacts", "capability.contactSensor", title: "Doors open/close", required: false, multiple: true
                 input "temperatures", "capability.temperatureMeasurement", title: "Temperatures", required:false, multiple: true
                 input "thermostats", "capability.thermostat", title: "Thermostats", required: false, multiple: true
        }
  
         section ("GroveStreams Feed PUT API key...") {
                 input "channelKey", "text", title: "API key"
         }
     }
  
     def installed() {
         initialize()
 }
  
 def updated() {
         unsubscribe()
         initialize()
 }
  
 def initialize() {
         subscribe(temperatures, "temperature", handleTemperatureEvent)
         subscribe(contacts, "contact", handleContactEvent)
 		subscribe(thermostats,"heatingSetpoint", handleHeatingSetpointEvent)
 		subscribe(thermostats, "thermostatOperatingState", handleThermostatOperatingStateEvent)
         
 //        devices.capabilities.each {cap ->
 //    log.debug "This device supports the ${cap.name} capability" }
 }
  
 def handleTemperatureEvent(evt) {
         sendValue(evt) { it.toString() }
 }
  
 def handleContactEvent(evt) {
         sendValue(evt) { it == "open" ? "true" : "false" }
 }
 
 def handleHeatingSetpointEvent(evt) {
 		sendValue(evt) { it.toString() }
 }
  
 def handleThermostatOperatingStateEvent(evt) {
 		sendValue(evt) { it.toString() }
 } 
  
 private sendValue(evt, Closure convert) {
         def compId = URLEncoder.encode(evt.displayName.trim())
         def streamId = evt.name
         def value = convert(evt.value)
        
         log.debug "Logging to GroveStreams ${compId}, ${streamId} = ${value}"
        
         def url = "https://grovestreams.com/api/feed?api_key=${channelKey}&compId=${compId}&${streamId}=${value}"
         def putParams = [
                 uri: url,
                 body: []]
  
         httpPut(putParams) { response ->
                 if (response.status != 200 ) {
                         log.debug "GroveStreams logging failed, status = ${response.status}"
                 }
         }
    }

(Paul Knight) #15

Hi Anthony,

I know this is a bit old, but I’m faced with a need to store and analyze event data locally, and am wondering if you have a distro of your solution. Any lessons learned along the way would be appreciated!

Paul


(Anthony S.) #16

I ended up going with the grafana | influxdb. It works fantastic


(Paul Knight) #17

That was my leading choice, but I caught your post and wanted to make sure I covered all avenues. Thanks for the update!


(Anthony S.) #18

no problem have fun with grafana. I really love it