SmartThings Community

Is it possible to programmatically rename the 'typeName' of a SmartApp's child device?

(Kurt Sanders) #1

Is it possible to programmatically change an existing device’s ‘typeName’?

I would like to allow a user to determine the deviceType of an existing child device, that was previously created with the same SmartApp. Both deviceTypes exist in the users “My Device Handlers”.

I already tried using the following code (deviceID is the DNI is the child device):

device = getChildDevice(deviceId) == “New Device Name” // Successful
device.label == “New Label Name” // Successful
device.typeName == “Name of a Valid DTH” // UNSuccessful: Does not work or generate any error

This code does not generate an error, but it does not change the typeName of the device. I can change the label and name of a child device, but it appears that changing the typeName is restricted? BTW, executing device.typeName == Name of a Baseball Player does not generate an error either. So what am I missing here?

Ultimately, I want to allow the user to select from a defined list of DTH’s a:

  1. DTH with background tile colors ON
  2. DTH with background tile colors OFF (Android users have issues displaying some tiles with background colors)

(Tony Fleisher) #2

Have you considered waiting to create the device until after the selection is made?

(Dave Gutheinz) #3

I am understanding you are trying to do this in ‘preferences’. The answer is NO. The screen creation must exist at the time of display, therefore, all data must be hard coded.

Option 1: Create two device handlers and then make the type name (i.e. colorTiles or b_wTiles) a chosen option in the Service Manager with the name “tileType”. It would become a setting and at install your would designate the type “myDevice${tileType}” (which is the name you assign to your device handler).

Option 2: Create the 2nd DH type and have the user change it by editing the device’s page on the IDE.

(Kurt Sanders) #4

I could go this route, but was hoping to be able to offer a ON/OFF switch in the app during and after setup. Thanks!

(Kurt Sanders) #5

Thanks for response.

  1. I will most likely implement this for the initial install by the end user and then hide this choice after setup, since I cannot programmatically switch the nameType.

  2. The end user can always manually switch the device’s nameType manually via the IDE (My devices), but I, like so many others, have had so many ‘your not authorized’ issues with doing this in Chrome. I always have to invoke Chrome’s Incognito mode to do anything related to changing any device’s characteristics (name, label, group, nameType, etc) in the ST IDE. ugh. Also, the end user might select the wrong nameType in the list and really mess things up. Just wish I could have made it bullet proof for them without having them have to do it manually, or re-install from scratch.