Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
JavaScript: How to write to multiple outputs
#3
Hi, 

I'm trying to convert a selector switch to multiple Modbus outputs.
I can see that the javascript seems to work when I compile, however, the data is not sent to the Modbus Logo.

This is my code.
The outputs themselves do work towards the Modbus Logo.

see also attached screenshot.

Code:
//--- Copy values from Virtuino Variables to JavaScript variables
var BranderModus = Virtuino.readValue("InputTag"); //Read inputTag value as String. 

if (BranderModus == 1) {
  Branderuit = '{"tag":"OutputTag1", "value":1}';
  Branderaan = '{"tag":"OutputTag2", "value":0}';
} else if (BranderModus == 2) {
  Branderuit = '{"tag":"OutputTag1", "value":0}';
  Branderaan = '{"tag":"OutputTag2", "value":0}';
} else if (BranderModus == 3) {
  Branderuit = '{"tag":"OutputTag1", "value":0}';
  Branderaan = '{"tag":"OutputTag2", "value":1}';
} else {
  result = null;  // return null if you don't want to send a value to output variable
}

result = [Branderuit, Branderaan];


Attached Files Thumbnail(s)
   
Reply


Messages In This Thread
RE: JavaScript: How to write to multiple outputs - by Dkyndt - 04-11-2023, 10:48 AM

Forum Jump:


Users browsing this thread: 3 Guest(s)