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

Add ability to publish commands to devices by device ID via Meadow.Cloud #343

Merged
merged 1 commit into from
Aug 24, 2023

Conversation

stevenkuhn
Copy link
Contributor

This updates the ability to publish commands to a collection of devices via Meadow.Cloud by including the the ability to specify devices by their device ID. The update command is meadow cloud command publish <COMMAND_NAME> --deviceIds <a list of device ids>. The generated help text for this new command is:

USAGE
  meadow cloud command publish <COMMAND_NAME> [options]

DESCRIPTION
  Publish a command to Meadow devices via the Meadow Service

PARAMETERS
* COMMAND_NAME      The name of the command

OPTIONS
  -c|--collectionId  The target collection for publishing the command
  -d|--deviceIds    The target devices for publishing the command
  -a|--args         The arguments for the command as a JSON string
  -q|--qos          The MQTT-defined quality of service for the command Choices: "AtLeastOnce", "AtMostOnce", "ExactlyOnce". Default: "AtLeastOnce".
  --host            Optionally set a host (default is https://www.meadowcloud.co)
  -h|--help         Shows help text.

With this update, meadow cloud command publish can either take in a collectionId or a list of deviceIds.

Example

An example of this command would be:

C:\>meadow login
Signed in as [email protected]
Done!

C:\>meadow cloud command publish TurnOnWater -d example_device_id1 example_device_id2 -a "{""durationInMinutes"":15}"
Publishing 'TurnOnWater ' command to Meadow.Cloud. Please wait...
Publish command successful.
Done!

If the included arguments are not properly formatted (quotes need to be escaped), a JSON error will occur:

C:\>meadow cloud command publish TurnOnWater -d example_device_id1 example_device_id2 -a "{"duration":15}"
Provided arguments is not valid JSON: 'd' is an invalid start of a property name. Expected a '"'. LineNumber: 0 | BytePositionInLine: 1.
Done!

If neither a collection ID nor device IDs are specified:

C:\>meadow cloud command publish TurnOnWater 
Either a collection ID (-c|--collectionId) or a list of device IDs (-d|--deviceIds) must be specified.

...more...

If both collection ID and device IDs are specified:

C:\>meadow cloud command publish TurnOnWater -c example_collection_id -d example_device_id1 example_device_id2
Cannot specify both a collection ID (-c|--collectionId) and list of device IDs (-d|--deviceIds). Only one is allowed.

...more...

Copy link
Collaborator

@lamebrain lamebrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! 🔥

@stevenkuhn stevenkuhn merged commit 663fe46 into develop Aug 24, 2023
6 checks passed
@stevenkuhn stevenkuhn deleted the cloud-command-publish branch August 24, 2023 16:54
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.

2 participants