Example: MASTER-SLAVE LogicMachine


How to add backup LogicMachine in the installation where SLAVE device will overtake the functionality of MASTER in case if last fails communicating with the bus.

Backup file

On MASTER device create backup file with final configuration in Utilities -> Backup and import it in SLAVE device via Utilities -> Restore

Test group address

Add test group address e.g. 1/1/1 on both devices with data type 4-byte unsigned integer

MASTER resident script

On MASTER add Resident script with Sleep interval 5 seconds and code:

Source code    
  1. grp.write('1/1/1', os.time(), dt.uint32)

SLAVE resident scrip

On SLAVE add Resident script with Sleep interval 10 seconds and code:

Source code    
  1. -- current object value
  2. curr = grp.getvalue('1/1/1')
  3. -- previous object value or current if not set
  4. prev = prev or curr
  6. -- master timeout
  7. if curr == prev then
  8. -- first error
  9. if not timeout then
  10. alert('master offline')
  11. -- enable scripts here
  12. timeout = true
  13. end
  14. -- master ok, recovered from error
  15. elseif timeout then
  16. alert('master online')
  17. -- disable scripts here
  18. timeout = false
  19. end
  21. -- save previous object value
  22. prev = curr

The script will check the KNX bus on MASTER device, if the communication fails, on SLAVE it will Enable specified scripts (comment line — enable scripts here), or if the communication is back and running – will disable the specified scripts (comment line — disable scripts here)

In case no KNX TP1 is used, you can check this example for KNX IP hot-swap solution.