is there a way to activate and deactivate the Modbus RTU Serial 1 by an event script?, cuz´I want to use an object for doing this from the visualization without using the administrator account
I'm trying to use 2 Modbus Masters writing in KNX(The LM and an external one)reading common devices but clearly not at the same time, so the master change should be done by the final user, switching between them without getting access over the LM config. That's why I want to set up a switch in user's visualization for make this change.
This is not the best approach. You should make one device talking to slave and the other two masters should exchange data in another way. LM can be also modbus slave.
28.08.2019, 15:25 (This post was last modified: 28.08.2019, 15:27 by HannPark.)
Thanks Daniel,
But what happened if I had 2 masters reading same devices?, in Modbus that's imposible but...you can do it if you turn off one master when the other one is working, as I see.. that's like a redundant modbus network, that's the thing that I wanna get... it's easy from the admin account cuz' you just go to the modbus tab and disable RTU and it's done...but the tricky thing is to do it from the visualization...
Use this event script to emulate a web request to enable/disable RTU. Attach it to a boolean object.
Code:
value = event.getvalue()
require('uci')
require('json')
function getvar()
return 'config-save'
end
function json.data()
return { enabled = value }
end
dofile('/lib/genohm-scada/plugins/modbus/web.lua')
/lib/genohm-scada/plugins/modbus/web:0: attempt to index global 'ngx' (a nil value)
stack traceback:
/lib/genohm-scada/plugins/modbus/web: in function 'restart'
/lib/genohm-scada/plugins/modbus/web: in function </lib/genohm-scada/plugins/modbus/web:0>
/lib/genohm-scada/plugins/modbus/web: in function </lib/genohm-scada/plugins/modbus/web:0>
[C]: in function 'dofile'
User script:14: in main chunk
On firmware 2025.12 (20251204), disabling a Modbus RTU device — via the RTU settings checkbox, via webrequest('general','plugin',{plugin='modbus',request='config-save',data={enabled=false}}), or via the original dofile('/lib/genohm-scada/plugins/modbus/web.lua') method (which correctly invokes the plugin's internal restart function) — correctly persists the disabled state in all three cases, but the live polling process continues scanning the device regardless, generating timeout errors at the normal poll interval.
Also, pressing the 'RTU Scan' button used to give an error message (can't remember the correct wording) when all RTU's are disabled. But now it just shows a new window for selection scanning options as if the RTU were enabled.
Yesterday, 08:46 (This post was last modified: Yesterday, 08:50 by EjvindHald.)
I think I need to be more precise. I have a device (air condition) where the power is physically set to on or off depending on usage. This goes hand in hand with enable and disabled modbus RTU.
The script for enable or disable RTU is working fine in LM. It does exactly the same as if you had done the operation using the UI in Logic Machine.
However, if a defined RTU appears disabled in modbus UI, it should not be polled anymore. In the last firmware, the polling continues also in disabled mode and this generates constant entries in my modbus log, because the device is turned off.
I do not need do to RTU scan, but the behavior of this functionality is no longer providing an error message when all is disabled. That is the only reason why I referred to it.
I have attached screenshots as you requested when I turn it on and later turn it off. The checkmark in the modbus UI is correctly set on and off via this operation. Physical polling is the problem.
Steps to reproduce:
Connect a physical RTU modbus device to LM
Define the modbus in LM
Verify the polling is working.
Disable the RTU in the LM modbus UI.
Turn off power or remove external RTU modbus device.
Now you will see in the modbus log that polling continues and is failing.
I have 8 registers mapped per device, and this has been like that for a few years. I have included the profiles for both and a mapping screen shot for one - the other follows the same pattern.