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.

IrrigationCaddy integration module
#1
<- EDIT: updated version, download it again and look at last post for changes. ->

Hi,
here is a module for interacting with IrrigationCaddy controller.
As usual you can find module and example attached.


I use two event based script. I trigger them for updating status or updating configuration use a KNX group.

The script for updating the status is:

Code:
old_print = print
debug_level = 0
print = function(...)
 if ( verbose ) then
   log(...)
  end
end

irrigationcaddy = require("user.IrrigationCaddy")
syslog_level = ERR
verbose = false


irrigationcaddy.ip = "192.168.1.100"

irrigationcaddy.update()

print ( string.format ( "IC status %s", irrigationcaddy.allowRun ) )

ic = grp.getvalue ( '0/1/40' )
ic_status = grp.getvalue ( '0/1/41' )

if ( ic_status ~= irrigationcaddy.allowRun ) then
print ( string.format ( "IC status (%s) different from device (%s)", tostring(ic_status), tostring(irrigationcaddy.allowRun) ) )
grp.write ( '0/1/41', irrigationcaddy.allowRun, dt.boolean )
end

The script for updating the configuration is:

Code:
irrigationcaddy = require("user.IrrigationCaddy")
debug_level = 5
verbose = true


irrigationcaddy.ip = "192.168.168.73"

ic = grp.getvalue ( '0/1/40' )
ic_status = grp.getvalue ( '0/1/41' )

print ( string.format ( 'Evento da %s per %s tipo %s', event['src'], event['dst'], event['type']) )

group = event['dst']

if ( group == '0/1/40' ) then
    if ( ic_status ~= ic ) then
   print ( string.format ( "Changing IC status (%s)  to %s", tostring(ic_status), tostring(ic) ) )
   if ( ic == false ) then
     irrigationcaddy.disable()
   elseif ( ic == true ) then
     irrigationcaddy.enable()
   end
   grp.write( '0/1/49', true, dt.boolean )
    end
end

Finally the script that triggers the update is:

Code:
log ( 'Triggering IC update' )
grp.write('0/1/49', true, dt.boolean )
return

Where group 0/1/49 is the triggering group.

I've chosen this approach to trigger update on configuration and on scheduled base.

Luca

Attached Files
.lua   irrigationcaddy.lua (Size: 11.93 KB / Downloads: 11)
.lua   testirrigationcaddy.lua (Size: 805 bytes / Downloads: 5)
Reply


Messages In This Thread
IrrigationCaddy integration module - by lpala - 24.01.2017, 21:06

Forum Jump: