Hi all, I’m getting acquainted with my vera in our new home. Lua doesn’t intimidate me, but I’m having a bit of trouble wrapping my head around the UI and event engine.
I’m going to make my ceiling fan balance the load between upstairs and downstairs heat pump units. It’s located in an open common area, and controlled by a Leviton fan controller. Both heatpumps are on ecobee thermostats and I have a trial code working:
local maxTempDelta = 6;
local minTempDelta = 2;
local fanSetting = 0;
local downTemp = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”,11);
local upTemp = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”,8);
if (math.abs(tonumber(downTemp)-tonumber(upTemp))>minTempDelta)
then
fanSetting = (math.abs(tonumber(downTemp)-tonumber(upTemp))/(maxTempDelta-minTempDelta))*100
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = fanSetting}, 4);
else
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “0”}, 4);
end
This works fine when ran in ‘Test Lua’.
My question has two parts. First, what is the best way to implement the above code, scene or startup lua? If scene, do I just leave all the devices off in the setup and let the Lua code turn on the fan? Are there resource load implications to running this in startup lua?
Second, I would like to add functionality such that when the fan controller is manually changed (a person hits the dimmer on the wall), the autoFan code will be temporarily disabled. I was thinking of using vcontainer to store the user input flag. I think I can handle programming the delay portion, but don’t know how to log a user hitting the switch versus the autoFan code setting the loadLevel.
Any and all help is much appreciated!
P.S. How does one make a code snippet? The button isn’t doing anything. Also tried to no avail.
Thanks