Using list type of custom presentation in edge driver

I’m making an edge driver with a custom presentation created.

The capability and presentation are as follows.

{
  "name": "test",
  "ephemeral": false,
  "attributes": {
      "action": {
          "schema": {
              "type": "object",
              "properties": {
                  "value": {
                      "title": "Command",
                      "type": "string",
                      "enum": [
                          "on",
                          "off"
                      ]
                  }
              },
              "additionalProperties": false,
              "required": [
                  "value"
              ]
          },
          "setter": "setAction",
          "enumCommands": [
          ]
      }
  },
  "commands": {
      "setAction": {
          "name": "setAction",
          "arguments": [
              {
                  "name": "mode",
                  "optional": false,
                  "schema": {
                      "title": "Command",
                      "type": "string",
                      "enum": [
                        "on",
                        "off"
                      ]
                  }
              }
          ]
      }
  }
}
{
  "dashboard": {
      "states": [],
      "actions": [],
      "basicPlus": []
  },
  "detailView": [
      {
          "label": "Command",
          "displayType": "list",
          "list": {
              "command": {
                  "name": "setAction",
                  "alternatives": [
                      {
                          "key": "on",
                          "value": "on",
                          "type": "active"
                      },
                      {
                          "key": "off",
                          "value": "off",
                          "type": "active"
                      }
                  ]
              },
              "state": {
                  "value": "action.value",
                  "alternatives": [
                    {
                      "key": "on",
                      "value": "on",
                      "type": "active"
                    },
                    {
                        "key": "off",
                        "value": "off",
                        "type": "active"
                    }
                  ]
              }
          },
          "state": null
      }
  ],
  "automation": {
      "conditions": [
      ],
      "actions": [
          {
              "label": "Command",
              "displayType": "list",
              "list": {
                  "alternatives": [
                    {
                      "key": "on",
                      "value": "on",
                      "type": "active"
                    },
                    {
                        "key": "off",
                        "value": "off",
                        "type": "active"
                    }
                  ],
                  "command": "setAction"
              }
          }
      ]
  },
  "id": "mynamespace.capability",
  "version": 1
}

And in the edge driver, I specified the command handler as follows

[caps['mynamespace'].ID] = {
          [caps['mynamespace.capability'].commands.setAction.NAME] = commands.action, 
}

The handler function runs fine. But

After selecting a list in DetailView, screen processing does not complete and an error message is displayed during loading

I tried to change the attribute of capability, but the following warning message is displayed

device:emit_event(caps['mynamespace.capability'].action('on'))

Attempted to generate event for f20779c7-1bf7-48c4-8adc-2f1c3e41a3db.main but it does not support capability test

What should I do? help me please

This behavior is really strange :thinking:

Can you provide the info below, please?

  • Which kind of driver are you using (LAN, Zigbee, Z-Wave)?
  • When you install the device do you receive any errors with the custom capability? For example, that it wasn’t found…
  • Did you initialize the custom capability in a driver’s lifecycle? Eg. Init, added, etc.

It was a problem that the capability was in a sub component other than main.

I solved it with emit_component_event

And there is one more unresolved issue.

I’m currently writing a Lan device edge driver.

It worked fine, but after a day (after quite a long time)

There is a 30 second delay when issuing the command.

Is there any information I can refer to?

Can you provide more details, please? I mean the following:

  • Does it happen every time you send or receive a command?
  • To which device are you connected? You could add its description, eg. brand
  • Does your network have multiple nodes in which the packets could take some time to be processed?

It doesn’t always happen, but it usually happens when you give a command after not working for a long time.

It is a LAN device connected by wifi and 5 devices have been added.

If you look at the logcat record in a situation where there is a delay,

A log indicating that the event handler has been activated is output. and and after a delay of more than 10~30 seconds

The log at the beginning of the function specified by capability_handlers is output.

Ok, I need more information to analyze the issue, so please, send the following info to build@smartthings.com:

  1. Share the complete logs of the delay you mention because the picture you shared is not clear to see in which process is happening.
    In this part, please print in the logs more messages to provide more information about the process, for example, in the case of LAN drivers a process is the following:

    • Start sending a command from the ST app. Eg. Send a switch command
    • This command is received in the capability handler. Here we can add something like print("switch capability handler called")
    • Then, you take this event to send the new status to the device, how this is handled, depends on you, but in this process, you can add a log before sending the command to the device > print("before sending command to the physical device") and another after print("after sending command to the physical device")
    • After sending the command, you need to check if the response, there you can print in the success case print("command successful"), in case an error is received: print("error response"..error)
  2. A detailed description of the behavior you’ve observed. For example:

“When I click on the button to turn on the device, I see the event is displayed in the logs. Then, when the command to the device is sent, it takes around 30 seconds to turn on the physical device.
This generally happens after I haven’t used the device in the ST app for a long time.”

Is this a main device that handles other five? If the delay is from the command sent in the ST app to the final device, have you checked the logs in each one?
This is to see if the delay is from ST to main or main to final device (Include your response in the email as well, please)

Here is the log of the first line of the capability handler

log.info(“on command_handler.open”)

log.info(“on command_handler.close”)

The capability handler being called itself is delayed

In the first image I see an event arrive 17.81 seconds after 02:14 am, and then the capability handler log at 18.51 seconds. So that is 0.7 seconds.

In the second image I see an event arriving at 25.55 seconds into the same minute and the capability handler log at 25.61 seconds (when rounded), so that is 0.06 seconds.

log is output immediately when the actual command is issued ( device thread event handled ). And after a few seconds it goes on to the next.

After that, the problem goes away, but the same symptoms appear after an hour or so.

The start log of the command handler is

It is output from the DEBUG log. ( device thread event handled )

These are the only two logs I left

on command_handler.open
on command_handler.close

When I checked again, the point at which the event handler starts is when

Received event with handler capability

is output.

I’ll have to check again

collected logs and emailed them to build@smartthings.com. please check

can check the [Receive event with handler capability log] around 2022-01-19 00:51:18.

after a long delay

can check the [Found CapabilityCommandDispatcher Handler] log around 00:52:52 seconds.

There seems to be a delay between finding and calling the handler function after the event handler is received.