Change Device Name in Create New Device Dialog

Posted on
Wed Aug 18, 2021 6:28 pm
michaelcreamer offline
Posts: 34
Joined: Jul 14, 2015

Change Device Name in Create New Device Dialog

I am creating a Plugin that allows the user to select existing Devices to monitor.

To assist the user, I would like to copy the Name of the selected Device (prefixed with something to make it unique) into the Name field on the Create New Device dialog.

So, if the Device "Side Door Lock" (see image below) is chosen I'd like to copy "XXX:Side Door Lock" into the Name field on the Create New Device dialog.

I know I can update the Device in the Device listing with dev.Name = "XXX:Side Door Lock" but when the Save button is pressed the Name reverts to the Name field on the dialog.

Is it possible for my Python code to update the Name of the new device when the user selects a Device in the "Config Sensor" dialog?

CreateNewDevice.png
CreateNewDevice.png (75.28 KiB) Viewed 1177 times

Posted on
Thu Aug 19, 2021 7:25 am
autolog offline
Posts: 3989
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Change Device Name in Create New Device Dialog

Example code in deviceStartComm:
Code: Select all
    def deviceStartComm(self, dev):
        #
        #
        #
        new_name = u"NEW DEVICE NAME"  # Whatever your device name is
        if dev.name != new_name:  # Check so that you don't update the name every time the device starts
            dev.name = new_name
            dev.replaceOnServer()  # Must replace on server so that change doesn't get lost

Hopefully that will point you in the right direction. :)

Posted on
Thu Aug 19, 2021 10:40 am
michaelcreamer offline
Posts: 34
Joined: Jul 14, 2015

Re: Change Device Name in Create New Device Dialog

Jon,

Thanks for your reply.

That code does change the device name in the Device Listing but as soon as the user clicks the Save button on the dialog the new device is renamed to “new device x” from the dialog Name field.

I’m hopping there is a way to update the Name value in the dialogue itself.

Thanks!

Posted on
Thu Aug 19, 2021 11:25 am
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Change Device Name in Create New Device Dialog

No there’s no way to update the dialog box field.


Sent from my iPhone using Tapatalk

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Aug 21, 2021 2:04 pm
michaelcreamer offline
Posts: 34
Joined: Jul 14, 2015

Re: Change Device Name in Create New Device Dialog

Thanks for the responses!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 7 guests