I want to have code that will identify which device (tablet, phone, etc) called a scene so I can program a response specific to that device. Is there any way to get the calling device’s IP address, MAC address, or any other identifying information as a variable in LUUP?
Not using the standard interfaces …
Is there a way with non-standard interfaces? ![]()
Ugly Hack#1: In Lua, you can run an OS-level command to capture the output of:
[tt] netstat -a -n | grep ESTABLISHED | grep ":3840 "[/tt]
and then troll through the things connected. It’ll net a LOT of different items that are currently connected, and if two CP’s are accessing “concurrently” you won’t be able to differentiate them ![]()
Hello,
Is there any way to add a param at the end of the url for run scene, like that :
With the previous code i was thinking something like this.
Instead of calling a scene create a virtual dim light
in pseudo:
Use http to set dim lvl of device to value > 0%
Scene trigger → when light x goes on.
In luup of the scene:
check the set dim lvl (you can specify your device according to dim lvl)
In the luup call the scene you want or do you thing in the current scene
In the end of the luup set the dimlvl to 0 % and device to off
This is a way to do it without doing stuf at OS lvl in the vera
Hi,
It should be simpler with a string in a VContainer, a luup.variable_watch() and a couple of functions.
Add this to the lua startup:
[code]function tableSplit(pString, pPattern)
local rTable = {} – NOTE: use {n = 0} in Lua-5.0
local fpat = “(.-)” … pPattern
local last_end = 1
local s, e, cap = pString:find(fpat, 1)
while s do
if s ~= 1 or cap ~= “” then
table.insert(rTable,cap)
end
last_end = e+1
s, e, cap = pString:find(fpat, last_end)
end
if last_end <= #pString then
cap = pString:sub(last_end)
table.insert(rTable, cap)
end
return rTable
end
function remoteIdentifiedAction()
local parameters = tableSplit(luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable1”, VContainerID), “|”)
local arg = {}
local argAction = {}
for key, value in ipairs(parameters) do
arg[key] = value
if (type(value) == “table”) then
for keyAction, valueAction in pairs(value) do
argAction[keyAction] = valueAction
end
end
end
luup.call_action(arg[1], arg[2], arg[3], arg[4])
– NOTE : arg[5] contain the MAC address of the sender
end
luup.variable_watch(“remoteIdentifiedAction”, “urn:upnp-org:serviceId:VContainer1”, “Variable1”, VContainerID)[/code]
The first function is an utility to split a string into a table using a special char as separator.
The second one is caled every time the value to the variable change, split the string and execute the action.
For example, tu run the scene ID 1, just fill the “Variable1” of your Variable Container with a string like “urn:micasaverde-com:serviceId:HomeAutomationGateway1”|“RunScene”|{SceneNum=“1”}|0|AA:BB:CC:DD:EE:FF
To dim the light id 2 to 30%, fill the “Variable1” of your Variable Container with a string like “urn:upnp-org:serviceId:Dimming1”|“SetLoadLevelTarget”|{newLoadlevelTarget = “30”}|0|AA:BB:CC:DD:EE:FF
You need to modify the 2nd function to react to each different arg[5] (which contain the MAC of the sender)