Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Type issue for non-default DeviceCommandHandlers #256

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

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