createEntityAttributesSubscription static method

TelemetrySubscriber createEntityAttributesSubscription({
  1. required TelemetryService telemetryService,
  2. required EntityId entityId,
  3. required String attributeScope,
  4. List<String>? keys,
})

Implementation

static TelemetrySubscriber createEntityAttributesSubscription(
    {required TelemetryService telemetryService,
    required EntityId entityId,
    required String attributeScope,
    List<String>? keys}) {
  SubscriptionCmd subscriptionCommand;
  var subscriptionKeys = keys != null ? keys.join(',') : null;
  if (attributeScope == LatestTelemetry.LATEST_TELEMETRY.toShortString()) {
    subscriptionCommand = TimeseriesSubscriptionCmd(
        entityId: entityId.id!,
        entityType: entityId.entityType,
        keys: subscriptionKeys);
  } else {
    var scope = attributeScopeFromString(attributeScope);
    subscriptionCommand = AttributesSubscriptionCmd(
        entityId: entityId.id!,
        entityType: entityId.entityType,
        keys: subscriptionKeys,
        scope: scope);
  }
  return TelemetrySubscriber(telemetryService, [subscriptionCommand]);
}