getResourceName method

ResourceName getResourceName(
  1. String name
)

Get a ResourceName from this Subtype and a provided name

// Example, getting the ResourceName of a sensor named "my_sensor":
var resourceName = Sensor.getResourceName('my_sensor');

Implementation

ResourceName getResourceName(String name) {
  return ResourceName()
    ..namespace = namespace
    ..type = resourceType
    ..subtype = resourceSubtype
    ..remotePath.addAll(name.split(':')..removeLast())
    ..name = name
    ..localName = name.split(':').last;
}