What parameters are passed to an event handler in Groovy?

Hi,

In the app I'm working on I have an event handler. I know there is "name" and "value", are there any others that are passed that are specific to Hubitat?

def myEventHandler(evt) {
    log.info(evt.name)
    log.info(evt.value)
}

The issue I'm having at the moment is the event handler is for a group of lights and I need to know which light the event is from.

There are also these:

evt.displayName (displayed name of device)
evt.device (the device itself)
evt.date

Once you have the device, you can get all of its attributes the normal way.

2 Likes

Awesome, thanks.

Just to add, I usually reference the documentation to find out the nitty gritty stuff too. I always learn something new.

I try to reference documentation too, however in the linked page there is no reference to displayName, device, or date.

I keep running into this problem every time I try and do something with a language that is new to me, especially anything that is open source. The documentation is incomplete and only marginally useful.

I actually abandoned a development project for addons to a game because their API documentation was Doxygen generated and they didn't add any useful information to it to make things more clear as to what was going on.

Its pretty confusing at first but its a groovy (or java?) thing. The documentation gives you what you need you just need to understand how it works in the language.

Referencing evt.displayName is the same as evt.getDisplayName which you will see the methods for at the bottom. I think they are called getter and setter methods. So looking at the methods at the bottom will usually give you want you need.

ex. evt.device = evt.getDevice

Hopefully that makes some sense.

That helps a lot actually. Thanks.