Author Topic: Basic LUA code not running from action question  (Read 1132 times)

Offline denwood

  • Sr. Newbie
  • *
  • Posts: 41
  • Karma: +3/-0
Basic LUA code not running from action question
« on: March 06, 2016, 01:17:55 pm »
I've been working with PLEG to automate our 9 ecobee thermostats and running through some issues.  The basic scenario is that I want open windows to turn off AC when cool is being called for and fire up the circ fans.  While stepping through triggers and conditionals, I'm running into a problem when running code in a PLEG action.  The controls for the stats are very limited in the GUI, so code is pretty much required.

This code works exactly as expected when testing from the Develop Apps "Test Luup" interface.  The Ecobee stat in question turns on the fan.

Code: [Select]
local service_id = "urn:upnp-org:serviceId:HVAC_FanOperatingMode1"
local action = "SetMode"
local args = {NewMode="ContinuousOn"} -- or "Auto"
local dev_num = 60 -- Our Ecobee R&D Thermostat Device ID
luup.call_action(service_id, action, args, dev_num)

If I copy/paste this same code into an action in PLEG and click "Run it Now", nothing happens when monitoring the Ecobee stat. The PLEG log (set to debug in a separate file) shows "RunNext: LUA continue".  If I try to debug using the "log to VERA file", the log never loads when I try to display it from PLEG.

My condition is called "c1" and the PLEG log shows this condition is true (I'm testing with a virtual switch and a few window sensors).  So when t1 (trigger one virtual switch) is true, it looks like my condition is toggled to "true", but nothing happens on the stat, and the log does't provide any information on why the code (above) is failing in the action.

Sun Mar 06 13:15:1.081 - RunNext:Condition:c1 Index:1
Sun Mar 06 13:15:1.411 - RunNext:Lua Continue
Sun Mar 06 13:15:1.412 - SaveActionDB:{}

Any suggestions on how I might be able to sort out what's going on?  I'm a Vera newby, so please assume "child like intellect" in terms of replies :-)


Cheers,
Dennis.


Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +764/-143
Re: Basic LUA code not running from action question
« Reply #1 on: March 06, 2016, 03:17:24 pm »
Did you RELOAD LUA after making changes ?


Offline MLeBaugh

  • Jr. Member
  • **
  • Posts: 76
  • Karma: +8/-1
Re: Basic LUA code not running from action question
« Reply #2 on: March 06, 2016, 03:21:00 pm »
Like Richard said be sure you reload after you set your changes, but you also do not need code to complete this you can just use the setmode option in your ecobee and set newmode to continuouson or auto

Offline denwood

  • Sr. Newbie
  • *
  • Posts: 41
  • Karma: +3/-0
Re: Basic LUA code not running from action question
« Reply #3 on: March 06, 2016, 10:52:22 pm »
ML, thanks for that tip.  I've been using code to control the ecobee in order to learn the basic snippets I need.  Control via the gui is missing essential bits like resumeprogram, and the ability to set climate holds.  I've also edited the ecobee_1 xml file so that fan and climate holds are not indefinite, but rather just until the next scheduled event.

Richard, I ended up doing a restore on the Vera Edge box, reauthorized the ecobee app (get pin) and managed to get things working as expected.  Thanks for the "reload Lua" tip using the buttons you've provided in all the tabs..will definitely remember that going forward. 

I was hoping not to have to get too deep into the Vera Box, but it's pretty obvious at this point that PLEG is pretty much mandatory for what I'm trying to do.  I'm trying to automate night cooling etc. in a 9000 sq/ft building with 9 ecobee stats, ventilator fans etc.  Between PLEG and the Combination Switch App, I figure we're good :-)

Between automation (shuts off a pile of non-essentials when security system is armed) and aggressive setbacks with the 9 Ecobee3 stats, we've cut our gas usage for heat by 25%, and power use by about 15%.   

Offline aecchalet

  • Sr. Member
  • ****
  • Posts: 252
  • Karma: +1/-1
Re: Basic LUA code not running from action question
« Reply #4 on: May 11, 2018, 08:22:09 am »
Is there a way to turn off AC cooling with a PLEG logic action without using Luup code?
If not, how would I do it with luup code?
Thanks
Vera Plus 1.7.2138; 12xHRDS1, 2xTrane SCHTZMT400 Tstats; 5xZIR00, 4xCA9000 PIRs; 2xHA01C Recept; 2x2wy ZDW120W switch; 1xAppl (ACT, GE/Jasco), 1xLite Dim Mod (GE/Jasco, Evolve);  2xDead Bolts Schlage

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +764/-143
Re: Basic LUA code not running from action question
« Reply #5 on: May 11, 2018, 01:45:07 pm »
Yes you can send commands to your thermostat without LUA.

Offline aecchalet

  • Sr. Member
  • ****
  • Posts: 252
  • Karma: +1/-1
Re: Basic LUA code not running from action question
« Reply #6 on: January 04, 2019, 04:03:44 pm »
I found the solution to using PLEG to shut off AC.  By default the action window for my thermostats opens in advanced mode.  If one switches to the basic mode with the slider near top, an image of thermostat appears.  One then just clicks on the OFF button and save the action.
Vera Plus 1.7.2138; 12xHRDS1, 2xTrane SCHTZMT400 Tstats; 5xZIR00, 4xCA9000 PIRs; 2xHA01C Recept; 2x2wy ZDW120W switch; 1xAppl (ACT, GE/Jasco), 1xLite Dim Mod (GE/Jasco, Evolve);  2xDead Bolts Schlage