Newb Lua programming question, but I can’t seem to get the current state from my device. I am trying to get the fan speed from my device. Here is my code along with the error and docs:
Code:
local speed = device.get_latest_state('main', capabilities.fanSpeed, 'fanSpeed', 0)
Error:
[ERROR 05:22:14] [string "st/thread.lua"]:76: Stairwell Fan thread encountered error: [string "st/dispatcher.lua"]:229: Error encountered while processing event for <Device: XXX (My Fan)>:
arg1: table: 0xf84058
[string "st/device.lua"]:228: component_id should be of type string but was table
Get the latest state of this device for a given component, capability, attribute
table (e.g. it would include both the value and unit keys if both are present)
Parameters
component_id (str) – the component ID to get the state for
capability_id (str) – the capability ID to get the state for
attribute_name (str) – the capability attribute name to get the state for
default_value (any) – Optional value to return if the state_cache for the lookup is nil
default_state_table (any) – Optional value to return if the state_cache for the lookup is nil
Returns
The first return value is the state.value present for the attribute, the second return is the state
Return type
any or any
I am passing the component_id as a string, so I am a bit perplexed by the error