How to read initial value of devices

I have created my custom plugin and inside onChangeRequest function I can read values of devices that I need and then I update local variable (attribute).
But when plugin start these variable not contain correct value until device values change for first time.
Normally I initialize all my attribute with a special value (example -1) and logic will work safe.
But there is a way fo force onChangeRequest function or get initial values of devices at begin?
Thanks, Paolo

You will usually use “onChangeRequest” to send commands to your device. Your polling loop or connect methods will update the attributes. In “onConnect” you can loop through your devices & call “onChangeRequest”.

Is possible do same also for KNX variable?
becouse I don’t find the way to loop through variables

image

Normally I use this sintax:
plugin.Devices[“ID”].variable = value;

Thanks, PAolo

KNX variables are automatically read when the app starts or is refreshed. You shouldn’t have to write any logic to update them.

I’m probably stuck on a stupid point. I can’t understand what is the syntax for reading and writing the values of KNX variables directly from within the javascript code of the plugins.
can you help me? Thank you very much

Are you talking about Plugins or a ScriptAction in a Scene or XAML page?

Plugins are isolated from one another. A Plugin cannot access variables from KNX or any other integration. Plugins have to follow the same rules as the source code for our official integrations. Think about it this way, we wouldn’t want our Sonos integration to be dependent on Denon. Not everyone with a Sonos Connect or Port is going to have it attached to a Denon AVR.

Any scripting you do that links your Plugin to KNX has to be done by using a ScriptAction in Scenes or XAML pages. There, you can access your variables by calling the GetDeviceAttribute function:

var x = App.GetDeviceAttribute("MyLight.Switch");

You were clear and in fact I expected the behavior inside the plugins to be isolating. Thanks for the clarification