Home Cloud Hub port to Hubitat

Hey all. So I am attemptig to revisit this again. The problem I am currently having is this:

java.lang.NullPointerException: Cannot get property 'security' on null object on line 289 (installed)

This is the section of the code:

hch.security[module_name] = [
    	'enabled': !!(settings.attUsername || settings.attPassword),
        'controllable': settings.attControllable,
        'followMode': settings.attFollowMode,
        'connected': false
    ]

I am not a real developer, so does anyone know what is causing this error?

So it looks like hch isn't getting assigned:

   def hch = (installing ? state.ihch : state.hch)
   log.debug "${module_name} = ${hch} ${installing} ${force}"

Returns this:

   digitallife = null true true`

That would suggest that state.ihch is null.

So what it looks like to me is the params that are being set aren't being carried over to the next function (Sorry if that is the wrong term) . Example:

  	section("Manual Configuration") {
            input("hchLocalServerIp", "text", title: "Enter the IP of your local server", required: true, defaultValue: "")

I enter the IP and click next, but this is the error I get:

(http://10.0.1.46/logs#app1462)2018-07-28 23:47:38.584:errorjava.lang.NullPointerException: Cannot get property 'hchLocalServerIp' on null object on line 160 (prefModulesPrepare)
(http://10.0.1.46/logs#app1462)2018-07-28 23:47:29.626:traceStopped waiting...
(http://10.0.1.46/logs#app1462)2018-07-28 23:47:24.544:traceLooking for local HCH server...

This is the code it's complaining about.

def prefModulesPrepare(params) {
	if (params.hchLocalServerIp) {
    	state.ihch.localServerIp = params.hchLocalServerIp
    } else {
        state.ihch.localServerIp = settings.hchLocalServerIp
    }

Which makes me believe it isn't being passed through. Is there something different in Hubitat that I need to change?

OOOOO.... I am getting closer. I found that the params aren't being carried over, so I did some error catching and forced the ip from the variable set from the input.

Probably not the cleanest, but it got me to the point where it pings the server.

OMG. I was so close to getting this to work and then found out about TLS not being supported on the hub. Does anyone have suggestions on how to work around this?

Ok..... So I got the Digital Life Authentication working, and I can see the devices being discovered in homecloudhub. However, it's like homecloudhub isn't reaching the app in HE. I never see any data logged and the devices never get created.

Does anyone have suggestions on how to troubleshoot this? I am so close to getting this to work.

It looks like homecloud hub is trying to connect on http://[ip]:39501

So after further review, this is the part of code that isn't working.

def lanEventHandler(evt) {
    def description = evt.description
    def hub = evt?.hubId
	def parsedEvent = parseLanMessage(evt.description)
    //def parsedEvent = description
	log.trace "RECEIVED LAN EVENT: $evt.description"
	
	//discovery
	if (parsedEvent.ssdpTerm && parsedEvent.ssdpTerm.contains(getLocalServerURN())) {
    	log.trace "DISCOVERY SUCCESSFUL"
        atomicState.hchLocalServerIp = convertHexToIP(parsedEvent.networkAddress)
	}
    
    //ping response
    if (parsedEvent.data && parsedEvent.data.service && (parsedEvent.data.service == "hch")) {
	    def msg = parsedEvent.data
        if (msg.result == "pong") {
        	//log in successful to local server
            log.info "Successfully contacted local server"
			atomicState.hchPong = true
        }   	
    }
    log.trace "parsedEvent.data = $parsedEvent.data"
    //log.trace "parsedEvent.data.event = " + parsedEvent.device.data.event
    if (parsedEvent.data && parsedEvent.data.event) {
    //if (parsedEvent.data) {
	    log.trace "GOT LAN EVENT ${parsedEvent.data.event} and data ${parsedEvent.data.data}"
        switch (parsedEvent.data.event) {
        	case "init":
                sendLocalServerCommand state.hch.localServerIp, "init", [
                            server: getHubLanEndpoint(),
                            modules: processSecurity([module: parsedEvent.data.data])
                        ]
				break
        	case "event":
            	processEvent(parsedEvent.data.data);
                break
        }
    }
}

I started tracing the code and it looks like the data is returning null.

log.trace "parsedEvent.data = $parsedEvent.data"
parsedEvent.data = null

Does anyone have any idea why? I have a copy of the code in git if you want to take a look.

Well the good news is I think I have the App working on hubitat. The bad news is that Hubitat may not have the ability yet to accept Lan notifications from devices.

I have an email out to support asking for assistance.

Well.... It looks like the feature has been implemented, so I have no idea why the events aren't reaching Hubitat. Can anyone help me trouble shoot this? If so, just tell me what you need from me and I will supply it.

so the laneventhandler is receiving an event but .description is null?

if yes … does the evt have any value? may be try something like this?

evt.each { log.trace it }

As soon as I get the app working again. I'll give it a shot and let you know.

wait … thought the app was working just getting the LAN notifications? :slight_smile:

It was until the latest update to hubitat. :slight_smile:

1 Like

This is what I get when I add the above to laneventhandler.

2018-08-04 23:08:03.313: **trace** com.hubitat.hub.domain.Event@5794809f
2018-08-04 23:08:03.258: **trace** com.hubitat.hub.domain.Event@3a58728d
2018-08-04 23:08:03.216: **trace** com.hubitat.hub.domain.Event@576fd397
2018-08-04 23:08:02.308: **trace** com.hubitat.hub.domain.Event@7801c515
2018-08-04 23:08:02.257: **trace** com.hubitat.hub.domain.Event@4d4a341
2018-08-04 23:08:02.219: **trace** com.hubitat.hub.domain.Event@250671e7
2018-08-04 23:08:00.183: **trace** com.hubitat.hub.domain.Event@223a4b0f
2018-08-04 23:07:26.283: **trace** com.hubitat.hub.domain.Event@3e8185b7

well that doesnt work.

how about if you go to the device then click events on the top bar is there a list of events there?

may be try?

log.trace evt.data, evt.description

See there lies the problem. The first thing the app is supposed to be doing is creating the Virtual Devices. It's not doing that. In the nodejs app I can see the Devices being discovered from digital life, but I don't ever see anything getting received by hubitat.

EDITED

Removed my last part of the comment because I was wrong about it. :slight_smile:

not sure i can dig in till later next week but is there a flow of what the code pieces are and what data is supposed to flow from where to where?

I can try to put something together. I don't know of one existing, but I have a basic understanding of how this was written.

that would very helpful. thank you.