loupedeck-commander 1.2.9 → 1.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
File without changes
@@ -456,10 +456,13 @@ export class Button {
456
456
  state : key,
457
457
  ...state
458
458
  }
459
- let val1 = format(state.value,params)
460
- if (val1 === val.toString()){
461
- this.#index = i;
462
- break;
459
+ if (state && state.value !== undefined){
460
+ let strVal = state.value.toString()
461
+ let val1 = format(strVal,params)
462
+ if (val1 === val?.toString()){
463
+ this.#index = i;
464
+ break;
465
+ }
463
466
  }
464
467
  //break;
465
468
  }
package/common/utils.mjs CHANGED
File without changes
@@ -91,8 +91,10 @@ export class OPCUAIf extends BaseIf {
91
91
  const elem = field[key]
92
92
  // groupnode
93
93
  if (elem.nodeid) {
94
- let format = this.formatString(elem.nodeid, options)
95
- let monitoredItemId = await this.Subscribe(format)
94
+ options["key"] = key
95
+ let formattedNodeId = this.formatString(elem.nodeid, options)
96
+ let monitoredItemId = await this.Subscribe(formattedNodeId)
97
+ console.log("Subscribe to",formattedNodeId)
96
98
  this.buttons[monitoredItemId] = i
97
99
  }
98
100
  // statenode
@@ -222,16 +224,23 @@ export class OPCUAIf extends BaseIf {
222
224
  async Disconnect() {
223
225
  if (this.#client) {
224
226
  this.LogInfo(`OPCUAIf: Disconnect\n`);
225
- await this.#client.Disconnect()
227
+ if (this.#session)
228
+ await this.#client.closeSession(this.#session,true)
229
+ this.#session = undefined
230
+ this.#client = undefined
226
231
  this.LogInfo(`OPCUAIf: Disconnected\n`);
227
232
  }
228
233
  }
229
234
  async Connect(url) {
230
235
  let self = this
236
+ if (this.#client){
237
+ console.log("Closing session first")
238
+ await this.Disconnect()
239
+ }
240
+
231
241
  this.#client = OPCUAClient.create({
232
242
  applicationName: "NodeOPCUA-Client",
233
-
234
- endpointMustExist: false,
243
+ endpointMustExist: true,
235
244
  // keepSessionAlive: true,
236
245
  requestedSessionTimeout: 60 * 1000,
237
246
  securityMode: MessageSecurityMode.None,
@@ -245,10 +254,11 @@ export class OPCUAIf extends BaseIf {
245
254
  defaultSecureTokenLifetime: 20000,
246
255
  tokenRenewalInterval: 1000
247
256
  });
257
+
248
258
 
249
259
  this.#client.on("backoff", (retry, delay) => {
250
- if ((retry % 10) == 0)
251
- self.LogInfo(`OPCUAIf Try Reconnection ${retry} next attempt in ${delay}ms ${self.#endpointurl}\n`);
260
+ //if ((retry % 10) == 0)
261
+ // self.LogInfo(`OPCUAIf Try Reconnection ${retry} next attempt in ${delay}ms ${self.#endpointurl}\n`);
252
262
  });
253
263
 
254
264
  this.#client.on("connection_lost", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loupedeck-commander",
3
- "version": "1.2.9",
3
+ "version": "1.2.10",
4
4
  "description": "A system to ease working with LoupeDeck devices using CMD-line, OPC/UA or HTTP-client interfaces",
5
5
  "main": "index.mjs",
6
6
  "scripts": {