0
Answered
Vladimir Bykov 5 days ago • updated by Xopyc (expert) 4 days ago 9

I am developing relay module, that can have 12, 8, 6, 4 or 2 channels.

Because there no way to create a subdevices by tempate in the script, I desided to create 12 subdevices in Studio and then after user chose of the number of channels delete unnecessary subdevices.

But

1. When I add new module i3Lite show me this dialog. I dont understand for what. Do you plan to leave this dialog in the system?



2. Subdevices doesn't delete




Is this a bug or I miss something?

Answered

Hello,

in your case, you should add new subdevices via js. Youк module should find the dimmer and ask him about channels count and when your module receive channels count, the script must create the required number of subdevices

If I understand right, in script I must:

  1. Create subdevice
  2. Create widget for this subdevice
  3. Create item in this widget


But I didn't find method like .AddItem for widgets, only for popups.

May be you have an example with dinamic modules.

no, your should:

- Create widget with items in GUI

- create subdevice in js

- clone widget in js

- attach cloned widget to new subdevice

Kindly tell me which methods I should use to clone widget and to attach widget to the subdevice.

module.ClonePopup - for cloning popup

SubDevice.AddWidget - for adding widget to new subdevices


Here you can find all API and instructions

http://lite.iridiummobile.net/%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0/en

module.ClonePopup returns Object

SubDevice.AddWidget have only one input string parameter 'Name'


How can I do that?

widget object has property "Name"

So, method SubDevice.AddWidget(Name) search existing widget by Name and, if it is found, attach him to the subdevice. If doesn't find, create new widget.


Correctly?

no, if you enter the name of not existing widget, then the app will display nothing instead widget