I write a SmartApp to retrieve device events by using the myDevice.events() and use the evt.descriptionText and evt.description to get the event description.
def event_list = contacts.events()
// subscribe more than one contact sensors
for ( int i=0; i < event_list.size(); i++)
{ for (int j=0; j < event_list[i].size(); j++)
{ log.debug "${event_list[i][j].descriptionText}"
log.debug "${event_list[i][j].description}"
}
}
For my SmartSense Multi sensors, the description method returns
By using the evt.name method, all the events from the events() method are only the temperature events. The IDE → My Device → MySmartSenseMulti → List Event, the event name shows not only the temperature, but also include lqi, rssi, battery.
Is it possible to get all event history not only one type of event? Or is there any device method can translate the content of description into description text. (I’ve tried to use myDevice.parse(str), but it encountered method/property not support error during runtime.
Hi Wan_Rong_Jih, I don’t know Groovy very well so take that into account when reading my words (they may be worthless). Is your valid code? The for loop looks like it’s missing something. Like a definition for event_list[i], then then something similar for the second J loop.
for (i = 0; i <3; i++) {
System.out.println("Hello World")
}
Yours looks like this:
def event_list = contacts.events()
// subscribe more than one contact sensors
for (int i=0; i {
for (int j=0; j {
log.debug "${event_list[i][j].descriptionText}"
log.debug "${event_list[i][j].description}"
}
}
I’d say that Groovy is giving you exactly what you are asking for, log entries of event_list[0][0]. I think you need to define the for loops differently. Sorry i couldn’t be of more help at this time.
Thanks @ncherry . Despite the mistake of copy/paste (the code has been corrected, it caused by the ‘<’ need space to show.). Either SmartApp IDE editor or the live logging does not have any error about my code, but the results of descriptionText do not fully translate the values of description.
Could anyone help me to get the full description of event logs?
After check events on my phone, I know why the descriptionText can only display the temperature event for SmartSense Multi. As the descriptionText returns the description of the event that is to be displayed to the user in the mobile application and the temperature event is the only type of event that SmartSense Multi on mobile devices.
My code is a partial of SmartApp…
It seems that the Definition section and Preference section are missed. SmartThings API documents will show you the SmartApp structure.
I do not understand the meaning of “how to parse the event list?” Do you mean parsing the returned event string? If it is, it’s hard for SmartApp to perform grammar/syntax parse, you should download the results and parsing them on your local machine.