Example: Timer on LogicMachine

Task

The following script is creating a timer for switching off specific KNX group address after specific time period. For example, there is Air Conditioner sitting on group address 1/1/1 (On/Off). You want to switch it off automatically after 50 minutes from the moment when it is switched on.

Scheduled script

Create a scheduled script which runs every minute:

Source code    
  1. -- group address or name
  2. addr = '1/1/1'
  3.  
  4. -- find required object
  5. obj = grp.find(addr)
  6.  
  7. -- object exists and current state is "on"
  8. if obj and obj.data then
  9. -- delta is in seconds
  10. delta = os.time() - obj.updatetime
  11.  
  12. -- switch off when timer expires
  13. if delta >= 50 * 60 then
  14. grp.write(addr, false)
  15. end
  16. end