Author Topic: Autelis Pool Control and Vera  (Read 14061 times)

Offline theal

  • Jr. Member
  • **
  • Posts: 50
  • Karma: +0/-3
Autelis Pool Control and Vera
« on: June 07, 2013, 08:41:58 pm »
Has anyone successfully made Autelis Pool Control to work with Vera?

Autelis makes RS-485 to Ethernet adapters for most Jandy/Zodiac and Pentair controllers and has a built web server for over-internet contols.
They added Vera's Variable Container support recently.

Autelis seems to be much more feature rich solution for supported controllers than Intermatic MultiWave.

http://autelis.com/wiki/index.php?title=Pool_Control_%28PI%29_Universal_Devices_ISY_2-Way_Integration#How_To_Setup_2-Way_Integration_With_Vera

There is also discussion on Autelis forum
http://www.autelis.com/forum/viewtopic.php?f=13&t=144&start=30

Please share your Autelis experience.
« Last Edit: June 11, 2013, 11:02:45 am by theal »

Offline mda

  • Sr. Member
  • ****
  • Posts: 464
  • Karma: +9/-0
Re: Autelis Pool Control and Vera
« Reply #1 on: June 08, 2013, 02:52:54 am »
I am still waiting to receive my autelis with the Vera compatible firmware to test (with a jandy onetouch actually).

Offline rayp

  • Jr. Member
  • **
  • Posts: 61
  • Karma: +3/-0
Re: Autelis Pool Control and Vera
« Reply #2 on: June 21, 2013, 08:22:49 am »
Autelis says they are still selling the Jandy interface however nearly everything is out of stock on their website in the pool control section (for months now). This is my plan also to integrate my Jandy RS to the Vera.
Did you get any ideas on the wait time for this product?

Offline mda

  • Sr. Member
  • ****
  • Posts: 464
  • Karma: +9/-0
Re: Autelis Pool Control and Vera
« Reply #3 on: June 22, 2013, 01:40:04 am »
Nope, just "we hope to have some available soon". Sorry.

Offline rayp

  • Jr. Member
  • **
  • Posts: 61
  • Karma: +3/-0
Re: Autelis Pool Control and Vera
« Reply #4 on: September 29, 2013, 02:18:41 am »
There appears to be sighs of life on the web page now......

http://www.autelis.com/homeautomation/pool-spa.html




Offline mda

  • Sr. Member
  • ****
  • Posts: 464
  • Karma: +9/-0
Re: Autelis Pool Control and Vera
« Reply #5 on: October 13, 2013, 02:31:23 am »
i received my Autelis for Jandy and installed the 1.5.5 autelis firmware for ISY/Vera on it. So far everything seems to be working. The Autelis populates a Variable Container device (details: http://bit.ly/1hN02RX) as values change on its side and i can control it with http commands from vera scenes eg: <autelis_ip>/set.cgi?name=spa&value=1 to turn on the spa (details: http://bit.ly/GULgh1) .

if anyone who codes professionally has a few free hours to write a plugin (i imagine a Pool device with child devices for pool thermostat, spa thermostat, outdoor temp sensor, and a few switches for various jets, lights, etc - maybe with a way to turn on only those child devices present in the system via check boxes or something) i would be very appreciative and happy to even sponsor some $ to cover the development cost. I believe the autelis team would gladly change their code to update the plugin devices instead of a variable container device.

Thanks!

-mda

Offline JacintoRa

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Autelis Pool Control and Vera
« Reply #6 on: December 10, 2013, 10:04:50 am »
Vera is the Programm and Autelis the Device. Am i right?

Offline tdinardo

  • Full Member
  • ***
  • Posts: 150
  • Karma: +1/-1
Re: Autelis Pool Control and Vera
« Reply #7 on: April 15, 2014, 11:30:14 pm »
MDA - have you gotten this setup working yet?

Thanks.

Tom

Offline mda

  • Sr. Member
  • ****
  • Posts: 464
  • Karma: +9/-0
Re: Autelis Pool Control and Vera
« Reply #8 on: April 16, 2014, 03:36:36 am »
MDA - have you gotten this setup working yet?

Yep, it works pretty well. Here is my setup:

1. a Variable Container device that the autelis can post its updates to (this is the device you set in the Autelis settings, in my case device #169)
2. a Multiswitch to show and change the status of the pool equipment (device #3 in my system)
3. a virtual thermostat to control the set point and show temp of the pool
4. a virtual thermostat to control the set point and show temp of the spa
5. a virtual temperature device to show the ambient air temp (device file: D_TemperatureSensor1.xml)

Virtual thermostats are from here http://forum.micasaverde.com/index.php/topic,8363.msg53275.html#msg53275

(see attached "Pool devices" screen shot).

The variables in the variable container will be created when the Autelis calls vera to set that variable for the first time, however i run this script ("setup_variables.sh" attached) once from my mac to create all the variables when i setup the device so they are in the correct order (only because it makes them easy to view on the Advanced tab of the variable container device when checking the setup, i do not think the order impacts functionality since the autelis sets the variables by name, in accordance with the order in the Autelis wiki http://autelis.com/wiki/index.php?title=Pool_Control_Universal_Devices_ISY_2-Way_Integration ). I am no good at shell scripts so this is doubtless the worst shell script you will ever see, sorry, but it works (i suspect this could be re-written by someone smart in about 5 lines ;) ).

As a reminder, you tell the Autelis where to post its updates by going to "ISY Settings" (they built the Vera compatible firmware on their ISY version and did not change the names) on your Autelis and setting your Vera IP and Variable Container device # (see "Autelis Settings" screen shot attached).

I put the following code into Startup Lua.

The function f_SetPoolStatusOnline updates a variable in the Variable Container with the status of the Autelis and the last time that status was updated. (The value of this function will become clear as you keep reading). The rest of the code updates devices 2-5 above when it detects changes to the Variable Container variables (posted by the Autelis). It also makes http calls to the Autelis whenever one of the devices 2-5 is changed. I am sure this code could be a lot better as i am no expert, but it works ok. It may take 5-15 seconds for a change made to the pool equipment to update the vera device. In my Jandy system, Aux1 is Spa Jets, Aux2 is Spa Lights, Aux3 is Pool Light, Aux4 is Spa Air Blower. If your system is different you will need to adjust the code and the Multiswitch button names accordingly.

Code: [Select]

-- update status and last update time on variable container for display on HomeWave app and send vera alert if pool status was offline and just changed to online

function f_SetPoolStatusOnline()

-- DEVICES

   local pool_status_device = 169 -- variable container device autelis posts updates to
   local vera_alerts_device = 23 -- to send online alert if previous status was offline

   local PriorOnlineStatus = luup.variable_get("urn:upnp-org:serviceId:VContainer1", "OnlineStatus", pool_status_device)
     if PriorOnlineStatus == "OFFLINE" then
         f_LogScene("Pool Control Online")
         luup.call_action("urn:richardgreen:serviceId:VeraAlert1", "SendAlert", {Message = "Pool Control Online", Recipients = "SMTP-Mail"}, vera_alerts_device)
     end
   luup.variable_set("urn:upnp-org:serviceId:VContainer1", "LastPing", os.date('%x %I:%M %p'), pool_status_device)
   luup.variable_set("urn:upnp-org:serviceId:VContainer1", "OnlineStatus", "Online", pool_status_device)
end

-- Autelis Startup Lua

-- DEVICES: update these for your system. ALSO replace the "3" in the multiswitch calls below with your multiswitch device. i am not sure why but i can not get this code to work if i use a variable for the multiswitch device #.

autelis_vc=169 -- pool variable container device id
autelis_pool_tstat=163 -- pool virtual thermostat
autelis_spa_tstat=164 -- spa virtual thermostat
autelis_air_temp=165 -- ambient air temp device
autelis_user="<username>" -- user name for autelis device
autelis_passwd="<password>" -- password for autelis device
autelis_ip="xxx.xxx.xxx.xxx" -- ip address of autelis device

-- update spa temp when pool temp changes and spa is not on and update pool thermo temp
function f_watch_pooltemp(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
     luup.variable_set("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature",lul_value_new, autelis_pool_tstat)
  local v_spaOn = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable12", autelis_vc)
     if v_spaOn == "0" then
       luup.variable_set("urn:upnp-org:serviceId:VContainer1", "Variable6",lul_value_new, autelis_vc)
       f_SetPoolStatusOnline()
     end
  end
luup.variable_watch("f_watch_pooltemp","urn:upnp-org:serviceId:VContainer1","Variable4", autelis_vc)

-- update spa temp thermo temp
function f_watch_spatemp(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
     luup.variable_set("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature",lul_value_new, autelis_spa_tstat)
     f_SetPoolStatusOnline()
end
luup.variable_watch("f_watch_spatemp","urn:upnp-org:serviceId:VContainer1","Variable6", autelis_vc)

-- update pool thermo set point
function f_watch_poolsetpoint(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
     luup.variable_set("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat", "CurrentSetpoint",lul_value_new, autelis_pool_tstat)
end
luup.variable_watch("f_watch_poolsetpoint","urn:upnp-org:serviceId:VContainer1","Variable1", autelis_vc)

-- update spa thermo set point
function f_watch_spasetpoint(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
     luup.variable_set("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat", "CurrentSetpoint",lul_value_new, autelis_spa_tstat)
     f_SetPoolStatusOnline()
end
luup.variable_watch("f_watch_spasetpoint","urn:upnp-org:serviceId:VContainer1","Variable3", autelis_vc)

-- update pool pump switch
function f_watch_poolpump(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
     luup.call_action("urn:dcineco-com:serviceId:MSwitch1","SetStatus1",{newStatus1=lul_value_new},3)
     f_SetPoolStatusOnline()
end
luup.variable_watch("f_watch_poolpump","urn:upnp-org:serviceId:VContainer1","Variable10", autelis_vc)

-- update spa pump switch
function f_watch_spapump(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
     luup.call_action("urn:dcineco-com:serviceId:MSwitch1","SetStatus3",{newStatus3=lul_value_new},3)
     f_SetPoolStatusOnline()
end
luup.variable_watch("f_watch_spapump","urn:upnp-org:serviceId:VContainer1","Variable12", autelis_vc)

-- update spa jets switch
function f_watch_spajets(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
     luup.call_action("urn:dcineco-com:serviceId:MSwitch1","SetStatus5",{newStatus5=lul_value_new},3)
     f_SetPoolStatusOnline()
end
luup.variable_watch("f_watch_spajets","urn:upnp-org:serviceId:VContainer1","Variable19", autelis_vc)

-- update spa blower switch
function f_watch_spablower(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
     luup.call_action("urn:dcineco-com:serviceId:MSwitch1","SetStatus6",{newStatus6=lul_value_new},3)
     f_SetPoolStatusOnline()
end
luup.variable_watch("f_watch_spablower","urn:upnp-org:serviceId:VContainer1","Variable22", autelis_vc)

-- update pool light switch
function f_watch_poollight(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
     luup.call_action("urn:dcineco-com:serviceId:MSwitch1","SetStatus7",{newStatus7=lul_value_new},3)
     f_SetPoolStatusOnline()
end
luup.variable_watch("f_watch_poollight","urn:upnp-org:serviceId:VContainer1","Variable21", autelis_vc)

-- update spa light switch
function f_watch_spalight(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
     luup.call_action("urn:dcineco-com:serviceId:MSwitch1","SetStatus8",{newStatus8=lul_value_new},3)
     f_SetPoolStatusOnline()
end
luup.variable_watch("f_watch_spalight","urn:upnp-org:serviceId:VContainer1","Variable20", autelis_vc)

-- update pool heat switch
function f_watch_poolheat(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
  if (lul_value_new == "1" or lul_value_new == "2") then
     luup.call_action("urn:dcineco-com:serviceId:MSwitch1","SetStatus2",{newStatus2=1},3)
     luup.call_action("urn:upnp-org:serviceId:HVAC_UserOperatingMode1","SetModeTarget", {NewModeTarget = "HeatOn"}, autelis_pool_tstat)
     luup.variable_set("urn:upnp-org:serviceId:HVAC_UserOperatingState1", "ModeState","Heating", autelis_pool_tstat)
  else
     luup.call_action("urn:dcineco-com:serviceId:MSwitch1","SetStatus2",{newStatus2=0},3)
     luup.call_action("urn:upnp-org:serviceId:HVAC_UserOperatingMode1","SetModeTarget", {NewModeTarget = "Off"}, autelis_pool_tstat)
     luup.variable_set("urn:upnp-org:serviceId:HVAC_UserOperatingState1", "ModeState","Idle", autelis_pool_tstat)
  end
      f_SetPoolStatusOnline()
end
luup.variable_watch("f_watch_poolheat","urn:upnp-org:serviceId:VContainer1","Variable15", autelis_vc)

-- update spa heat switch
function f_watch_spaheat(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
  if (lul_value_new == "1" or lul_value_new == "2") then
     luup.call_action("urn:dcineco-com:serviceId:MSwitch1","SetStatus4",{newStatus4=1},3)
     luup.call_action("urn:upnp-org:serviceId:HVAC_UserOperatingMode1","SetModeTarget", {NewModeTarget = "HeatOn"}, autelis_spa_tstat)
     luup.variable_set("urn:upnp-org:serviceId:HVAC_UserOperatingState1", "ModeState","Heating", autelis_spa_tstat)
  else
     luup.call_action("urn:dcineco-com:serviceId:MSwitch1","SetStatus4",{newStatus4=0},3)
     luup.call_action("urn:upnp-org:serviceId:HVAC_UserOperatingMode1","SetModeTarget", {NewModeTarget = "Off"}, autelis_spa_tstat)
     luup.variable_set("urn:upnp-org:serviceId:HVAC_UserOperatingState1", "ModeState","Idle", autelis_spa_tstat)
  end
      f_SetPoolStatusOnline()
end
luup.variable_watch("f_watch_spaheat","urn:upnp-org:serviceId:VContainer1","Variable17", autelis_vc)

-- update pool air temp
function f_watch_poolairtemp(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
     luup.variable_set("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature",lul_value_new, autelis_air_temp)
     f_SetPoolStatusOnline()
end
luup.variable_watch("f_watch_poolairtemp","urn:upnp-org:serviceId:VContainer1","Variable5", autelis_vc)

-- set autelis variables based on devices

-- update pool jandy set point
function f_watch_poolthermosetpoint(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
   local vURL ="http://"..autelis_ip.."/set.cgi?name=poolsp&temp=".. lul_value_new
   local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
end
luup.variable_watch("f_watch_poolthermosetpoint","urn:upnp-org:serviceId:TemperatureSetpoint1_Heat","CurrentSetpoint", autelis_pool_tstat)

-- update spa jandy set point
function f_watch_spathermosetpoint(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
     local vURL ="http://"..autelis_ip.."/set.cgi?name=spasp&temp=".. lul_value_new
   local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
end
luup.variable_watch("f_watch_spathermosetpoint","urn:upnp-org:serviceId:TemperatureSetpoint1_Heat","CurrentSetpoint", autelis_spa_tstat)

-- update pool pump
function f_watch_poolpumpSwitch(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
   local vURL ="http://"..autelis_ip.."/set.cgi?name=pump&value=".. lul_value_new
   local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
end
luup.variable_watch('f_watch_poolpumpSwitch','urn:dcineco-com:serviceId:MSwitch1','Status1',3)

-- update spa pump
function f_watch_spapumpSwitch(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
   local vURL ="http://"..autelis_ip.."/set.cgi?name=spa&value=".. lul_value_new
   local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
end
luup.variable_watch('f_watch_spapumpSwitch','urn:dcineco-com:serviceId:MSwitch1','Status3',3)

-- update spa jets
function f_watch_spajetSwitch(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
   local vURL ="http://"..autelis_ip.."/set.cgi?name=aux1&value=".. lul_value_new
   local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
end
luup.variable_watch('f_watch_spajetSwitch','urn:dcineco-com:serviceId:MSwitch1','Status5',3)

-- update spa blower
function f_watch_spablowerSwitch(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
   local vURL ="http://"..autelis_ip.."/set.cgi?name=aux4&value=".. lul_value_new
   local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
end
luup.variable_watch('f_watch_spablowerSwitch','urn:dcineco-com:serviceId:MSwitch1','Status6',3)

-- update pool light
function f_watch_poollightSwitch(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
-- local v_oldvalue = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable21", autelis_vc)
--  if ( lul_value_new ~= v_oldvalue ) then
   local vURL ="http://"..autelis_ip.."/set.cgi?name=aux3&value=".. lul_value_new
   local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
--  end
end
luup.variable_watch('f_watch_poollightSwitch','urn:dcineco-com:serviceId:MSwitch1','Status7',3)

-- update spa light
function f_watch_spalightSwitch(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
   local vURL ="http://"..autelis_ip.."/set.cgi?name=aux2&value=".. lul_value_new
   local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
end
luup.variable_watch('f_watch_spalightSwitch','urn:dcineco-com:serviceId:MSwitch1','Status8',3)

-- update pool heat from multiswitch
function f_watch_poolheatSwitch(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
   local vURL ="http://"..autelis_ip.."/set.cgi?name=poolht&value=".. lul_value_new
   local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
end
luup.variable_watch('f_watch_poolheatSwitch','urn:dcineco-com:serviceId:MSwitch1','Status2',3)

-- update spa heat from multiswitch
function f_watch_spaheatSwitch(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
   local vURL ="http://"..autelis_ip.."/set.cgi?name=spaht&value=".. lul_value_new
   local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
end
luup.variable_watch('f_watch_spaheatSwitch','urn:dcineco-com:serviceId:MSwitch1','Status4',3)

-- update pool heat from thermostat
function f_watch_poolheatStat(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
  if lul_value_new == "Heating" and lul_value_new ~= lul_value_old then
      set_heat = 1
    else -- Idle
      set_heat = 0
  end -- if heating or idle
   local vURL ="http://"..autelis_ip.."/set.cgi?name=poolht&value=".. set_heat
   local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
end
luup.variable_watch('f_watch_poolheatStat','urn:upnp-org:serviceId:HVAC_UserOperatingState1','ModeState', autelis_pool_tstat)

-- update spa heat from thermostat
function f_watch_spaheatStat(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
  if lul_value_new == "Heating" and lul_value_new ~= lul_value_old then
      set_heat = 1
    else -- Idle
      set_heat = 0
  end -- if heating or idle
      local vURL ="http://"..autelis_ip.."/set.cgi?name=spaht&value=".. set_heat
      local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
end
luup.variable_watch('f_watch_spaheatStat','urn:upnp-org:serviceId:HVAC_UserOperatingState1','ModeState', autelis_spa_tstat)


This is the luup code i put in a scene i call "Ping Pool Control" with a schedule to run every 15 minutes. It checks to make sure the Autelis is online and uses vera alerts to send an alert if it is online:

Code: [Select]

-- Ping Pool Control scene luup

-- DEVICES
local vURL ="http://<xxx.xxx.xxx.xxx>/status.xml" -- xxx.xxx.xxx.xxx to your Autelis IP address
local vCode, vData = luup.inet.wget(vURL,5,"<autelis user name>","<autelis password")
local pool_status_device = 169 -- the variable container device # that Autelis posts updates to
local vera_alerts_device = 23 -- to send online alert if previous status was offline


if vCode == 0 then
   f_SetPoolStatusOnline()
 else
   luup.variable_set("urn:upnp-org:serviceId:VContainer1", "LastPing", os.date('%x %I:%M %p'), pool_status_device)
   luup.variable_set("urn:upnp-org:serviceId:VContainer1", "OnlineStatus", "OFFLINE", pool_status_device)
   f_LogScene("Pool Control OFFLINE")
   luup.call_action("urn:richardgreen:serviceId:VeraAlert1", "SendAlert", {Message = "Pool Control OFFLINE", Recipients = "SMTP-Mail"}, vera_alerts_device)
end

I hope this helps. It would probably be better implemented in PLEG but I have not made the move to PLEG yet; if anyone else would like to do the PLEG implementation I would be happy to walk through the business logic in the startup Lua of course.

-mda
« Last Edit: April 22, 2014, 04:16:01 am by mda »

Offline PJJP

  • Full Member
  • ***
  • Posts: 149
  • Karma: +2/-0
Re: Autelis Pool Control and Vera
« Reply #9 on: April 16, 2014, 04:40:41 pm »
@MDA, awesome work.

I think I am missing something. I am trying to follow your setup, but there's a couple things I do not understand.

My VC is getting updated by the Autelis successfully. What causes the functions in startup to be evaluated? I see that f_SetPoolStatusOnline is called by the scene, but what about the other functions, such as f_watch_pooltemp, f_watch_spatemp, etc?


Offline mda

  • Sr. Member
  • ****
  • Posts: 464
  • Karma: +9/-0
Re: Autelis Pool Control and Vera
« Reply #10 on: April 16, 2014, 05:26:13 pm »



@MDA, awesome work.

Thanks! ... just a lot of messy trial and error and still not 100% reliable, but i keep chipping away at it :)

Quote
What causes the functions in startup to be evaluated?

In the startup Lua it tells vera to watch the variables in the variable container with a luup.variable_watch for each variable in the variable container (http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_variable_watch). When those variables change Vera calls the appropriate function for that changed variable.

For example, this bit of code in the startup Lua tells Vera to watch the variable "Variable10" in the "autelis_vc" variable container device. Any time Variable10 is updated (by the Autelis' http calls to vera), the function "f_watch_poolpump" gets called.

Code: [Select]
luup.variable_watch("f_watch_poolpump","urn:upnp-org:serviceId:VContainer1","Variable10", autelis_vc)
The f_watch_poolpump function gets the new value of Variable10 passed to it by Vera in the lul_value_new variable and in this case it sets the first button of the Multiswitch device (device #3 in my case) to lul_value_new (which will be 1 if the pool pump is on or 0 if the pool pump is off). There are some cases (heat for example) where Autelis might send 0, 1, or 2 as the value and the functions for those variables convert those to 0 or 1 appropriately.

Code: [Select]
-- update pool pump switch
function f_watch_poolpump(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
     luup.call_action("urn:dcineco-com:serviceId:MSwitch1","SetStatus1",{newStatus1=lul_value_new},3)
     f_SetPoolStatusOnline()
end

Offline PJJP

  • Full Member
  • ***
  • Posts: 149
  • Karma: +2/-0
Re: Autelis Pool Control and Vera
« Reply #11 on: April 16, 2014, 05:39:56 pm »
Nice! Thank you for the explanation. I have not really played with the startup lua until now. At this point, I just need to customize it to my system. If you make any further improvements, please post them! Thank you again.

Offline mda

  • Sr. Member
  • ****
  • Posts: 464
  • Karma: +9/-0
Re: Autelis Pool Control and Vera
« Reply #12 on: April 21, 2014, 02:13:45 am »
@PJJP

I think there is a bug in my code that is turning the pool heater off if heat is set to enabled (pump is off and heat is set to on). I will let you know as soon as i sort it out. (might have something to do with me messing something up during my recent move to multiswitch, not sure).
« Last Edit: April 21, 2014, 02:20:52 am by mda »

Offline mda

  • Sr. Member
  • ****
  • Posts: 464
  • Karma: +9/-0
Re: Autelis Pool Control and Vera
« Reply #13 on: April 22, 2014, 02:38:51 am »
@PJJP

I found the bug... it is in the last 2 sections "update pool heat from thermostat" and "update spa heat from thermostat". They should be as follows (i will also update the post above). Sorry about that.

Code: [Select]
-- update pool heat from thermostat
function f_watch_poolheatStat(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
  if lul_value_new == "Heating" and lul_value_new ~= lul_value_old then
      set_heat = 1
    else -- Idle
      set_heat = 0
  end -- if heating or idle
   local vURL ="http://"..autelis_ip.."/set.cgi?name=poolht&value=".. set_heat
   local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
end
luup.variable_watch('f_watch_poolheatStat','urn:upnp-org:serviceId:HVAC_UserOperatingState1','ModeState', autelis_pool_tstat)

-- update spa heat from thermostat
function f_watch_spaheatStat(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
  if lul_value_new == "Heating" and lul_value_new ~= lul_value_old then
      set_heat = 1
    else -- Idle
      set_heat = 0
  end -- if heating or idle
      local vURL ="http://"..autelis_ip.."/set.cgi?name=spaht&value=".. set_heat
      local vCode, vData = luup.inet.wget(vURL,5,autelis_user,autelis_passwd)
end
luup.variable_watch('f_watch_spaheatStat','urn:upnp-org:serviceId:HVAC_UserOperatingState1','ModeState', autelis_spa_tstat)
« Last Edit: April 22, 2014, 04:16:25 am by mda »

Offline mda

  • Sr. Member
  • ****
  • Posts: 464
  • Karma: +9/-0
Re: Autelis Pool Control and Vera
« Reply #14 on: April 22, 2014, 05:00:38 am »
thanks to the XML tip from @akbooer i was able to update the "ping pool control device" scene luup to also refresh vera's variable container device with Autelis variables every few minutes -- just to make sure it stays in sync. (notice the logic here around setting the Spa Temperature is the same as in the startup lua; since my Jandy system reports a temp of zero if the spa is turned off, i use the pool temp in that case since in my setup the spa will be the same temp as the pool until the spa is on and might be heated.)

Code: [Select]
-- Ping Pool Control scene luup

-- DEVICES
local vera_alerts_device = 23 -- to send online alert if previous status was offline
-- END DEVICES

local vURL = autelis_ip.."/status.xml"
local vCode, vData = luup.inet.wget(vURL,5, autelis_user, autelis_passwd)

if vCode == 0 then
   f_SetPoolStatusOnline()

   local v_runstate = vData: match "<runstate>([^<]*)</runstate>"
   local v_pump = vData: match "<pump>([^<]*)</pump>"
   local v_spapump = vData: match "<spa>([^<]*)</spa>"
   local v_poolht = vData: match "<poolht>([^<]*)</poolht>"
   local v_spaht = vData: match "<spaht>([^<]*)</spaht>"
   local v_spajets = vData: match "<aux1>([^<]*)</aux1>"
   local v_spalight = vData: match "<aux2>([^<]*)</aux2>"
   local v_poollight = vData: match "<aux3>([^<]*)</aux3>"
   local v_spablower = vData: match "<aux4>([^<]*)</aux4>"
   local v_poolsp = vData: match "<poolsp>([^<]*)</poolsp>"
   local v_spasp = vData: match "<spasp>([^<]*)</spasp>"
   local v_pooltemp = vData: match "<pooltemp>([^<]*)</pooltemp>"
   local v_spatemp = vData: match "<spatemp>([^<]*)</spatemp>"
   local v_airtemp = vData: match "<airtemp>([^<]*)</airtemp>"


   luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable10", v_pump, autelis_vc)
   luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable12", v_spapump, autelis_vc)
   luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable15", v_poolht, autelis_vc)
   luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable17", v_spaht, autelis_vc)
   luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable19", v_spajets, autelis_vc)
   luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable20", v_spalight, autelis_vc)
   luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable21", v_poollight, autelis_vc)
   luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable22", v_spablower, autelis_vc)

   luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable1", v_poolsp, autelis_vc)
   luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable3", v_spasp, autelis_vc)
   luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable4", v_pooltemp, autelis_vc)
   luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable5", v_airtemp, autelis_vc)

   if v_spapump == "1" then -- spa pump is on so use spa temp
       luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable6", v_spatemp, autelis_vc)
     else -- use pool temp
       luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable6", v_pooltemp, autelis_vc)
   end

 else
   luup.variable_set("urn:upnp-org:serviceId:VContainer1", "LastPing", os.date('%x %I:%M %p'), autelis_vc)
   luup.variable_set("urn:upnp-org:serviceId:VContainer1", "OnlineStatus", "OFFLINE", autelis_vc)
   f_LogScene("Pool Control OFFLINE")
   luup.call_action("urn:richardgreen:serviceId:VeraAlert1", "SendAlert", {Message = "Pool Control OFFLINE", Recipients = "SMTP-Mail"}, vera_alerts_device)
end