We have moved at community.getvera.com

Author Topic: {SOLVED} How read the values from luup.call_action  (Read 474 times)

Offline kyle.dawson

  • Full Member
  • ***
  • Posts: 153
  • Karma: +1/-1
{SOLVED} How read the values from luup.call_action
« on: December 22, 2018, 04:43:39 pm »
I am looking to read the value, specifically the returnArguments from the luup.call_action.  It comes back as table or list and I can not figure out how to loop thru to get each value.    Below is sample code:

Code: [Select]
local ALTUI_DEVICE_NO = 850
local ALTUI_DEVICE_SID = "urn:upnp-org:serviceId:altui1"
local GROUP_ID_KITCHEN = "RINCON_B832343333301400:4353"


resultCode, resultString, job, returnArguments = luup.call_action(ALTSONOS_DEVICE_SID, "GetVolume", { groupID = GROUP_ID_KITCHEN} , ALTSONOS_DEVICE_NO)



« Last Edit: December 23, 2018, 10:31:16 am by kyle.dawson »
VeraPlus(1), Sonos(3), GE Switch(30), GE Dimmer(5), GE Zwave Outlet(3), MimoLight Garage Door(1),Neo Motion(6), Door Sensors(3) Camera(9), Honeywell Thermostat(2), Google Home(4), Alexa(4), Google Chrome Cast(5)  - Driven via ALTUI

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: How read the values from luup.call_action
« Reply #1 on: December 22, 2018, 05:44:26 pm »
Return arguments are in a table with name/value pairs.

You can loop through these:

Code: [Select]
for name,value in pairs (returnArguments) do
  -- whatever you like
end

or simple access each value by name:

Code: [Select]
if returnArguments.whatever then ...

Be aware, though, that if ithe action is implemented as a job, the call may well return before the job is run.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline amg0

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3174
  • Karma: +210/-8
Re: How read the values from luup.call_action
« Reply #2 on: December 22, 2018, 05:44:46 pm »
I am looking to read the value, specifically the returnArguments from the luup.call_action.  It comes back as table or list and I can not figure out how to loop thru to get each value.    Below is sample code:

Code: [Select]
local ALTUI_DEVICE_NO = 850
local ALTUI_DEVICE_SID = "urn:upnp-org:serviceId:altui1"
local GROUP_ID_KITCHEN = "RINCON_B8E93758FA4001400:725"
local GROUP_ID_FAMILY_ROOM = "RINCON_000E58C7D93A01400:4198103609"


resultCode, resultString, job, returnArguments = luup.call_action(ALTSONOS_DEVICE_SID, "GetVolume", { groupID = GROUP_ID_KITCHEN} , ALTSONOS_DEVICE_NO)

for key,val in pairs(returnArguments ) do

Offline kyle.dawson

  • Full Member
  • ***
  • Posts: 153
  • Karma: +1/-1
Re: How read the values from luup.call_action
« Reply #3 on: December 22, 2018, 10:47:20 pm »
No matter what I try the value is nil. 


Code: [Select]
local ALTUI_DEVICE_NO = 850
local ALTUI_DEVICE_SID = "urn:upnp-org:serviceId:altui1"
local GROUP_ID_KITCHEN = "RINCON_A8E956A3758FA4"
resultCode, resultString, job, returnArguments = luup.call_action(ALTSONOS_DEVICE_SID, "GetVolume", { groupID = GROUP_ID_KITCHEN} , ALTSONOS_DEVICE_NO)
local name, value
for name,value in pairs(returnArguments) do
  luup.log("Debug Name: " .. name)
  luup.log("Debug Value: " .. value)
end

I get this result


[string "ALTUI - LuaRunHandler"]:6: bad argument #1 to 'pairs' (table expected, got nil)
VeraPlus(1), Sonos(3), GE Switch(30), GE Dimmer(5), GE Zwave Outlet(3), MimoLight Garage Door(1),Neo Motion(6), Door Sensors(3) Camera(9), Honeywell Thermostat(2), Google Home(4), Alexa(4), Google Chrome Cast(5)  - Driven via ALTUI

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: How read the values from luup.call_action
« Reply #4 on: December 23, 2018, 02:34:27 am »
Check the status return from the call... it must be failing.

Are you sure that you are using the correct serviceId and parameter names?
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline kyle.dawson

  • Full Member
  • ***
  • Posts: 153
  • Karma: +1/-1
Re: How read the values from luup.call_action
« Reply #5 on: December 23, 2018, 10:30:55 am »
Well that is a dumb user error. I was testing ALTUI and ALTSONS and mixed up the numbers.  Thanks so much, its working great now. 
VeraPlus(1), Sonos(3), GE Switch(30), GE Dimmer(5), GE Zwave Outlet(3), MimoLight Garage Door(1),Neo Motion(6), Door Sensors(3) Camera(9), Honeywell Thermostat(2), Google Home(4), Alexa(4), Google Chrome Cast(5)  - Driven via ALTUI