Getting information about devices
To find out the unique ID or name of a device, get a list of devices in a registry.
Getting a list of devices in a registry
If you don't know the unique ID or name of the registry where your device is located, view the list of existing registries.
- In the management console
, select the folder where the registry is located. - Select IoT Core.
- Select the registry.
- Go to the Devices tab.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
View the description of the CLI command to get a list of devices:
yc iot device list --help
-
Get a list of devices in the registry by specifying its name or ID:
yc iot device list --registry-name <registry_name>
Result:
+----------------------+-----------+ | ID | NAME | +----------------------+-----------+ | b9135goeh1uc******** | my-device | +----------------------+-----------+
To get a list of devices in a registry, use the list REST API method for the Device resource or the DeviceService/List gRPC API call.
Getting information about a device
To access a device, use the unique ID or name of the registry from the previous step.
- In the management console
, select the folder where the device is located. - Select IoT Core.
- Select the registry where the device is located.
- Go to the Devices tab.
- Select the device.
- The Overview page will show the device details.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
View the description of the CLI command to get information about a device:
yc iot device get --help
-
Get detailed information about a device by specifying its name or ID:
yc iot device get <device_name>
Result:
id: b9135goeh1uc******** registry_id: b91ki3851hab******** created_at: "2019-05-28T16:08:30.938Z" name: my-device
Terraform
For more information about the provider resources, see the documentation on the Terraform
If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
If you don't have Terraform, install it and configure the Yandex Cloud provider.
To get detailed information about a device using Terraform:
-
Add the
data
andoutput
sections to the Terraform configuration file:data "yandex_iot_core_device" "my_device" { device_id = "<device_ID>" } output "device_params" { value = data.yandex_iot_core_device.my_device.registry_id }
Where:
data "yandex_iot_core_device"
: Description of the device as a data source:device_id
: Device ID.
output "device_params"
: Output variable containing information about the registry the device belongs to:value
: Returned value.
You can replace
registry_id
with any other parameter to get the information you need. For more information about theyandex_iot_core_device
data source parameters, see the provider documentation . -
Create resources:
-
In the terminal, change to the folder where you edited the configuration file.
-
Make sure the configuration file is correct using the command:
terraform validate
If the configuration is correct, the following message is returned:
Success! The configuration is valid.
-
Run the command:
terraform plan
The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
in the terminal and press Enter.
Terraform will create the required resources and display the output variable values in the terminal. To check the results, run:
terraform output
Result:
device_params = "are7ajlrf493********"
-
To get detailed information about a device, use the get REST API method for the Device resource or the DeviceService/Get gRPC API call.
Device monitoring data is updated when accessing the device via gRPCS and MQTT. The quality of service (QoS) level is at most once.