This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Reactor update by script
#1
Hello,

I'm trying to automatically link group objects to the reactor using a script that makes the modifications directly inside the database. For example, to link the object 1/1/x to the UIOy of the reactor as a digital output, I'm just doing this:

Code:
name = 'Digital Output 1'
x = 1
y = 1

db:query('UPDATE reactorra SET name = ?, address = ?, bus_write = 1, param_1 = "out_bin", param_3 = 0, param_4 = 0 WHERE id = ?', name, knxlib.encodega("1/1/" .. x), "io-" .. y)

This is seemingly working, but actually the link is not really made (changing the boolean value of the object doesn't the state of the output in the reactor) until I manually edit one of the reactor entries. As soon I validate a single manual edit, all the entries start to work correctly.

I know that just updating the database doesn't work out of the box for some manipulations that are supposed to be done via the web interface, but there is always a workaround to make it work. I found 2 examples on the forum:
- Updating the schedulers (https://forum.logicmachine.net/showthread.php?tid=265): here the changes are made via a db update and are then validated by calling a special function;
- Updating the Modbus parameters (https://forum.logicmachine.net/showthread.php?tid=2200): here all the changes are made using a specific function that seems to simulate a web request. 

As I don't understand exactly the internal mechanisms that are used in both cases, I can't figure out how to make it work for a reactor update but I guess that the solution is similar (and can be reproduced for any kind of update).

(And of course I'll be very happy if someone can explain quickly how it works so that next time I can succeed without asking :-) )

Thanks for your help!
Reply
#2
You need to send a reload signal after db update.
Code:
pid = os.checkproc('reactorra')
if pid then
  os.kill(pid, signal.SIGUSR1)
end
Reply
#3
(04.09.2019, 12:31)admin Wrote: You need to send a reload signal after db update.
Code:
pid = os.checkproc('reactorra')
if pid then
  os.kill(pid, signal.SIGUSR1)
end

Hello admin,

Thanks a lot, it works perfectly!

The solution you propose here is quite different from the ones that were proposed for the schedulers and Modbus parameters update: there is no "unified" way to simulate web requests from a script?

Thanks again :-)
Reply


Forum Jump: