Skip to content

Conversation

AmineI
Copy link

@AmineI AmineI commented Dec 29, 2023

There is a type issue with deviceCommand() callback's type, impacting the usage of smartApp.deviceCommand() in TypeScript.

deviceCommand() defines a callback with a command parameter of type DeviceCommand. This is incorrect, as DeviceCommand has a component attribute, instead of componentId attribute as obtained from the APIs.

Default deviceCommandHandler() is not impacted, as it uses the interface DeviceCommandsEvent, itself using the correct type DeviceCommandsEventCommand.

This is becoming a mouthful. Here are the current classes :

Incorrect for deviceCommand()
https://github.com/SmartThingsCommunity/smartthings-core-sdk/blob/bdd6bcc59044daef46725524e7fb3234d4cc0c1a/src/endpoint/rules.ts#L185-L191

Correct for deviceCommand()

export class DeviceCommandsEventCommand {
componentId: string
capability: string
command: string
arguments: any[]
}

Note that this PR is marked as incomplete, as this DeviceCommandsEventCommand is difficult to import for external projects. I would leave that decision to you in order to export or create an interface.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • I have read the CONTRIBUTING document
  • My code follows the code style of this project (hint: install an xo editor plugin)
  • Any required documentation has been added
  • I have added tests to cover my changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant