Logic Machine Forum
Information about database synchronization, storage, script and others - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Information about database synchronization, storage, script and others (/showthread.php?tid=2680)



Information about database synchronization, storage, script and others - Carlos Padilla - 09.06.2020

Hello partners, I hope you are excellent especially in these times of pandemic. I come to you since perhaps they have some experience in this regard and could indicate some paths that I could take, with this I am not saying that they make me the codes, since I know that the purpose of this forum is to help with the concerns that arise. Already growing up in the world of logic machine and thanks to your help and special from Admin and Erwin, I have been able to take many things forward.


As for the inconvenience that I have is in a hotel, I have 10 logic machines, which are communicated by their visualization. In addition to the above there are certain configurations that I generate in any of the 10 and I synchronize them with the others through HTTP REQUEST, this option has helped me a lot in this regard. The problem is that I have to create some species of "groups" or rather the hotel will create them with which you will be free to do them, I have to associate rooms with these groups and in turn some actions which may or may not have some time schedules . The above must be added, saved, modified and deleted in any logic machine, but I must synchronize this information with the rest. As you realize, the above implies knowledge in databases, storage and other things that I do not know. Therefore, I ask you if you have information, threads, documentation and suggestions that may help me, to know where I should start. Thank you for your attention and any information will be very useful to me.


RE: Information about database synchronization, storage, script and others - Erwin van der Zwart - 09.06.2020

Hi,

Can you explain what the purpose is of having several schedulers that are synced all the time, why don't you use 1 master scheduler that is located in 1 LM and control the scheduled objects in the other LM's over KNX IP? You can add the Master scheduler in every visu by a frame so when you change it, it change in all the visu's, this way you don't need to sync anything as it is centralized already..

BR,

Erwin


RE: Information about database synchronization, storage, script and others - Carlos Padilla - 10.06.2020

Hello, thanks for answering. Synchronization is required because each logic machine controls from 5 to 12 rooms and if you have only one calendar server, there may be a possibility that if the logic machine with the calendar server goes down, the whole hotel will stop working (111 rooms On the other hand, if each logic machine has control and the calendar server, in case one of them fails, the worst thing that can happen is that 12 rooms stop working and 111 rooms stop working. On the other hand, in each logic machine, the same group addresses are repeated, which saves a lot of time on the links, script and others, that's why sometimes for a general configuration, it is convenient to synchronize it (it should be noted that the Synchronizations I do by request, since I have a filter table to prevent a telegram from jumping from one logic machine to another).


RE: Information about database synchronization, storage, script and others - Erwin van der Zwart - 11.06.2020

Hi,

I was triggered by the request and wanted to see if it was do-able and offcourse as always there is a way and i liked the challenge (:

You need to create sync.lp on the master controller so run the script once in there, now we can request the scheduler data from the main database from another controller.

In the other controllers you need to create a event based script with a trigger or a resident/scheduled script at the desired interval, you also need to create the schedulers and holidays with the exact same names as in the main controller., events can be empty as they are synced anyway.

Events and holidays will by synced from the main controller, all scheduler events and holidays with the same name will be cleared first (after a check that request for data was succesful) and then populated with the data from the main controller. All schedulers events and holidays in the slave controller with another name will stay untouched.

The start/end date from schedulers with the same name as in the main controller will also be syncronised, including the active state. So if you disable the scheduler or events in the main controller, they will be also synced as disabled in the slaves.

Group adrresses for output and disabling the scheduler are not synced so you can attached them to any addresses you like in the slaves.

It works even over the internet, i just uploaded my scheduler events to the LM demo and it was poulated with all events i have at home (:

Here are the 2 files you need:

.lua   Create sync lp.lua (Size: 1.21 KB / Downloads: 37)
.lua   Sync schedulers from another controller based on name requires sync.lp on other controller.lua (Size: 4.91 KB / Downloads: 32)

BR,

Erwin


RE: Information about database synchronization, storage, script and others - BrentW - 20.01.2021

(11.06.2020, 00:16)Erwin van der Zwart Wrote: Hi,

I was triggered by the request and wanted to see if it was do-able and offcourse as always there is a way and i liked the challenge (:

You need to create sync.lp on the master controller so run the script once in there, now we can request the scheduler data from the main database from another controller.

In the other controllers you need to create a event based script with a trigger or a resident/scheduled script at the desired interval, you also need to create the schedulers and holidays with the exact same names as in the main controller., events can be empty as they are synced anyway.

Events and holidays will by synced from the main controller, all scheduler events and holidays with the same name will be cleared first (after a check that request for data was succesful) and then populated with the data from the main controller. All schedulers events and holidays in the slave controller with another name will stay untouched.

The start/end date from schedulers with the same name as in the main controller will also be syncronised, including the active state. So if you disable the scheduler or events in the main controller, they will be also synced as disabled in the slaves.

Group adrresses for output and disabling the scheduler are not synced so you can attached them to any addresses you like in the slaves.

It works even over the internet, i just uploaded my scheduler events to the LM demo and it was poulated with all events i have at home (:

Here are the 2 files you need:


BR,

Erwin
Hi Erwin,

I'm completing a project where I'm doing a similar task with the exception of changing the scheduler_events.

This is the code I am using to update the dB:
db:update('scheduler_events', { active = 1, start_hour = start_Hour , start_min = start_Min ,  daysofweek = days_Active, holidays =  holidays_Set }, { id = calc_start_ID })

Following this update the values are changed in the scheduler but the event will not trigger.
I have manually changed the start time and it will indeed trigger at this point.
I've also inspected the dB and everything seems right there too.
Any Ideas?

B.W


RE: Information about database synchronization, storage, script and others - BrentW - 20.01.2021

Just a Quick update here.

I managed to find the info here;
https://forum.logicmachine.net/showthread.php?tid=265&highlight=scheduler

It is necessary to run the clearschdulers() function to clear the temp data.

Hope this helps anyone suffering the same problem.

B.W