Created
November 3, 2025 05:28
-
-
Save sscotth/ac4599815d6f836f2f0c647623353b59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| BEARER_TOKEN="xxxxxx" | |
| API_BASE_URL="https://api.smartthings.com/v1/devices" | |
| # --- Configuration (EDIT THIS ARRAY ONLY) --- | |
| DEVICE_IDS=( | |
| "xxxxx" | |
| "xxxxx" | |
| "xxxxx" | |
| # Add more here as needed | |
| ) | |
| echo "Starting time update process for ${#DEVICE_CONFIGS[@]} devices." | |
| echo "--------------------------------------------------" | |
| for DEVICE_ID in "${DEVICE_IDS[@]}"; do | |
| API_URL="${API_BASE_URL}/${DEVICE_ID}/commands" | |
| CURRENT_TIME=$(date +"%Y-%m-%dT%H:%M:%S") | |
| echo "➡️ Processing Device ID: ${DEVICE_ID}" | |
| echo " Time: ${CURRENT_TIME}" | |
| JSON_BODY=$(printf ' | |
| { | |
| "commands" : [ | |
| { | |
| "component" : "main", | |
| "capability" : "execute", | |
| "command" : "execute", | |
| "arguments" : [ | |
| "/configuration/vs/0", | |
| { | |
| "x.com.samsung.da.currentTime" : "%s" | |
| } | |
| ] | |
| } | |
| ] | |
| }' "$CURRENT_TIME") | |
| HTTP_CODE=$(curl -s -X POST \ | |
| -H "Authorization: Bearer ${BEARER_TOKEN}" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$JSON_BODY" \ | |
| -o /dev/null \ | |
| -w "%{http_code}" \ | |
| "$API_URL") | |
| if [ "$HTTP_CODE" = "200" ]; then | |
| echo " ✅ Success (HTTP 200)" | |
| else | |
| echo " ❌ Failed (HTTP ${HTTP_CODE})" | |
| fi | |
| echo "--------------------------------------------------" | |
| done | |
| echo "✨ Script finished." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment