Virtual Buttons


(Ardenite) #21

Question for everyone. Does this software approach fix the Enerwave 7-Button Scene Controller issue where the first button press after a period of non-use does absolutely nothing? Some users have described the device as going into some kind of “sleep mode”. Mine often takes 30 seconds until it will send (or until ST will process) an action via button press.


(Brice; SmartRulesApp.com) #22

I haven’t had that issue, so I’m not sure, but no, I don’t think this would affect that issue, as it does not change anything with the hardware configuration or the main device type.


#23

@obycode - do you know if this works with the new hub and latest app?
I’m trying to use it on a v2 hub, with a Securifi key fob, and every time I try to set it up, I get the same error: the app says “Failed to save page: DefaultPage,” and the log says:
java.lang.NullPointerException: Cannot invoke method toInteger() on null object @ line 32.

Line 32 is:
def numButtons = buttonDevice.currentValue("numButtons").toInteger()

I’ve tried using several different device types: the one from the Virtual Buttons project on GitHub, the more recent version by @kevintierney, with the additions from the Virtual Buttons version to add numButtons, and a version I modified further to rename the buttons. All produce the same error in Virtual Buttons, but work fine in the key fob Thing.

This is my first attempt to install a community SmartApp so I don’t know what to do to debug (i.e., how do I trace what’s going wrong with the call in line 32 that seems to be pulling null instead of the string from the device definition)


(Brice; SmartRulesApp.com) #24

It looks like numButtons has never gotten a value, so that call to currentValue is returning null. Does the device type you’re trying set it? Maybe it is set only during initialization and you changed the device type after it was initialized?


#25

The device type seems to set it, with the line
updateState("numButtons", "3")
in the def configure(){ call. I did change the device time a few times trying to debug this, I’ll try deleting the device and re-initializeing it.


#26

Yep, the problem was at initialization, the log said:
groovy.lang.MissingMethodException: No signature of method: script1446902832479539891518.updateState() is applicable for argument types: (java.lang.String, java.lang.String) values: [numButtons, 2]

So I replaced updateState("numButtons", "2") with
sendEvent(name: "numButtons", value: "2", displayed: false)
and that seems to have fixed it. I actually had value as 4 the first time so now I has four virtual buttons, two of which don’t work. Seems I’ll have to delete and re-add the fob again with the corrected code.


(Brice; SmartRulesApp.com) #27

Oops :grimacing:. That’s called copying and pasting without paying attention (or testing). I had made sure it worked with the device I was using only. Sorry, my bad. The fix is in the repo now.


(Adam V) #28

Has anyone managed to get proper button “holds” as described above, that could be used with a vol up / down or blinds up/ down working with any devices in smartthings? I’m a little concerned if this functionality is fundamentally missing as it means real word control of devices is pretty limited.

Anyone?


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #29

Are you referring to Physical examples or Virtual?


(Adam V) #30

Both preferably - but the priority on physical


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #32

Virtual Continuous Hold Buttons are conceptually possible to create, but probably need a new Attribute or Attribute State (and, optionally, Command). A Momentary “pushed” is considered a single Event of no duration. Adding a duration is one option. More concise would be to just add a “released” Event and SmartApps would repeatedly perform an incremental action (e.g., volume up) between the two events. Either way is not likely to be satisfactorily responsive given SmartThings’s cloud latency.

Physical Continuous Hold Buttons are not possible unless the actual physical device sends both “pushed” and “released” Events (or equivalent), per the first paragraph.

Button Controllers such as the Aeon Minimote do not have a “continuous hold” function (unless it is buried in the detailed specifications and not yet coded into the Device Handler…). The “held” behavior of buttons #1-4 are just “momentary pushed” Events with a “shift-flag” (i.e., they look just as if the remote had buttons #5-8 added).


You know… that’s the pretty much the exact same thing I said back in May 2013, except back then I made no reference to Virtual Buttons, as no one had created any yet!


(Djcampis) #33

I’m getting the same error as mlshakim, but with the Aeon minimote. Any thoughts?


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #34

Detail? (sorry… I don’t want to trace back the thread…). Which Device Type Handler (official or custom), which SmartApp…

I believe that the “offical” Device Type for the Aeon Minimote does not set numButtons, therefore any SmartApp using it has to have code to handle null and make an assumption of 4 or 8 buttons…

(At least that’s what I do and needed to do in my SmartApp: Use Buttons As PIN Input (“Security Keypad”) e.g., Aeon Aeotec Minimote, ZWN-SC7 Enerwave 7 Button; trigger to Routines, lock/unlock, arm/disarm, mode, lights )


(Brice; SmartRulesApp.com) #35

Yes, Terry is right. I don’t think the official device type has numButtons, but the one in my GitHub repo does ( https://github.com/obycode/smartthings-smartapps/blob/master/VirtualButtons/AeonMinimote.groovy ). Setting a default value when one is not specified would be smart, but my code doesn’t currently do that. I’ll try to add that at some point, or anyone else is welcome to fork the code and make the change.


(Djcampis) #36

This is the error I’m receiving. And yes, I am using the “official device type”. Should I try the custom device type obycode published? Or is there a better option?


(Brice; SmartRulesApp.com) #37

Yes, the custom device type would fix the problem, or changing the SmartApp to use a default of 4 buttons as @tgauchat suggested would also work.


#39

Late to the game and great app, however I’m having issues when I go to use the virtual buttons as triggers. For some reason I’m getting a null pointer occurring: Cannot get property ‘buttonNumber’ on null object @line 75 (buttonHandler)

If I use a “real” button for the same routine, it works without issue. Initially I misread thinking it was wanting the virtual button to have a button number, but seems somewhere a null is getting passed where it shouldn’t be.

[34b81842-b2d8-40b7-a36a-23cb829bc923](https://graph-ap02-apnortheast2.api.smartthings.com/ide/logs#34b81842-b2d8-40b7-a36a-23cb829bc923) 2:18:27 PM: error java.lang.NullPointerException: Cannot get property 'buttonNumber' on null object @line 75 (buttonHandler)
[34b81842-b2d8-40b7-a36a-23cb829bc923](https://graph-ap02-apnortheast2.api.smartthings.com/ide/logs#34b81842-b2d8-40b7-a36a-23cb829bc923) 2:18:27 PM: trace daysOk = true
[34b81842-b2d8-40b7-a36a-23cb829bc923](https://graph-ap02-apnortheast2.api.smartthings.com/ide/logs#34b81842-b2d8-40b7-a36a-23cb829bc923) 2:18:27 PM: debug evt.name: pushed
[34b81842-b2d8-40b7-a36a-23cb829bc923](https://graph-ap02-apnortheast2.api.smartthings.com/ide/logs#34b81842-b2d8-40b7-a36a-23cb829bc923) 2:18:27 PM: debug evt.name: pushed
[2d417002-79b0-4d03-ba2f-b63053d7cf7c](https://graph-ap02-apnortheast2.api.smartthings.com/ide/logs#2d417002-79b0-4d03-ba2f-b63053d7cf7c) 2:18:27 PM: debug pushing the virtual button
[2d417002-79b0-4d03-ba2f-b63053d7cf7c](https://graph-ap02-apnortheast2.api.smartthings.com/ide/logs#2d417002-79b0-4d03-ba2f-b63053d7cf7c) 2:18:27 PM: debug getChildDevices(false), children=4
[2d417002-79b0-4d03-ba2f-b63053d7cf7c](https://graph-ap02-apnortheast2.api.smartthings.com/ide/logs#2d417002-79b0-4d03-ba2f-b63053d7cf7c) 2:18:27 PM: debug buttonEvent: button pushed ({"buttonNumber":1})
[02064b8c-1729-4b66-8c21-cb4fafdfe27e](https://graph-ap02-apnortheast2.api.smartthings.com/ide/logs#02064b8c-1729-4b66-8c21-cb4fafdfe27e) 2:18:27 PM: debug Executing 'push'
[2d417002-79b0-4d03-ba2f-b63053d7cf7c](https://graph-ap02-apnortheast2.api.smartthings.com/ide/logs#2d417002-79b0-4d03-ba2f-b63053d7cf7c) 2:18:27 PM: debug pushing the virtual button

Any suggestions?