Home Cloud Hub port to Hubitat

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.

The SmartApp does the authentication and retrieves tokens that it then passes down to the nodejs app - the nodejs app never gets the credentials (username and password) for security purposes - it only gets a token from the SmartApp that needs to be refreshed once in a while - it expires. The SmartApp is also responsible for managing the devices, creating new ones, and updating existing ones when events happen.

What it looks like to me is that the nodejs app is sending the even but it never reaches hubitat. I do see something received in the hubitat logs but I am pretty sure they aren't from the nodejs app because they occure even when I shut down nodejs.

The nodejs app works fine pointing at smartThings, and from what I can tell has nothing smartThings specific in it.

Here is an example of what is being received:

parsedEvent = [mac:001788227989, networkAddress:0A000102, deviceAddress:50, ssdpPath:/description.xml, ssdpUSN:uuid:2f402f80-da50-11e1-9b23-001788227989, ssdpTerm:urn:schemas-upnp-org:device:basic:1, ssdpNTS:null]

Later today I'll get this set up on smartThings again and capture a parsedEvent for comparison.

From SmartThings:

Received discovery event for module digitallife, device Rosiak Control Panel of type digital-life-controller, value null, data: [data-rules-set:application/json, data-dlc-control:0, data-dlc-status-bitmask:0, data-operation-mode:0, type:digital-life-controller, data-appliance-ip2:null, id:0, data-proxy-port:49156, data-timezone:CST6CDT, event:discovery, data-subscription-features:DLBASCPKG, name:Rosiak Control Panel, data-connectivity:3, data-livevideoonalarmtoken:Loukse7HBbXt44rguC1v74PEHavsB8Vr, data-header-ip:98.144.102.103, data-test-request:null, data-discovery-status:null, data-discovery:0, module:digitallife, data-dl-flags:23, data-policycaps:G=16,K=16,SP=1,T=1,IIWC=1,HP=2,N=1,RD=1,ER=4,AM=2,TMH=1,DTM=1,AQS=1,VE=1,SC=1,EVT=1,PE=1,REST=1,EndExitDelay=1, data-battery:100, data-change-rules-set-row:application/json, data-inbound-port:32000, data-livevideoonalarmpolicy:never, data-schedule:application/json, data-locale:en_US, data-location:0003013034, data-schedule-change:null, data-token:XW7pmWZAIWLIL4G5fqQKl7fXruIsVAJ4, data-power-source:AC, data-test-mode-expiry:,auto-dla, data-tampered-device-list:null, data-policyrules:10, data-proxy-ip:a-nps1-da.dlife.att.com, data-appliance-ip:10.0.1.44, data-status:0]

From Hubitat:

Nothing....

Here is the output from nodejs:

Aug 05 11:55:28 raspberrypi systemd[1]: Started Node.js Local Home Cloud Hub Server.
Aug 05 11:55:31 raspberrypi node[10517]: 8/5/2018, 11:55:31 AM [homecloudhub] Home Cloud Hub app v0.1
Aug 05 11:55:31 raspberrypi node[10517]: 8/5/2018, 11:55:31 AM [homecloudhub] ====================================================================================================
Aug 05 11:55:31 raspberrypi node[10517]: 8/5/2018, 11:55:31 AM [homecloudhub] Retrieved config with server at 10.0.1.46:39501
Aug 05 11:56:29 raspberrypi node[10517]: 8/5/2018, 11:56:29 AM [homecloudhub] Received init request
Aug 05 11:56:29 raspberrypi node[10517]: 8/5/2018, 11:56:29 AM [homecloudhub] Starting module digitallife
Aug 05 11:56:29 raspberrypi node[10517]: 8/5/2018, 11:56:29 AM [digitallife] Initializing...
Aug 05 11:56:29 raspberrypi node[10517]: 8/5/2018, 11:56:29 AM [digitallife] Successfully got tokens.
Aug 05 11:56:29 raspberrypi node[10517]: 8/5/2018, 11:56:29 AM [digitallife] Getting list of devices...
Aug 05 11:56:29 raspberrypi node[10517]: 8/5/2018, 11:56:29 AM [digitallife] Listening for events... token is 50d5f807d483f81296dec9e79941ff4d
Aug 05 11:56:29 raspberrypi node[10517]: (node:10517) DeprecationWarning: Calling an asynchronous function without callback is deprecated.
Aug 05 11:56:29 raspberrypi node[10517]: 8/5/2018, 11:56:29 AM [digitallife] Connected and listening for events...
Aug 05 11:56:30 raspberrypi node[10517]: 8/5/2018, 11:56:30 AM [homecloudhub] Sending event to SmartThings: Discovered device "Living Window 1" <SD0A1664A7>
Aug 05 11:56:30 raspberrypi node[10517]: 8/5/2018, 11:56:30 AM [homecloudhub] Sending event to SmartThings: Discovered device "AlarmKeypad " <KP0200B9AC>
Aug 05 11:56:30 raspberrypi node[10517]: 8/5/2018, 11:56:30 AM [homecloudhub] Sending event to SmartThings: Discovered device "Play Room Window 2" <SD0A1946FA>
Aug 05 11:56:30 raspberrypi node[10517]: 8/5/2018, 11:56:30 AM [homecloudhub] Sending event to SmartThings: Discovered device "Living Window 4" <SD0A17E32F>
Aug 05 11:56:31 raspberrypi node[10517]: 8/5/2018, 11:56:31 AM [homecloudhub] Sending event to SmartThings: Discovered device "Living Window 3" <SD0A17E32D>
Aug 05 11:56:31 raspberrypi node[10517]: 8/5/2018, 11:56:31 AM [homecloudhub] Sending event to SmartThings: Discovered device "Play Room Window 1" <SD0A191E07>
Aug 05 11:56:31 raspberrypi node[10517]: 8/5/2018, 11:56:31 AM [homecloudhub] Sending event to SmartThings: Discovered device "Dining Window 2" <SD0A18018B>
Aug 05 11:56:31 raspberrypi node[10517]: 8/5/2018, 11:56:31 AM [homecloudhub] Sending event to SmartThings: Discovered device "Dining Window 3" <SD0A181A58>
Aug 05 11:56:32 raspberrypi node[10517]: 8/5/2018, 11:56:32 AM [homecloudhub] Sending event to SmartThings: Discovered device "Office Window 2" <SD0A203E53>
Aug 05 11:56:32 raspberrypi node[10517]: 8/5/2018, 11:56:32 AM [homecloudhub] Sending event to SmartThings: Discovered device "Weather " <XA002accu>
Aug 05 11:56:32 raspberrypi node[10517]: 8/5/2018, 11:56:32 AM [homecloudhub] Sending event to SmartThings: Discovered device "Patio Door" <SD0A1664A3>
Aug 05 11:56:33 raspberrypi node[10517]: 8/5/2018, 11:56:33 AM [homecloudhub] Sending event to SmartThings: Discovered device "Rosiak Control Panel" <0>
Aug 05 11:56:33 raspberrypi node[10517]: 8/5/2018, 11:56:33 AM [homecloudhub] Sending event to SmartThings: Discovered device "Digital Life System" <AM00000004>
Aug 05 11:56:33 raspberrypi node[10517]: 8/5/2018, 11:56:33 AM [homecloudhub] Sending event to SmartThings: Discovered device "Key Fob" <SK0E044FF6>
Aug 05 11:56:33 raspberrypi node[10517]: 8/5/2018, 11:56:33 AM [homecloudhub] Sending event to SmartThings: Discovered device "Entry Front Door" <SD0A15F1B8>
Aug 05 11:56:34 raspberrypi node[10517]: 8/5/2018, 11:56:34 AM [homecloudhub] Sending event to SmartThings: Discovered device "Siren " <SI030075F7>
Aug 05 11:56:34 raspberrypi node[10517]: 8/5/2018, 11:56:34 AM [homecloudhub] Sending event to SmartThings: Discovered device "Dining Window 1 " <SD0A17E333>
Aug 05 11:56:34 raspberrypi node[10517]: 8/5/2018, 11:56:34 AM [homecloudhub] Sending event to SmartThings: Discovered device "Entry Laundry Door" <SD0A166483>
Aug 05 11:56:34 raspberrypi node[10517]: 8/5/2018, 11:56:34 AM [homecloudhub] Sending event to SmartThings: Discovered device "Living Window 2" <SD0A1664AC>
Aug 05 11:56:35 raspberrypi node[10517]: 8/5/2018, 11:56:35 AM [homecloudhub] Sending event to SmartThings: Discovered device "Office Window 1" <SD0A1CF888>
Aug 05 11:56:35 raspberrypi node[10517]: 8/5/2018, 11:56:35 AM [homecloudhub] Sending event to SmartThings: Discovered device "Play Room Window 3" <SD0A126440>
Aug 05 11:56:35 raspberrypi node[10517]: 8/5/2018, 11:56:35 AM [homecloudhub] Sending event to SmartThings: Discovered device "Smoke Detector" <SU020095DC>

So it looks like Hubitat can communicate with nodejs but nodejs can't send data to hubitat. When I start the nodejs app it get to the point where it tries to communicate with hubitat and sits there. If I configure the hubitat app again, it connects to nodejs and then I get the AT&T devices found by homecloudhub. nodejs is then supposed to send that information to hubitat but it never reaches there.

Aug 05 12:15:40 raspberrypi node[10805]: 8/5/2018, 12:15:40 PM [homecloudhub] Home Cloud Hub app v0.1
Aug 05 12:15:40 raspberrypi node[10805]: 8/5/2018, 12:15:40 PM [homecloudhub] ====================================================================================================
Aug 05 12:15:40 raspberrypi node[10805]: 8/5/2018, 12:15:40 PM [homecloudhub] Retrieved config with server at 10.0.1.46:39501
Aug 05 12:15:40 raspberrypi node[10805]: 8/5/2018, 12:15:40 PM [homecloudhub] url: http://10.0.1.46:39501

Here is the section of code that homecloudhub get's to and just sits there:

doLoadConfig = function () {
    node.fs.readFile(configFile, function read(err, data) {
        if (!err) {
            try {
                config.server = JSON.parse(data);
                if (config.server && config.server.ip && config.server.port) {
                    log({
                        info: 'Retrieved config with server at ' + config.server.ip + ':' + config.server.port
                    });
                    log({
                        info: 'url: http://' + config.server.ip + ':' + config.server.port
                    })
                    node.request.put({
                        url: 'http://' + config.server.ip + ':' + config.server.port,
                        headers: {
                            'Content-Type': 'application/json'
                        },
                        json: true,
                        body: {
                            event: 'init'
                        }
                    });
                }
            } catch (e) {
                log({
                    error: 'Failed reading config file: ' + e
                });
            }
        }
    });
},
1 Like

I've spent the last couple of hours enabling logging for various parts of the nodejs app. I can confirm that the information is not getting from nodejs to hubitat. My java is a bit rusty (by rusty I mean almost non existent.), so do you happen to know how I can output the return code from the put call to hubitat? I want to see if there is an error that I am just not seeing.

Maybe I am doing this wrong, but when I run the following curl command I get no return code from the webserver. Shouldn't I be getting something?

curl -X PUT -H "Content-Type: application/json" -d '{"event": "event", "data": “foo”}' "http://10.0.1.46:39501"

I also don't see the call in hubitat.

However, I can telnet to my hub on port 39501 so I know the port is listening.

Hey all I have a messy version of homecloudhub ported over That works with HE. I commented out many of the areas I chose to not support so they still exist within the app.
Thank you so much to everyone who helped me get this far especially:
@patrick
@chuck.schwer
@csteele
@mike.maxwell

If I've forgotten anyone, I am so sorry. There were so many people involved with this since I started the project back in February.

Here is a link to the github repo:

Please let me know if you have issues with the code or even suggestions on how to make it better.
This is just the initial port. I plan on removing the dynamic pages as I am choosing to only support AT&T digital life with this port.

NOTE: For anyone coming over from SmartThings, You don't need to make any changes to your nodejs files unless seeing the word "SmartThings" in your logs bothers you. The version in my git repo changed SmartThings to Automation Hub.