Post Command Help Needed


#1

Hello All,

I want to start of by saying that I am new to this, hopefully someone out there can help me out .

I have a smart electric meter in my home panel. It has default protocols like Modbus and BACnet, from what I saw online Smartthings does not work with either protocol. I have figured out that this device also has a web api.

I have been using groovy console to test my code. I did get the code below to work in the groovy console but in smartthings ide I am getting an error.

import groovyx.net.http.*

public class HttpclassgetrRoles {

static void main(String[] args){

     def baseUrl = new URL('http://192.168.1.65/login.json')
     HttpURLConnection connection = (HttpURLConnection) baseUrl.openConnection();
     connection.addRequestProperty("Accept", "application/json")
     connection.with {
       doOutput = true
       requestMethod = 'POST'   
          
       
     }

 }

}

Error in smartthings:

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object ‘HttpclassgetrRoles@51d8de90’ with class ‘HttpclassgetrRoles’ to class ‘physicalgraph.device.DeviceTypeExecutorBase’

Any ideas?

Thank you!


(www.rboyapps.com - Make your home your butler!) #2

ST allows only a subset of classes that can be used. Use the httpPost API, refer to the developer documentation for more details.