Querying Events


(Jody) #1

EDIT: I figured it out. I had made a mistake and was calling a void method instead of Def.

I have gone over the docs multiple times, and I cannot seem to get a list of the last 10 events for a device.

When I call device.events(), it returns a list like this of objects like this

physicalgraph.app.EventWrapper@665423fe

They don’t appear to to have any of the methods or attributes listed under the taxonomy


(Brian) #2

Look in your IDE under hub>list events

It shows all your hub events, the capability and the value. If you click on the event it gives you an even deeper drill down of information


(Jody) #3

Thanks, but this was for an external app I am using to query events and analyze them.


(SGK) #4

Hi jodyalbritton,
When I call device.events(), it returns a list like this of objects like this

physicalgraph.app.EventWrapper@665423fe

Any idea how to parse it and get all values like description and all.


(Jody) #5

This should be what you are looking for.

  def listDeviceEvents() {
        def numEvents = 20
        def id = params.id
        def device = allDevices?.find{it.id == id}

        if (!device) {
            httpError(404, "Device not found")
        } else {
            log.debug "Retrieving last $numEvents events"
            def events = device.events(max: numEvents)
            def result = events.collect{item(device, it)}
            log.debug "Returnings EVENTS: $result"
            result
        }
    }

(SGK) #6

Ok,Thank you.