Device specific storage

I need to have the endpoint id for future calculations something like device.fingerprinted_endpoint_id
this value should be fast and easily readable as it’s part of many functions.

should I use

local function first_button_ep(device)
  return device:get_field("first_button_ep")
end

or there is a better, faster way to get the value

@veonua You can get it from its component/endpoint association:

-- component associated to device.fingerprinted_endpoint_id
local component = "..."
device:get_endpoint_for_component_id(component)

unfortunately, there is a many-to-many relationship, eg. component has a button ep:4 and a switch ep:2

If you made the endpoint to component association as documented at the Zigbee libraries / Multi-Component devices, you should be able to easily query any endpoint dynamically.

Also, to have a better context, can you share more details about the implementation you’re trying to achieve?

get_endpoint_for_component_id returns a number,

2

while I need a dictionary

{
  capability.switch : 2,
  capability.button: 4
}
1 Like

Since it is a data structure what you need to save and collect, yes, the persistent_store is an accurate approach.