1.1.4 questions

Continuing the discussion from Hub Update 1.1.4:

thanks for making this async … this should help a great deal with HE performance. just updated to the latest … will check over the next week.

thanks for adding these. does unsubscribe now also support unsubscribing to location events?

how is this one different from the existing subscribe(buttonDevice, "pushed.X", buttonEventHandler)?

thank you.

App input type "button" is a ui button, not a device. It presents a button that can be pressed in the ui.

See the Pause/Resume button introduced in a few apps for an example: RM, Simple Lighting, Motion Lighting....

2 Likes

Didn't realize this. Great addition.

1 Like

ahh … so functionally similar to input type bool with submitOnChange:true … except its a Pause/Resume button calling another function first instead of like a toggle just returning control to the same function?

Not really similar to input of bool, and it is not a Pause/Resume button, although it is used to create one.

Here is example:

input "thisButton", "button", title: "Press this button"

That renders in the ui like this:

When that button is pressed, this method is called:

def appButtonHandler(btn) {
// from the button above, btn = "thisButton"
}

That method runs, and then the page is refreshed as if there were a submitOnChange: true. The submitOnChange: true is implicit to the input for type button.

An app can have multiple buttons, and they will each call that method. The method has to sort which one was pressed, and what to do about it. See HSM for a more complex example of buttons in the UI.

1 Like

got it. thank you.

any word on this?

Yes, it does.

1 Like

the unsubscribe does not seem to work. what am i doing wrong?

	subscribe(location, "sunrise", test)
	subscribe(location, "sunset", test)
    
    unsubscribe(location)

[app:569] 2018-09-29 17:28:35.107:errorgroovy.lang.MissingMethodException: No signature of method: app15382673065971318675034.unsubscribe() is applicable for argument types: (com.hubitat.hub.domain.Location) values: [home] Possible solutions: subscribe(java.lang.Object, java.lang.String, java.lang.Object) on line 40 (updated)

line 40 is the unsubscribe.

Wouldn't it be just as simple to ignore those events in the event handler when you don't need them?

do that already. but if the unsubscribe is available for location might as well unsubscribe them. :slight_smile:

My answer wasn't clear: unsubscribe() should unsubscribe from location events. I don't know about the specific version of unsubscribe(location).

@bravenel
Bruce can a variable be used in the ‘title’?
I’m guessing that’s what you use for ‘pause/resume’

Andy

Yes, a variable can be used. Also, this new input type supports a few additional options:

textColor: "(css name or #hex)"

and

backgroundColor: "(css name or #hex)"

The button input will trigger the appButtonHandler(btn) method and then trigger a submitOnChange to update the UI. Keep in mind, this will submit all fields on the page just like any other field that has a submitOnChange:true

1 Like

Brilliant!
Thanks for the info Patrick

Andy

Hello! How do you set the button's position? I see that in RM the update button is to the far right of the ui.