Verbos logging help with KuKu Harmony port

Iā€™ll admit I am still fairly new to groovy, but I am pretty fluent in various shells. Is there anyway to get a verbos output of some code so I can get a better understanding of what it is doing? I am trying to port an app from smartThings, and when trying to run it, it fails with a 500 error but I see no details about what caused the error.

The code saves fine.

Open the real time log in a separate tab and look there for clues. :slight_smile:

In the Hubitat menu, open the last option ā€˜Logsā€™ in a separate window/tab. This is a live output of everything that writes to the log including errors. Try to run the app and check the Log window when you get the 500 error. In some cases I got the 500 error without any info in the log. I usually add some additional log lines to see what point in the code itā€™s getting up to. Some common causes I had were an href to another page that wasnā€™t defined in the preferences. There isnā€™t any line by line debugging so your best option is to add additional logging output from what I understand.

Yeah. I've added debug lines and can see where the code is stoping, but I can't find anything wrong with it. I was hoping to have a way to enable standard error or some crap like that.

Why not post the line of code that is problematic here?

To be honest I am not sure which line is the actual problem. Here is my github repo for it:

https://github.com/xxKeoxx/hubitat/blob/master/Hubitat_Harmony.goovy

Here is the log output.
Note: Some of the line #'s have changed because I added other debug lines.

app:233 2018-03-08 11:00:38.047:debug Line 821: atomicState.discoverdHubs = [basement]
app:233 2018-03-08 11:00:38.044:debug Line 810: discoverHubs_response: basement
app:233 2018-03-08 11:00:38.041:debug Line 808: [hubs:[basement]] and [basement]
app:233 2018-03-08 11:00:38.036:debug Line 803: discoverHubs_response >> [hubs:[basement]]
app:233 2018-03-08 11:00:38.025:debug Line 107: KuKu Harmony Version
app:233 2018-03-08 11:00:38.021:debug Line 104: harmony Devices
app:233 2018-03-08 11:00:38.016:debug Line 95: discoverHubs
app:233 2018-03-08 11:00:38.010:debug Line 89+: Harmony Hub List
app:233 2018-03-08 11:00:37.999:debug Line 83+: dynamic main page
app:233 2018-03-08 11:00:37.998:debug Line 78: atomicState = [basement]
app:233 2018-03-08 11:00:37.988:debug Line 828: getHubAction>> ********:8282, /hubs, discoverHubs_response
app:233 2018-03-08 11:00:37.984:debug Line 796: discoverHubs
app:233 2018-03-08 11:00:37.978:debug Line 77: Running discoverHubs.
app:233 2018-03-08 11:00:37.974:debug Line 71: Main Page
app:233 2018-03-08 11:00:37.972:debug Line 64: parent Or Child Page

Here is the original codeI am trying to port:

Are you able to see the section ā€œHarmony Hub List :ā€ with the option for ā€œAdd a deviceā€¦ā€? If so, does the 500 error show up on that page or when you click ā€œAdd a deviceā€¦ā€?
It looks like discoverHubs is using HubAction and receiving a response asynchronously. One test is to comment out line 77 since the hub is already discovered and stored in the state.

HeHeHe... I looked at that app before I wrote my simple Harmony Integration for Hubitat:

The KuKuHarmony app was a bit overwhelming for my Groovy skills, and it does not support Harmony Activities. All I wanted was simple Harmony Activities, so I wrote the above simple device Driver for Hubitat.

If you read through the thread, there are a couple of other workarounds available as well.

At a minimum, you might be able to look at my Driver code to see how it communicates to the 'harmony-api' running on a separate server. KuKu uses the same 'harmony-api'.

Yes. The error happens when I click on Add a Device.

Yeah. I saw that, but I had already began to understand how this app was written so I want to see it to the end if possible. Honestly I feel like all of the different calls make it harder to follow. I may end up redesigning the app once I get this to work over here. It's also formatted different than most other apps I've seen. Most of them have initialization and other preferences at the top.

I've stopped writing anything on smartThings.

1 Like

Ah, that narrows it down to line 106. I canā€™t find any other Hubitat examples that use app() to install a child app right now. Iā€™ll look a little more but that at least narrows down where itā€™s happening.

Well it looks like Hubitat doesnā€™t support something with the logic of the app being either the parent or child. Either the dynamic name or parent parameter isnā€™t working. I made a copy of the app and changed the definition section to this:

name: "KuKu Harmony Device",
namespace: "turlvo",
author: "KuKu",
description: "This is a SmartApp that support to control Harmony's device!",
category: "Convenience",
parent: "turlvo:KuKu Harmony",
singleInstance: true,
iconUrl: "https://cdn.rawgit.com/turlvo/KuKuHarmony/master/images/icon/KuKu_Harmony_Icon_1x.png",
iconX2Url: "https://cdn.rawgit.com/turlvo/KuKuHarmony/master/images/icon/KuKu_Harmony_Icon_2x.png",
iconX3Url: "https://cdn.rawgit.com/turlvo/KuKuHarmony/master/images/icon/KuKu_Harmony_Icon_3x.png")

And also changed this method:

 def parentOrChildPage() {
     log.debug "Line 64: parent Or Child Page"
     mainChildPage()
 }

Then back on the main parent app changed line 106 to:

app( name: "harmonyDevices", title: "Add a device...", appName: "KuKu Harmony Device", namespace: "turlvo", multiple: true, uninstall: false)

I was then able to click Add a device.

I get this error when saving the app now:

Metadata Error: Parent App 'turlvo:KuKu Harmony' not found on line 42

Hm I just tested again and had no errors. Did you make a copy of the code, start a new app, paste the code and modify the definition section and parentOrChildPage method then save? In the end there should be two apps in the Apps Code: ā€œKuKu Harmonyā€ and ā€œKuKu Harmony Deviceā€

Sorry. I didn't understand what you were suggesting. I just modified the existing one.

SUCCESS!!! I will update my git repo with this. I will probably work on a rewrite eventually, but for now this works.

Thank you for the help!

Awesome! Yeah it can be cleaned up a bit if itā€™s being separated out into two apps. Itā€™s interesting the name definition could be dynamic in ST so the same code could act as the parent or the child.

Is the github repository found below updated with these changes? I am seeing the error as well.

I saw this error when I first installed. The drivers we're named differently so when it was called it as never found. I think it was the turvlo name needed to be changed to keo?

The drivers have all been updated out on Git now. sorry about that.