A ViewON JavaScript section does not receive a browser change event merely because a tag value changes. For tag-driven logic, execute the script on its configured interval, compare the current tag value with the previously observed value, and call the required function only when the two values differ.
Why onchange does not detect the tag update
addEventListener observes supported events on event targets; it does not observe arbitrary variable or tag-value changes. A JavaScript Proxy also cannot detect an update made directly to the underlying value. It can react only when the change is performed through the proxy, so it does not solve an externally updated ViewON tag unless every write passes through that proxy.
Use interval-based change detection
The ViewON JavaScript section runs repeatedly at its configured interval. The evidence states that this interval is entered in milliseconds and has a minimum value of 100 ms. Retain the last sampled value between executions, read the current tag value with the existing ViewON tag-access command, and compare the samples.
- Configure the JavaScript section interval; use
100 msor greater. - Read the current value of the required ViewON tag.
- If no prior sample exists, store the current value without treating initialization as a change.
- Compare subsequent samples with the stored value. When they differ, execute the alarm-text function and then store the new value.
The available evidence does not provide a complete, verified tag-read expression or show how ViewON preserves script variables between interval executions. Confirm both details in the project environment instead of inferring an API name or storage scope from the incomplete expression in the source.
Diagnose the simulation
Open the browser development console with F12 during simulation and inspect it for syntax or runtime errors. If the console is clear, verify that the simulated ViewON tag actually changes and that each interval execution reads the new value rather than repeatedly reading an unchanged input.
| Check | Expected evidence | Interpretation |
|---|---|---|
| Development console | No syntax or runtime errors | The script can continue to interval and tag-value checks. |
| Script interval | Configured value is at least 100 ms
|
The JavaScript section can execute periodically. |
| Current and previous samples | Values differ after a simulated update | The alarm-text function should be called. |
| Function output | Moving alarm text and trigger-time handling update as designed | The tag-change path is working; presentation logic is a separate verification point. |
Separate tag detection from alarm presentation
First verify that the comparison detects one simulated tag transition and calls the function once. Then verify the intended moving alarm text and trigger-time display. This separation identifies whether the failure is in tag acquisition, change detection, or the alarm presentation function without assuming that simulation matches unverified eWON Flexy behavior.
FAQ
Why does ViewON onchange not fire when a tag changes?
A tag-value update is not automatically a browser change event. Poll the tag from the interval-driven JavaScript section and compare its current value with a retained previous value.
What is the minimum ViewON JavaScript interval?
The evidence specifies a minimum interval of 100 ms. Configure the section at 100 ms or greater, then verify that repeated executions observe the simulated tag update.
How do I debug a ViewON script that shows no simulation error?
Press F12 to open the browser development console and check for syntax or runtime errors. Also inspect the current and previous tag samples to confirm that the simulated value actually changes between executions.