Vera uses LUUP which is Lua-UPnP
That is the reason I started my LUA page, but so far I have not needed to add anything.
Some of my LUUP Code I have working in my scenes
http://<local_Vera_IP>:3480/data_request?id=device&action=delete&device=<device_ID>
where
<local_Vera_IP> is the IP address of the Vera device
<device_ID> is the ID of the device to be removed.
-- run only at night
return luup.is_night()
local dID = 5
local currentStatus = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", dID)
local newStatus = "1"
if (currentStatus == "1") then
newStatus = "0"
end -- if
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = newStatus}, dID)
Used in Bathroom, based on Conditional Scene Execution: Some Examples - Time Period (below)
local startHour = 23 -- 0 to 23
local startMinute = 0 -- 0 to 59
local startTime = startHour *60 + startMinute -- convert time to the minute of the day
local endHour = 6 -- 0 to 23
local endMinute = 45 -- 0 to 59
local endTime = endHour *60 + endMinute
local currentTime = os.date("*t")
currentTime = currentTime.hour * 60 + currentTime.min
local dimmerId = 112
local dimmerLevel = "75"
local dimmerLowLevel = "15"
if startTime <= endTime then
-- Both the start time and the end time are in the same day:
-- if the current time is in the given interval, set dimmerLevel to low .
if startTime <= currentTime and currentTime <= endTime then
dimmerLevel = dimmerLowLevel
end
else
-- The start time is before midnight, and the end time is after midnight:
-- if the current time is not outside the given interval, set dimmerLevel to low
if not (endTime < currentTime and currentTime < startTime) then
dimmerLevel = dimmerLowLevel
end
end
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = dimmerLevel}, dimmerId)
luup.call_action('urn:micasaverde-com:serviceId:HomeAutomationGateway1', 'SetHouseMode', { Mode=<newmode> }, 0)
Replace <newmode> with values from 1 to 4 where:
1 = Home
2 = Away
3 = Night
4 = Vacation
Set Mode Night
luup.call_action(‘urn:micasaverde-com:serviceId:HomeAutomationGateway1’, ‘SetHouseMode’, { Mode=3 }, 0)
Set Mode Home
luup.call_action(‘urn:micasaverde-com:serviceId:HomeAutomationGateway1’, ‘SetHouseMode’, { Mode=1 }, 0)
Set Mode Away
luup.call_action(‘urn:micasaverde-com:serviceId:HomeAutomationGateway1’, ‘SetHouseMode’, { Mode=2 }, 0)
Conditional Scene Execution: Some Examples - Time Period
source: http://forum.micasaverde.com/index.php/topic,18679.0.html
local pStart = "22:30" -- Start of time period
local pEnd = "06:15" -- End of time period
local allow = true -- true runs scene during period, false blocks it
local hS, mS = string.match(pStart,"(%d+)%:(%d+)")
local mStart = (hS * 60) + mS
local hE, mE = string.match(pEnd,"(%d+)%:(%d+)")
local mEnd = (hE * 60) + mE
local tNow = os.date("*t")
local mNow = (tNow.hour * 60) + tNow.min
if mEnd >= mStart then
return (((mNow >= mStart) and (mNow <= mEnd)) == allow)
else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)
end
local pStart = "22:30" -- Start of time period
local pEnd = "06:15" -- End of time period
local allow = true -- true runs scene during period, false blocks it
local hS, mS = string.match(pStart,"(%d+)%:(%d+)")
local mStart = (hS * 60) + mS
local hE, mE = string.match(pEnd,"(%d+)%:(%d+)")
local mEnd = (hE * 60) + mE
local tNow = os.date("*t")
local mNow = (tNow.hour * 60) + tNow.min
local action = "0"
if mEnd >= mStart then
action = ((mNow >= mStart) and (mNow <= mEnd)) == allow
else
action = ((mNow >= mStart) or (mNow <= mEnd)) == allow
end
return (action)
Dim a switch #6 to 30%
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "30"}, 6)
http://wiki.micasaverde.com/index.php/Scripts_for_scenes#Scene_that_runs_only_in_a_user_set_time_interval
local startTime = "22:30"
local endTime = "05:30"
local hour = tonumber( startTime:sub( startTime:find("%d+") ) )
local minute = tonumber(startTime:sub(-2))
if hour and minute then
startTime = hour * 100 + minute
else
luup.log("ERROR: invalid start time")
return false
end
hour = tonumber( endTime:sub( endTime:find("%d+") ) )
minute = tonumber(endTime:sub(-2))
if hour and minute then
endTime = hour * 100 + minute
else
luup.log("ERROR: invalid end time")
return false
end
local currentTime = os.date("*t")
currentTime = currentTime.hour * 100 + currentTime.min
luup.log("startTime = " .. startTime .. "; currentTime = " .. currentTime .. "; endTime = " .. endTime)
if startTime <= endTime then
-- Both the start time and the end time are in the same day:
-- if the current time is in the given interval, run the scene.
if startTime <= currentTime and currentTime <= endTime then
return true
end
else
-- The start time is before midnight, and the end time is after midnight:
-- if the current time is not outside the given interval, run the scene.
if not (endTime < currentTime and currentTime < startTime) then
return true
end
end
return false