GoogleCloudPlatform / node-red-contrib-google-cloud

Node-RED nodes for Google Cloud Platform
Apache License 2.0
90 stars 57 forks source link

Help requested with iot core #60

Closed MiLaak closed 4 years ago

MiLaak commented 4 years ago

In Node-Red, what would be easiest way to send commands or configurations to IoT Devices?

There is node.js example in https://cloud.google.com/iot/docs/how-tos/commands -> API -> Node.js

But it seems to take quite few steps to take it in use if running .js code in Node-Red which is running in Docker image.

kolban-google commented 4 years ago

Let me start looking at what kinds of things this package may wish to add for Node-RED GCP IoT support. If you could post back with as many example use cases or stories as you can think of, that would help.

MiLaak commented 4 years ago

Hi,

I'm running Node-Red in custom docker image in the same GCP project where IoT Core is running. There are couple of iot devices are connected to Iot Core.

GUI for is done with Node Red Dashboard. My use case is such that I want to send command and/or configuration (string containing json blob) to my IoT Devices from Node Red.

Not sure if I was able to describe this as useful story or use case... Let me know if more details needed.

kolban-google commented 4 years ago

Reviewing the spec of GCP IoT ... I see that the logical content of a command sent to a device is:

For command processing, I'm imagining a new GCP IoT node "IoT Command" that would take these parameters and make the command call. Would this be in-line with your thinking? This would be the Node-RED equivalent of https://cloud.google.com/sdk/gcloud/reference/iot/devices/commands

For configuration processing, similar story. I'm imagining a new GCP IoT node "IoT Configuration" that would take these parameters and make a configuration update call.

This would be the Node-RED equivalent of https://cloud.google.com/sdk/gcloud/reference/iot/devices/configs/update

I'll be delighted to work on the Node-RED/GCP side of the story. I'm hoping that you can guide me on the "requirements" aspect. That way the nodes can deliver exactly what you want.

MiLaak commented 4 years ago

I'm not either too experienced with IoT Core but for now I'm using following commands to do the job from the Cloud Shell:

gcloud iot devices configs update --project=$PROJECT_NAME \ --region=$PROJECT_REGION \ --registry=$REGISTRY_NAME \ --device=$DEVICE_ID1 \ --config-data="configuration data"

gcloud iot devices commands send --project=$PROJECT_NAME \ --region=$PROJECT_REGION \ --registry=$REGISTRY_NAME \ --device=$DEVICE_ID1 \ --command-data="command data"

Some wishes:

E.g. it would be user friendly to just define registry, device and the data to be sent. Optional/automatically detected parameters would be project and region.

kolban-google commented 4 years ago

Perfect response. THANK you for that. I'll get started on it straight away. I think I can accommodate all the requests. If you wish, email me at kolban@google.com and we can chit chat privately ... this will become useful if you are willing to take builds to test before we publish to github for all.

kolban-google commented 4 years ago

A couple of new nodes have been built and added to the collection. They are being tested with the requester and not yet released.

kolban-google commented 4 years ago

The code has now been published as part of 0.0.15. Waiting from validation from requester.

MiLaak commented 4 years ago

Everything works as requested. Thanks for support!

kolban-google commented 4 years ago

TY for raising the request. Closing the issue as complete. Re-open or create a new one as needed.