OhmConnect + Smartthings Integration

I made a few modifications to the device handler to have it actually poll the server. Don’t know why polling wouldn’t refresh.

/**
*  Copyright 2015 SmartThings
*
*  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.
*
*  OhmConnect Device Type
*
*  Author: markewest@gmail.com
*
*  Date: 2015-10-02
*/

preferences {
	input name: "ohmidCode", type: "text", title: "Ohm Id", 
	description: "Configure your Ohmconnect 8 digit ID (end of the URL at the bottom of the account page)", 
	required: true, displayDuringSetup: true
}

metadata {
	definition (name: "OhmConnect API", namespace: "afewremarks", author: "Mark West") {
		capability "Actuator"
		capability "Switch"
		capability "Sensor"
		capability "Polling"

		command "refresh"
	}

	// simulator metadata
	simulator {

	}

	// UI tile definitions
	tiles(scale: 2) {
		multiAttributeTile(name:"status", type: "thermostat", width: 6, height: 4, canChangeIcon: false, decoration: "flat") {
			tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
				attributeState "on", label: 'Ohm Hour', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821"
				attributeState "off", label: 'Stable Grid', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
			}
		}

		standardTile("refresh", "device.switch", width: 2, height: 2, inactiveLabel: false, decoration: "flat") {
			state "default", label:'', action:"polling.poll", icon:"st.secondary.refresh"
		}

		main "status"
		details(["status","refresh"])
	}
}

def installed() {
	log.debug "Installing OhmConnect Device"

	runEvery1Minute(doRefresh)
}

def parse(String description) {

}

def on() {
	sendEvent(name: "switch", value: "on")
}

def off() {
	sendEvent(name: "switch", value: "off")
}

def poll() {
	log.debug "OhmConnect Polling"

	refresh()
}

def refresh() {
	doRefresh()
}

def doRefresh() {
	log.debug "Executing 'poll'"

	def currentState = device.currentValue("switch")

	def params = [
	uri:  'https://login.ohmconnect.com/verify-ohm-hour/',
	path: ohmidCode,
	]
	try {
		httpGet(params) { resp ->

		if(resp.data.active == "True"){
			log.debug "Ohm Hour"

			if(currentState == "off"){
				sendEvent(name: "switch", value: "on")
			}

		} else {
			log.debug "Not currently an Ohm Hour"

			if(currentState == "on"){
				sendEvent(name: "switch", value: "off")
			}


		}
	}
	} catch (e) {
		log.error "something went wrong: $e"
	}
}

I’m still not seeing polling refresh. I only get the executing ‘poll’ when I click the refresh button in the app.

Remove and reinstall/initialize the device. Otherwise it won’t pick up the runEvery1Minute schedule.

1 Like

thanks, that did it! I was getting weird refreshes every 15-20, but removing and adding now has it polling every minute. I’ll see how it works next Ohm hour!

Hi there, I’m new here and I’m already very grateful to the community for all of the posts which have helped me a lot already.

I would like to see if someone could provide some help setting this up. This integration would be very useful to me but I can’t seem to be able to find my Ohmconnect Account ID to configure the Device Handler.

Is there something that I am missing here? I am assuming this integration still works. Am I wrong?

I just signed up for ohmconnect and it would be really helpful if my smart devices through smartthings were controllable. I don’t plan on repurchasing all of my plugs and whatnot.

So does this still work? I can’t find much documentation anywhere here or at ohmconnect.

Thanks.