SmartApp UI Customization Questions

I am relatively new to the SmartThings environment. I have a general understanding that a Device communicates with the SmartThings cloud (and SmartThings Hub) by virtue of its Device Handler. I have also noticed that the IDE can be employed to change Device Handlers (eg, to use a custom device handler so something like the ZWaveTweaker device handler).

I noticed that changing the Device Handler for a particular device not only changes the functionality (to some limited extent), but also the user interface (eg, the screen that appears in the Classic App when you select the particular device associated with that device handler). The simplest example is ZWaveTweaker, which provides a ā€œcustomā€ interface for changing a deviceā€™s parameters.

I am wondering how (and the extent to which) the device handler can control the user interface that shows up in the Classic App. Can someone point me to the place in the Smartthings documentation that explains the APIs or other mechanisms for controlling not only device functionality/communication, but also the UI in the classic app?

Tagging @krlaframboise , just because heā€™s written a bunch of them. :wink:

2 Likes

https://docs.smartthings.com/en/latest/device-type-developers-guide/tiles-metadata.html covers the device handler ā€˜tilesā€™ - the UI for the Classic SmartApp and you can explore from there to get a grasp of how device handlers and smartapps work in the ā€˜classicā€™ environment.

2 Likes

I see. Does the code in the device handler get executed in the SmartThings cloud (or on a local Hub), or is some or all of that device handler code sent to and executed by the App itself (eg, on an iPhone client)?

Both. Like any client-server situation.

Changes a bit in the New SmartThings App, but thereā€™s still split and sharing of duties.

1 Like

Does that mean the App (Classic or New) can interpret Groovy code, or are there just API calls (whether or not published) governing the communication between the App and the SmartThings cloud or hub?

I also just noticed that the new App appears to be adding back much of the functionality found in the Classic app (and more). It seemed a bit on the slow side, but I only tried it briefly. I had been ignoring it due to a lack of functionality, but maybe itā€™s worth giving another look at this point.

No.

The Groovy Code in legacy Device Type Handlers contains a ā€œmetadataā€ section which the platform translates into whatever data structures are used by the Classic App to render UI elements.

The New App offers an HTML5-type of descriptive language for custom device UI plug-ins. But thatā€™s all detailed in the online developer documentation.

1 Like

The built-in groovy device type handlers in the SmartThingsPublic repository are required for all hub connected devices whether youā€™re using the new or classic mobile app so I wouldnā€™t consider them legacy handlers, but the ā€œtilesā€ and ā€œpreferencesā€ sections of the metadata are only used by the classic app.

The ā€œvidā€ attribute in the metadata definition determines which UI it should display in the new mobile app and the ā€œtilesā€ section of the metadata allows you to define all the tiles that should be displayed in the classic mobile app.

1 Like

I think there are plenty of device types which do not have source code in the public repo.

And I presume there is a growing number of device types (even for Hub connected) which are only written using the new, non-Groovy, legacy deprecated API.

Itā€™s only a matter of time, no?

Can you name one z-wave or zigbee handler that isnā€™t in the public repository?

I agree that theyā€™ll probably get rid of the groovy code base at some point, but Iā€™m pretty sure that all z-wave and zigbee devices require a groovy handler in order to work in either mobile app.

Iā€™m basing that off of the publication process for hub connected devices in the new developer workspace and the way theyā€™re using that vid attribute to tie the device code to the UI, but I could be wrongā€¦

No. Perhaps there arenā€™t any - yet.