Skip to content

@xcons/cli-thingsboard - Widget Bundle List Kılavuzu

Bu dokümantasyon, XCONS ThingsBoard CLI ile widget bundle listeleme işlemlerini detaylı olarak açıklar.

Widget Bundle List Komutu

bash
xcons-thingsboard widget-bundle list [options]

Seçenekler

  • -h, --host <host>: ThingsBoard sunucu adresi (örn: 192.168.233.132:8080)
  • -u, --user <email>: ThingsBoard kullanıcı adı/email
  • -p, --pass <password>: ThingsBoard şifresi
  • -f, --filter <text>: Bundle adı, açıklama veya ID'ye göre filtreleme
  • --json: Sonuçları JSON formatında çıktı al

Temel Kullanım

Tüm Bundle'ları Listeleme

bash
# Interaktif sunucu bağlantısı
xcons-thingsboard widget-bundle list

# Sunucu bilgileri ile listeleme
xcons-thingsboard widget-bundle list \
  -h 192.168.233.132:8080 \
  -u admin@domain.com \
  -p password

Filtrelenmiş Listeleme

bash
# Bundle adına göre filtreleme
xcons-thingsboard widget-bundle list \
  -h localhost:8080 -u tenant@thingsboard.org -p tenant \
  --filter "Custom"

# Açıklamaya göre filtreleme
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --filter "dashboard"

# ID'ye göre filtreleme
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --filter "cf355dd0"

JSON Çıktısı

bash
# JSON formatında çıktı
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --json

# JSON çıktısını dosyaya kaydet
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --json > bundles.json

Çıktı Formatları

Tablo Formatı (Varsayılan)

bash
xcons-thingsboard widget-bundle list -h server:8080 -u admin -p pass

Örnek Çıktı:

Fetching ThingsBoard widget bundles from server...
Found 5 widget bundles

Server: http://192.168.233.132:8080

ID                                      TITLE                         DESCRIPTION
--------------------------------------------------------------------------------------------------------
13814000-1dd2-11b2-8080-808080808080    Cards                        Card widgets
13814001-1dd2-11b2-8080-808080808080    Charts                       Chart widgets for visualization
13814002-1dd2-11b2-8080-808080808080    Control widgets              Control widgets for RPC
13814003-1dd2-11b2-8080-808080808080    Custom Dashboards            Custom dashboard widgets
278b4440-f894-11ef-bf2f-f7b9477f8896    Xcon Studio                  Widget bundle created by XCONS CLI

Total: 5 bundles

Use --json flag to get detailed information
Use --filter <text> to filter by title, description or ID

JSON Formatı

bash
xcons-thingsboard widget-bundle list --json -h server:8080 -u admin -p pass

Örnek JSON Çıktısı:

json
[
  {
    "id": "13814000-1dd2-11b2-8080-808080808080",
    "title": "Cards",
    "description": "Card widgets"
  },
  {
    "id": "13814001-1dd2-11b2-8080-808080808080", 
    "title": "Charts",
    "description": "Chart widgets for visualization"
  },
  {
    "id": "13814002-1dd2-11b2-8080-808080808080",
    "title": "Control widgets", 
    "description": "Control widgets for RPC"
  },
  {
    "id": "278b4440-f894-11ef-bf2f-f7b9477f8896",
    "title": "Xcon Studio",
    "description": "Widget bundle created by XCONS CLI for custom widgets"
  }
]

Filtreleme Örnekleri

Ad Bazlı Filtreleme

bash
# "Chart" içeren bundle'lar
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --filter "Chart"

# "Custom" içeren bundle'lar  
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --filter "Custom"

# "Xcon" içeren bundle'lar
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --filter "Xcon"

Filtrelenmiş Çıktı Örneği:

Fetching ThingsBoard widget bundles from server...
Found 5 widget bundles
Processing 5 widget bundles...
Filter applied: 1/5 widget bundles match "Xcon"

Filtered by: Xcon
Server: http://192.168.233.132:8080

ID                                      TITLE                         DESCRIPTION
--------------------------------------------------------------------------------------------------------
278b4440-f894-11ef-bf2f-f7b9477f8896    Xcon Studio                  Widget bundle created by XCONS CLI

Total: 1 bundles

Use --json flag to get detailed information
Use --filter <text> to filter by title, description or ID

Açıklama Bazlı Filtreleme

bash
# "dashboard" içeren açıklamalar
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --filter "dashboard"

# "control" içeren açıklamalar
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --filter "control" 

# "visualization" içeren açıklamalar
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --filter "visualization"

ID Bazlı Filtreleme

bash
# Kısmi ID ile arama
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --filter "278b4440"

# Tam ID ile arama
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --filter "278b4440-f894-11ef-bf2f-f7b9477f8896"

Sunucu Bağlantısı

İnteraktif Bağlantı

Parametreler verilmezse CLI interaktif olarak sorar:

bash
xcons-thingsboard widget-bundle list

İnteraktif Soru Sırası:

ThingsBoard server connection required
? ThingsBoard server host (with port): 192.168.233.132:8080
? Username/Email: admin@domain.com  
? Password: [gizli giriş]

Doğrudan Bağlantı

bash
# Tüm parametrelerle
xcons-thingsboard widget-bundle list \
  -h 192.168.233.132:8080 \
  -u tenant@thingsboard.org \
  -p tenant

# Minimal parametreler (şifre interaktif sorulur)
xcons-thingsboard widget-bundle list \
  -h localhost:8080 \
  -u admin@thingsboard.org

Pratik Kullanım Senaryoları

XCONS Bundle Kontrolü

bash
# XCONS CLI tarafından oluşturulan bundle'ı bul
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --filter "Xcon Studio"

Bundle Durumu Analizi

bash
# Tüm bundle'ları JSON olarak al ve analiz et
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass \
  --json > bundles.json

# Bundle sayısını say
jq length bundles.json

# Bundle isimlerini listele
jq -r '.[].title' bundles.json

# Açıklama olan bundle'lar
jq '.[] | select(.description != "")' bundles.json

Bundle Arama

bash
# Birden fazla anahtar kelime ile arama
terms=("dashboard" "control" "chart" "custom")

for term in "${terms[@]}"; do
  echo "=== Searching for: $term ==="
  xcons-thingsboard widget-bundle list \
    -h server:8080 -u admin -p pass \
    --filter "$term"
  echo
done

Hata Durumları ve Çözümler

Bağlantı Hataları

Hata: ThingsBoard server not found - Check host address

Çözüm:

bash
# Host adresini kontrol et
ping 192.168.233.132

# Port kontrolü
telnet 192.168.233.132 8080

# Protokol ekle
xcons-thingsboard widget-bundle list -h http://192.168.233.132:8080

Kimlik Doğrulama Hataları

Hata: Authentication failed - Invalid username or password

Çözüm:

bash
# Kullanıcı bilgilerini doğrula
# ThingsBoard web arayüzünde giriş dene

# Farklı kullanıcı dene
xcons-thingsboard widget-bundle list \
  -h server:8080 \
  -u sysadmin@thingsboard.org \
  -p sysadmin

Yetki Hataları

Hata: Access forbidden - User may not have required permissions

Çözüm:

bash
# Yönetici hesabı kullan
xcons-thingsboard widget-bundle list \
  -h server:8080 \
  -u sysadmin@thingsboard.org \
  -p sysadmin

# Tenant admin hesabı kullan
xcons-thingsboard widget-bundle list \
  -h server:8080 \
  -u tenant@thingsboard.org \
  -p tenant

Boş Sonuç

Çıktı: No widget bundles found on the server.

Kontroller:

bash
# Filtreyi kaldır
xcons-thingsboard widget-bundle list \
  -h server:8080 -u admin -p pass

# Farklı kullanıcı dene (bundle görüntüleme yetkileri farklı olabilir)
xcons-thingsboard widget-bundle list \
  -h server:8080 -u sysadmin@thingsboard.org -p sysadmin

# Tenant değiştir (multi-tenant ortamda)

Gelişmiş Kullanım

Scripting ile Bundle Yönetimi

bash
#!/bin/bash

# Bundle listesi al ve işle
get_bundles() {
    local host=$1
    local user=$2
    local pass=$3
    
    xcons-thingsboard widget-bundle list \
        -h "$host" -u "$user" -p "$pass" \
        --json
}

# Bundle sayısını say
count_bundles() {
    get_bundles "$@" | jq length
}

# Belirli bundle'ı bul
find_bundle() {
    local host=$1
    local user=$2
    local pass=$3
    local search_term=$4
    
    get_bundles "$host" "$user" "$pass" | \
        jq -r ".[] | select(.title | contains(\"$search_term\")) | .id"
}

# Kullanım
TB_HOST="localhost:8080"
TB_USER="tenant@thingsboard.org"
TB_PASS="tenant"

echo "Total bundles: $(count_bundles $TB_HOST $TB_USER $TB_PASS)"
echo "Xcon bundle ID: $(find_bundle $TB_HOST $TB_USER $TB_PASS "Xcon")"

Bundle Karşılaştırma

bash
# İki farklı sunucudaki bundle'ları karşılaştır
get_bundle_names() {
    xcons-thingsboard widget-bundle list \
        -h "$1" -u "$2" -p "$3" \
        --json | jq -r '.[].title' | sort
}

# Sunucu 1 bundle'ları
get_bundle_names "server1:8080" "admin" "pass1" > server1_bundles.txt

# Sunucu 2 bundle'ları
get_bundle_names "server2:8080" "admin" "pass2" > server2_bundles.txt

# Fark analizi
echo "=== Server1'de olup Server2'de olmayan bundle'lar ==="
comm -23 server1_bundles.txt server2_bundles.txt

echo "=== Server2'de olup Server1'de olmayan bundle'lar ==="
comm -13 server1_bundles.txt server2_bundles.txt

echo "=== Her iki sunucuda da olan bundle'lar ==="
comm -12 server1_bundles.txt server2_bundles.txt

Bundle İstatistikleri

bash
# Bundle istatistiklerini çıkar
analyze_bundles() {
    local json_file=$1
    
    echo "=== Bundle İstatistikleri ==="
    echo "Toplam bundle sayısı: $(jq length "$json_file")"
    echo "Açıklaması olan bundle sayısı: $(jq '[.[] | select(.description != "")] | length' "$json_file")"
    echo "Açıklaması olmayan bundle sayısı: $(jq '[.[] | select(.description == "")] | length' "$json_file")"
    
    echo -e "\n=== En Uzun Bundle Adları ==="
    jq -r '.[] | "\(.title | length) - \(.title)"' "$json_file" | sort -nr | head -5
    
    echo -e "\n=== Bundle ID'leri ==="
    jq -r '.[].id' "$json_file"
}

# Kullanım
xcons-thingsboard widget-bundle list --json > bundles.json
analyze_bundles bundles.json

Bundle Monitoring

Bundle Değişiklik Takibi

bash
#!/bin/bash

MONITOR_FILE="bundle_history.log"
TB_HOST="localhost:8080"
TB_USER="tenant@thingsboard.org"
TB_PASS="tenant"

monitor_bundles() {
    local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
    local count=$(xcons-thingsboard widget-bundle list \
        -h "$TB_HOST" -u "$TB_USER" -p "$TB_PASS" \
        --json | jq length)
    
    echo "$timestamp: $count bundles" >> "$MONITOR_FILE"
    
    if [ -f "last_bundles.json" ]; then
        # Önceki snapshot ile karşılaştır
        local changes=$(diff <(jq -r '.[].id' last_bundles.json | sort) \
                            <(jq -r '.[].id' current_bundles.json | sort) | wc -l)
        if [ "$changes" -gt 0 ]; then
            echo "$timestamp: Bundle değişikliği tespit edildi!" >> "$MONITOR_FILE"
        fi
    fi
    
    cp current_bundles.json last_bundles.json
}

# Mevcut bundle'ları al
xcons-thingsboard widget-bundle list \
    -h "$TB_HOST" -u "$TB_USER" -p "$TB_PASS" \
    --json > current_bundles.json

# Monitoring fonksiyonunu çalıştır
monitor_bundles

Otomatik Bundle Raporu

bash
#!/bin/bash

generate_bundle_report() {
    local report_file="bundle_report_$(date +%Y%m%d_%H%M%S).html"
    
    cat > "$report_file" << EOF
<!DOCTYPE html>
<html>
<head>
    <title>ThingsBoard Bundle Report</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 40px; }
        table { border-collapse: collapse; width: 100%; }
        th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
        th { background-color: #f2f2f2; }
        .stats { background-color: #e7f3ff; padding: 15px; margin: 20px 0; }
    </style>
</head>
<body>
    <h1>ThingsBoard Widget Bundle Report</h1>
    <div class="stats">
        <h2>İstatistikler</h2>
        <p>Toplam Bundle Sayısı: $(jq length bundles.json)</p>
        <p>Rapor Tarihi: $(date)</p>
        <p>Sunucu: $TB_HOST</p>
    </div>
    
    <h2>Bundle Listesi</h2>
    <table>
        <tr>
            <th>Bundle Adı</th>
            <th>ID</th>
            <th>Açıklama</th>
        </tr>
EOF

    jq -r '.[] | "<tr><td>\(.title)</td><td>\(.id)</td><td>\(.description)</td></tr>"' bundles.json >> "$report_file"
    
    cat >> "$report_file" << EOF
    </table>
</body>
</html>
EOF

    echo "Rapor oluşturuldu: $report_file"
}

# Bundle'ları al ve rapor oluştur
xcons-thingsboard widget-bundle list --json > bundles.json
generate_bundle_report

Bundle CSV Export

bash
# Bundle'ları CSV formatında export et
export_bundles_csv() {
    echo "ID,Title,Description" > bundles.csv
    xcons-thingsboard widget-bundle list \
        -h "$1" -u "$2" -p "$3" \
        --json | jq -r '.[] | [.id, .title, .description] | @csv' >> bundles.csv
    echo "Bundle'lar bundles.csv dosyasına export edildi"
}

# Kullanım
export_bundles_csv "localhost:8080" "admin" "password"

Sonraki Adımlar

Bundle listeleme işleminden sonra:

  1. Widget Bundle Oluşturma - Yeni bundle'lar oluşturma
  2. Widget Listeleme - Bundle'lardaki widget'ları görüntüleme
  3. Widget Kurulum - Widget'ları bundle'lara yükleme

Bundle listeleme işlemi tamamlandı. Bundle'larınızı artık yönetebilirsiniz!