SmartThings now permanently offline

Will give it a shot.

1 Like

Wow...had to try 10 times in a row as quickly as possible...but I got it. Thanks for the help.

3 Likes

Anyone have a Ring alarm system that you could see if a slight modification would be able to arm/disarm it?

I don't but I believe @mike.maxwell will be getting his hands on one soon :wink:

As an FYI, the pic below is of the main sections returned by a device query using the Ring API. My guess is that the Ring alarm will be listed under "base_stations". My Doorbell pro was under "doorbots" and my floodlight was under "stickup_cams".

image

4 Likes

Great! Thanks. I’m getting an uneasy feeling lately that iSmart Alarm’s plan to not have a recurring revenue stream, has ultimately not panned out, and like it or not I may have a white box that might soon only offer the protection of throwing it at intruders.

4 Likes

I noticed at the bottom of the same article describing how to get the flood going another guy posted code to turn the floodlight can alarm on and off. Kinda cool for another automation scheme.

Do you have any advice for getting the video feed into the HE dashboard? That was my next challenge.

Glad to hear it worked for you as well!

That is way beyond my capability. Accessing the video feed would be the first part of the scenario. Converting the feed to be compatible with the dashboard would be the next...if it's even possible.

@Someguy, I made a few adjustments to the groovy code you linked to above. The driver was generating unnecessary logs (that included the tokens in plain text). It also generated http exceptions for every on/off PUT request. I adjusted the httpPut requests to look for the correct contentType and the errors are now gone. I also added a Debug Log toggle so the excessive logging could be enabled/disabled through the driver preferences.
See my updated code below.

/**
 *
 *  Ring Spotlight Cam Light Control
 * 
 *  Needs the username/password and the device ID of the device. 
 *  This needs to be sourced by an API call to
 *  https://api.ring.com/clients_api/ring_devices?api_version=9&auth_token={{auth_token}}
 *  
 *  I used https://github.com/davglass/doorbot as a guide to build the requests.
 *  Author: Philip
 *
 *
 *	edited for hubitat by Stephan Hackett
 * 	3/16/19
 *		- added debug logging toggle
 *		- changed PUT requests for on() and off() to use 'application/html' instead of Json - prevents the exception errors that were occurring
 *
 */
metadata {
	definition (name: "Ring Spotlight", namespace: "stephack", author: "Philip") {
		capability "Actuator"
		capability "Switch"
		capability "Sensor"
	}
	
	preferences {
        input "username", "email", title: "Ring Username", description: "Email used to login to Ring.com", displayDuringSetup: true, required: true
        input "password", "password", title: "Ring Password", description: "Password you login to Ring.com", displayDuringSetup: true, required: true
        //Not sure there is a better way to do this than ask? 
        input "deviceid", "text", title: "Device ID", description: "The numeric value that identifies the device", displayDuringSetup: true, required: true
		input "logEnable", "bool", title: "Enable Debug Logging?"
    }
}

def parse(String description) {
}

def authenticate() 
{
	def s = "${username}:${password}"
	String encodedUandP = s.bytes.encodeBase64()
    
    def token = "EMPTY"
    def params = [
    	uri: "https://oauth.ring.com",
    	path: "/oauth/token",
        headers: [
            "User-Agent": "iOS"
    	],
        requestContentType: "application/json",
        body: "{\"client_id\": \"ring_official_ios\",\"grant_type\": \"password\",\"password\": \"${password}\",\"scope\": \"client\",\"username\": \"${username}\"}"
	]
    try {
        httpPost(params) { resp ->
            if(logEnable) log.debug "POST response code: ${resp.status}"
            
            if(logEnable) log.debug "response data: ${resp.data}"
            token = resp.data.access_token
        }
    } catch (e) {
        log.error "HTTP Exception Received on POST: $e"
        log.error "response data: ${resp.data}"
        return
        
    }
    
    params = [
    	uri: "https://api.ring.com",
    	path: "/clients_api/session",
        headers: [
        	Authorization: "Bearer ${token}",
            "User-Agent": "iOS"
    	],
        requestContentType: "application/x-www-form-urlencoded",
        body: "device%5Bos%5D=ios&device%5Bhardware_id%5D=a565187537a28e5cc26819e594e28213&api_version=9"
	]

    try {
        httpPost(params) { resp ->
            if(logEnable) log.debug "POST response code: ${resp.status}"
            
            if(logEnable) log.debug "response data: ${resp.data}"
            token = resp.data.profile.authentication_token
        }
    } catch (e) {
        log.error "HTTP Exception Received on POST: $e"
        log.error "response data: ${resp.data}"
        return
        
    }
    
    if(logEnable) log.debug "Authenticated, Token Found."
    return token
}

def on() {
	
    if(logEnable) log.debug "Attempting to Switch On."
    def token = authenticate()
    //Send Command to Turn On
    def paramsforPut = [
    	uri: "https://api.ring.com",
    	path: "/clients_api/doorbots/${deviceid}/floodlight_light_on",
        query: [
        	api_version: "9",
            "auth_token": token
    	],
		contentType:'application/html'
	]
    try {
        httpPut(paramsforPut) { resp ->
			if(logEnable) log.debug "PUT(on) response code: ${resp.status}"
        }
    } catch (e) {
        //ALWAYS seems to throw an exception?
        //Platform bug maybe? 
        log.error "HTTP Exception Received on PUT: $e"
    }
	sendEvent(name: "switch", value: "on")
	log.info "${device.label} was turned on"
}

def off() {

    if(logEnable) log.debug "Attempting to Switch Off"
    def token = authenticate()
    
    //Send Command to Turn Off
    def paramsforPut = [
    	uri: "https://api.ring.com",
    	path: "/clients_api/doorbots/${deviceid}/floodlight_light_off",
        query: [
        	api_version: "9",
            "auth_token": token
    	],
		contentType:'application/html'
	]
    try {
        httpPut(paramsforPut) { resp ->
            if(logEnable) log.debug "PUT(off) response code: ${resp.status}"
        }
    } catch (e) {
        //ALWAYS seems to throw an exception?
        //Platform bug maybe? 
        log.error "HTTP Exception Received on PUT: $e"
    }
    sendEvent(name: "switch", value: "off")
	log.info "${device.label} was turned off"
}
2 Likes

This is great - how do you get the Device ID?

Instructions are in the link shown in this post.

It's a bit of a pain, but there is some guidance above.

1 Like

Oops didnt see that sorry. :grimacing:

Worked! I can turn the floodlight on and off. Very cool..

Here's an overview on what I did to get it to work.

On HE:

  1. Add @stephack's custom driver code from this thread.
  2. Create a virtual device using the driver.
  3. Set username/password and Device ID (see below) under Preferences.
  4. Save :wink:

Per the article - to get the Device ID.

  1. You have to install Postman. For me the app in Windows just got stuck on a blank window so had to do it in Linux.
  2. Once in Postman:
  • create a new "environment" called "Ring Environment" and add the variables: username, password, auth_token - set the initial values of the user/password to your ring credentials.
  • Download and extract the provided collections JSON file.
    https://philipnyecom.files.wordpress.com/2017/12/ring-api-set-postman_collection-json1.zip
  • Go to "import" and drag and drop the json file on to the import box.
  • A "Ring API Set" should appear in the left hand column.
  • First click on "POST Authenticate OAuth" at the top
  • Then click on "POST Authenticate (Get Token)" underneath.
  • Then click on "GET Get Devices". In the "body" window you should see the result in JSON format. Copy this to an editor and save if you want.
  • Parse the result - you are looking for entries under "stickup_cams".. the element is called "id"

The article that @Someguy posted has all the details if you are having trouble.

5 Likes

Wow this is awesome. Just updated and working great! Thank you :smile:

1 Like

@SmartHomePrimer found this while searching for something else Ring related. I don't have the Ring Alarm System myself, but remembered you were asking. Maybe this will work for you?

Smartthings Ring Alarm setup

1 Like

Nice. Thank you. Since HE does support Websockets, that would probably work. I don't have Ring either, but they're short listed if iSmart Alarm goes belly up.