Home Cloud Hub port to Hubitat

One of the apps I use over at smartThings is HomeCloud Hub. It is used to integrate my AT&T digital life into smartThings. Has anyone tried porting this code yet?

Can someone help me figure out this error? I think once I get this error fixed, home cloud hub will just work in hubitat.

startup failed: Script1.groovy: 729: unable to resolve class physicalgraph.device.HubAction @ line 729, column 17. sendHubCommand(new physicalgraph.device.HubAction("lan discovery " + getLocalServerURN(), physicalgraph.device.Protocol.LAN)) ^ Script1.groovy: 775: unable to resolve class physicalgraph.device.HubAction @ line 775, column 24. sendHubCommand(new physicalgraph.device.HubAction( ^ 2 errors on line null

Here is line 729:

sendHubCommand(new physicalgraph.device.HubAction("lan discovery " + getLocalServerURN(), physicalgraph.device.Protocol.LAN))

Here is line 775:

sendHubCommand(new physicalgraph.device.HubAction(
method: "GET",
path: "/${command}",
headers: [
HOST: "${ip}:42457"
],
query: payload ? [payload: groovy.json.JsonOutput.toJson(payload).bytes.encodeBase64()] :
))

A good starting point would be to replace all instances of ā€œphysicalgraphā€ with ā€œhubitatā€. This applies to all apps and device handlers.

Man I wish I was a developer. I fixed the errors but now it looks like the next selection screens arenā€™t showing me options such as user name and password.

Is someone willing to pick this project up? I am clearly out of my element with this.

have you checked with ady624 over on the ST or webcore forum? maybe he is willing to support it on hubitat as well.

I havenā€™t because last I heard he was employed by smartThings and thought this would be conflict of interest.

no harm in asking. man is free to do what he wants to do with his free time. :slight_smile:

1 Like

I posted under New Features on the WebCore Community site.

1 Like

Ivā€™e tracked down the problem with this port to the following line of code:

sendLocalServerCommand state.ihch.localServerIp.toInt(), "ping", [:]

Is there anyway to output what it is returning so I can see it in the log? Right now the screen just returns blank.

erga derga!!

This is the error I get and I canā€™t figure out what it means:

2018-03-18 20:24:34.089:errorNo signature of method: com.hubitat.hub.executor.AppExecutor.error() is applicable for argument types: (java.lang.String, groovy.lang.MissingMethodException) values: [Error logging in to HCH..., groovy.lang.MissingMethodException: No signature of method: java.lang.String.toInt() is applicable for argument types: () values: [] Possible solutions: toSet(), count(java.lang.CharSequence), toList(), print(java.lang.Object), print(java.io.PrintWriter), join(java.lang.CharSequence, [Ljava.lang.CharSequence;)] Possible solutions: render(), getLog(), now(), grep(), every(), iterator() on line 400

Here is the code:

/***********************************************************************/
/*                           LOGIN PROCEDURES                          */
/***********************************************************************/
/* Login to Home Cloud Hub                                             */
/***********************************************************************/
private doHCHLogin() {
	try {
	if (state.ihch.useLocalServer) {
        atomicState.hchPong = false

		log.trace "Line 366: Pinging local server at " + state.ihch.localServerIp
        sendLocalServerCommand state.ihch.localServerIp.toInt(), "ping", [:]
	    log.trace "Line 368: after sendLocalServerCommand"
		def cnt = 50
        def hchPong = false
        log.trace "Line 371: just before cnt"
        while (cnt--) {
            pause(100)
            hchPong = atomicState.hchPong
            log.debug "Line 375: hchPong = ${hchPong}"
            if (hchPong) {
                return true
            }
        }
        return false
	} else {
        log.trace "Line 382: httpGet"
        return httpGet('https://www.homecloudhub.com/endpoint/02666328-0063-0086-0069-076278844647/manager/smartthingsapp/login/' + settings.hchUsername.bytes.encodeBase64() + '/' + settings.hchPassword.bytes.encodeBase64()) { response ->
            if (response.status == 200) {
                if (response.data.result && (response.data.result == "success") && response.data.data && response.data.data.endpoint) {
                    state.ihch.endpoint = response.data.data.endpoint
                    state.ihch.connected = now()
                    if (!state.ihch.security) {
                        state.ihch.security = [:]
                    }
                    return true
                } else {
                    return false
                }
            } else {
                return false
            }
        }
	}
	} catch (e) { log.error "Error logging in to HCH...", e }
}

I have no real idea what HomeCloudHub is, but that section of code is just trying to PING a local HomeCloudHub server on your LAN, I believe. If it gets a response with 50 tries, each 100ms apart, it returns true, otherwise it returns false.

Are you running a local HomeCloudHub nodejs server on your LAN? If so, try simply adding a ā€˜return trueā€™ as the first line in the doHCHLogin() function to see it you can get further alongā€¦

On second thoughtā€¦ I believe this is not a real PING commandā€¦ I believe it is simply sending a string of ā€˜pingā€™ to the nodejs server. If you canā€™t get this command to work, none of it probably will.

Here is what sendLocalServerCommand() is actually doingā€¦ I am sure youā€™ve replaced the ā€˜physicalgraphā€™ with ā€˜hubitatā€™, correct?

private sendLocalServerCommand(ip, command, payload) {
	try {
        ip = ip ?: state.sch.localServerIp
        log.trace "Sending command $command with payload size ${"${groovy.json.JsonOutput.toJson(payload).bytes.encodeBase64()}".size()} to IP $ip"
        log.trace payload
        sendHubCommand(new physicalgraph.device.HubAction(
            method: "GET",
            path: "/${command}",
            headers: [
                HOST: "${ip}:42457"
            ],
            //body: [payload: payload]
            query: payload ? [payload: groovy.json.JsonOutput.toJson(payload).bytes.encodeBase64()] : []
        ))
	} catch (e) { log.error "Got an error...", e }
}

Have you made any headway with this? Any success? I need to move my Digital Life system over to my Hubitat. I don't know Groovy but I'm willing to add it to my list of languages if needed. :slight_smile:

Some. Iā€™ve gotten to the point where it asks for your Creds, but it keeps failing with invalid credentials.

Iā€™ve only been working on it as time permits. Right now I what iā€™ve done to work around it is use the other hub integration so all of the contact and motion sensors from Digital Life (on ST) are mirrored in HE. They get updated pretty quick.

We had the invalid creds issue in the ST version a while ago but ady fixed that. Did you start your hubitat version with the fixed version of his code?

I forked it from his repoā€¦ I thought. Iā€™ll double check and try the port again.

Ok. So it's not an issue with logging in even though the app says it is. It looks like it logs in but still fails on this bit of code:

def prefATTConfirm() {
    if (doATTLogin(true, true)) {
                return dynamicPage(name: "prefATTConfirm", title: "AT&T Digital Lifeā„¢ Integration", nextPage:"prefModules") {
                        section(){
                                paragraph "Congratulations! You have successfully connected your AT&T Digital Lifeā„¢ system."
                        }
        }
        } else {
                return dynamicPage(name: "prefATTConfirm",  title: "AT&T Digital Lifeā„¢ Integration") {
                        section(){
                                paragraph "Sorry, the credentials you provided for AT&T Digital Lifeā„¢ are invalid. Please go back and try again."
                        }
        }
    }
}

In the log I can see a successful log in.

Even after commenting out the else statement so it only has the success part I still have no success. Their is no failure, it just goes back to the previous screen. I fear this may be beyond my knowledge.

Messed around with this a bit today and Iā€™m not even getting to a point where it asks for login. It asks for the IP of my homecloudhub server. Once I give it that the next screen is just ā€œHome cloud hub modulesā€ and a ā€œDoneā€ button. After clicking on Done I get ā€œConnect to home cloud hubā€ and another ā€œDoneā€ button. After clicking done there Iā€™m taken back to the first screen of the app install.

Without taking the time to learn groovy Iā€™m probably not going to be of much help. :frowning:

Iā€™ve made some progress on it. I am basically re-writing most of it. I am only using it for digital Life so I have removed all of the other integrations to make reverse engineering this easier. The original does a lot of dynamic pages which were hard for me to follow.

So Iā€™ve basically gotten through the entire flow for digital life authentication but at the end I canā€™t get the app to commit. I havenā€™t given up yet, and I am feeling more optimistic than I was a few weeks ago.

I was trying to strip out the non Digital Life portions as well. Iā€™m glad youā€™re feeling optimistic!

Disclaimer: This may take me a bit as I continue to reverse engineer this thing. I'll keep you updated as much as I can.