Trying to add variable watch to Lua startup for sonos volume but is not working
Why?
– Set up variable-watch for device 9
luup.variable_watch(“doChange9”,“urn:upnp-org-com:serviceId:RenderingControl”,“Volume”,9)
– Process variable-watch callback for device 9. Chamge Sonos Cuisine Volume
function doChange9()
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “RunScene”, {SceneNum = 69}, 0)
end
Do you know if the watch is not working or if the function call is not working? Try the function (or even just the luup.call_action) in the test window. If it works, likely there is something wrong with the variable watch itself. Rex says that you have to restart Vera in order to make this take effect. Are you doing that? This code is in the startup lua, right?
If that doesn’t work, then it needs to be debugged further. If it does work, then try this in the test code window:
function doChange9()
luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "69"}, 0)
end
doChange9()[/quote]
luup.call action… Works but,
function doChange… does not work
just checked again in log and Watch fonction in Lua startup not seem to appear there
Strange. I put this in my (UI5) test window and it ran fine:
function doChange9()
luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "31"}, 0)
luup.log("doChange9 just ran")
end
doChange9()
return trueThis is what I see in the log file. Do you see anything like this?08 05/21/17 18:56:50.799 JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunLua <0x2f9e3680>
08 05/21/17 18:56:50.799 JobHandler_LuaUPnP::HandleActionRequest argument Code=function doChange9()
luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "31"}, 0)
luup.log("doChange9 just ran")
end
doChange9()
return true <0x2f9e3680>
08 05/21/17 18:56:50.800 JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunScene <0x2f9e3680>
08 05/21/17 18:56:50.801 JobHandler_LuaUPnP::HandleActionRequest argument SceneNum=31 <0Do you see the test function in the log like this?
This looks great:Device_Variable::m_szValue_set device: 8 service: urn:upnp-org:serviceId:RenderingControl variable: Volume was: 75 now: 10 Your action and function are working fine.
Did you restart after adding this to the startup lua and saving? Note that a reload may not work - I don’t know if the lua startup is read on reload. Saving the startup lua is not enough since it is only read at startup. Try a reboot.
You said you did not see the watch in the log? Either the watch and the function are not getting saved in the startup lua, or the startup lua didn’t run.
Best Home Automation shopping experience. Shop at Ezlo!