Jump to content
C4 Forums | Control4

How to get variable value from other driver (through name)


Recommended Posts

Hello!

 

The standart function of Control4 API C4:GetVariable have two parameters, which are Device ID and Variable ID. So, I can see the Device ID in driver information, but do not Variable ID. How can I get value of device variable through the name or how can I get it Variable ID?

 

Thanks for help!

Link to comment
Share on other sites


The easiest way in 2.8 (may have been in 2.7.x, but I don't know for certain) is to call C4:GetDeviceVariables(idDevice).

 

That call returns a table, with VariableID referencing another table, which includes name, value, and a host of other things, such as type, readonly, hidden.

 

Execute this Lua:

 

for k,v in pairs(C4:GetDeviceVariables(29)) do print(k, v.name, v.value) end  -- Replace 29 with a device id...

 

What are you wanting to do this for, out of curiosity?

 

RyanE

Link to comment
Share on other sites

The easiest way in 2.8 (may have been in 2.7.x, but I don't know for certain) is to call C4:GetDeviceVariables(idDevice).

I tried it, but it didn't work. There are not API function C4:GetDeviceVariables neither in documentation nor in DriverEditor. The table always is empty, for any device ID

Link to comment
Share on other sites

The easiest way in 2.8 (may have been in 2.7.x, but I don't know for certain) is to call C4:GetDeviceVariables(idDevice).

 

That call returns a table, with VariableID referencing another table, which includes name, value, and a host of other things, such as type, readonly, hidden.

 

Execute this Lua:

 

for k,v in pairs(C4:GetDeviceVariables(29)) do print(k, v.name, v.value) end  -- Replace 29 with a device id...

 

Ryan,

Thanks - this is a great time saver!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...