API is returning random results for garage door status

I think the smartthings API is having an issue? Not sure if this is a good place to ask, but I have an ongoing issue that if I ping/query the status of my garage door I am getting random results back, changing frequently.

Watching the web interface, there is no issue. The door status is indicated properly.

This small bit of example powershell illustrates the issue well, guids are changed here to random. This runs in a loop and if the status changes, it shows the new state. This is showing a lot of changes, every few seconds, even though the web UI is showing none of these changes.

Here’s the example output and the script.

Door status changed to: closed at 07/06/2025 20:36:12
closed
closed
open
Door status changed to: open at 07/06/2025 20:36:16
open
open
closed
Door status changed to: closed at 07/06/2025 20:36:20
closed
open
Door status changed to: open at 07/06/2025 20:36:23
open
closed
Door status changed to: closed at 07/06/2025 20:36:27
closed
open
Door status changed to: open at 07/06/2025 20:36:30
open
closed
Door status changed to: closed at 07/06/2025 20:36:32
open

Blockquote

$previousStatus = $null

while ($true) {
$response = Invoke-RestMethod -Uri “https://api.smartthings.com/v1/devices/624d9370-7966-4125-9c69-0f13b41fe020/status -Method Get
-Headers @{ “Authorization” = “Bearer a426ce63-9916-478c-9c7b-02fbf3bb5c05” }

$currentStatus = $response.components.main.doorControl.door.value

write-host $currentStatus

if ($currentStatus -ne $previousStatus) {
    Write-Host "Door status changed to: $currentStatus at $(Get-Date)"
    $previousStatus = $currentStatus
}

Start-Sleep -Seconds 1

}

As a dev on an enterprise web based application, this looks exactly like the API calls are being ran through a load balancer and the cache is dirty on some server instance the inbound call is routed to.

I’d be thinking the same thing. It might be informative to log the x-amz-cf-pop header if it is present to see which point of presence you are communicating with, and also the actual IP address as there are usually about six to eight in use at any one time.

I’ve had issues with both. The POP because my server occasionally picks up one in the US instead of the EU and the endpoint I was using turned out to be regional, and also with an API call failing on certain IP addresses. Neither sounds like what you are seeing.

It might also be good to look at the timestamp returned for the attribute as there is a live thread where something similar is being seen and the timestamp is clearly different (older) on the duff data in that case. Let’s flag @nayelyz and @itati as Developer Support have been working that one.

Thank you. I didn’t see x-amz-cf-pop, but with verbose logging I can catch the outbound remote IP in curl or with invoke-webrequest pretty nicely, and it is rotating, so it could be very helpful. Here’s my latest logging script. Including the timestamps is also a great idea.

I didn’t quite see what I was expecting. Could still be some additional load balancing going on that I’m not getting details for here. What we do see for sure is that the timestamp is stale for the incorrect information, in the case below,

Door status changed to: closed at 07/07/2025 12:03:46 (Server IP: 52.20.85.235, Door Timestamp: 07/07/2025 15:33:01)

Door status changed to: closed at 07/07/2025 12:03:50 (Server IP: 54.84.56.5, Door Timestamp: 07/07/2025 15:33:01)

So far, I’ve seen it can take 5 minutes to settle down, and 2 minutes. So no particularly interesting pattern there yet.

Door status changed to: open at 07/07/2025 12:03:42 (Server IP: 52.20.85.235, Door Timestamp: 07/07/2025 16:03:37)
Door status changed to: closed at 07/07/2025 12:03:46 (Server IP: 52.20.85.235, Door Timestamp: 07/07/2025 15:33:01)
Door status changed to: open at 07/07/2025 12:03:49 (Server IP: 52.20.85.235, Door Timestamp: 07/07/2025 16:03:37)
Door status changed to: closed at 07/07/2025 12:03:50 (Server IP: 54.84.56.5, Door Timestamp: 07/07/2025 15:33:01)
Door status changed to: open at 07/07/2025 12:03:52 (Server IP: 54.84.56.5, Door Timestamp: 07/07/2025 16:03:37)
Door status changed to: closed at 07/07/2025 12:03:53 (Server IP: 54.84.56.5, Door Timestamp: 07/07/2025 15:33:01)
Door status changed to: open at 07/07/2025 12:03:54 (Server IP: 54.84.56.5, Door Timestamp: 07/07/2025 16:03:37)
Door status changed to: closed at 07/07/2025 12:03:57 (Server IP: 54.84.56.5, Door Timestamp: 07/07/2025 15:33:01)
Door status changed to: open at 07/07/2025 12:03:58 (Server IP: 54.84.56.5, Door Timestamp: 07/07/2025 16:03:37)
Door status changed to: closed at 07/07/2025 12:04:00 (Server IP: 54.84.56.5, Door Timestamp: 07/07/2025 15:33:01)
Door status changed to: open at 07/07/2025 12:04:02 (Server IP: 54.84.56.5, Door Timestamp: 07/07/2025 16:03:37)
Door status changed to: closed at 07/07/2025 12:04:05 (Server IP: 54.84.56.5, Door Timestamp: 07/07/2025 15:33:01)
Door status changed to: open at 07/07/2025 12:04:06 (Server IP: 54.84.56.5, Door Timestamp: 07/07/2025 16:03:37)
Door status changed to: closed at 07/07/2025 12:04:09 (Server IP: 54.84.56.5, Door Timestamp: 07/07/2025 15:33:01)
Door status changed to: open at 07/07/2025 12:04:12 (Server IP: 54.86.139.148, Door Timestamp: 07/07/2025 16:03:37)
Door status changed to: closed at 07/07/2025 12:04:14 (Server IP: 54.86.139.148, Door Timestamp: 07/07/2025 15:33:01)
Door status changed to: open at 07/07/2025 12:04:19 (Server IP: 54.86.139.148, Door Timestamp: 07/07/2025 16:03:37)
Door status changed to: closed at 07/07/2025 12:04:20 (Server IP: 54.86.139.148, Door Timestamp: 07/07/2025 15:33:01)
Door status changed to: open at 07/07/2025 12:04:21 (Server IP: 54.86.139.148, Door Timestamp: 07/07/2025 16:03:37)
Door status changed to: closed at 07/07/2025 12:04:23 (Server IP: 54.86.139.148, Door Timestamp: 07/07/2025 15:33:01)


$previousStatus = $null
$hostName = "api.smartthings.com"
$VerbosePreference = 'SilentlyContinue'  # Suppress verbose output

while ($true) {
    # Resolve the hostname to get the IP address
    $serverIP = (Resolve-DnsName -Name $hostName -Type A).IPAddress | Select-Object -First 1

    # Make the API request using Invoke-WebRequest
    $response = Invoke-WebRequest -Uri "https://api.smartthings.com/v1/devices/b3ce7cb1-8636-4b6b-9046-e38a627a5a72/status" `
                                 -Method Get `
                                 -Headers @{ "Authorization" = "Bearer d4812352-41a9-4976-ac6f-... }

    # Parse the JSON response
    $jsonResponse = $response.Content | ConvertFrom-Json
    $currentStatus = $jsonResponse.components.main.doorControl.door.value
    $doorTimestamp = $jsonResponse.components.main.doorControl.door.timestamp

    if ($currentStatus -ne $previousStatus) {
        Write-Host "Door status changed to: $currentStatus at $(Get-Date) (Server IP: $serverIP, Door Timestamp: $doorTimestamp)"
        $previousStatus = $currentStatus
    }

    Start-Sleep -Seconds 1
}

Maybe seeing here that the stale information is a half hour old is interesting

Hi, @Robert_Castles

So, in your script, are you querying the status of the same device several times in a row, right?
Have you seen if the changes between on/off are registered in the device’s history?
I’m guessing it doesn’t. In the other case we’re investigating, the user changes the device status and when going back and forth between the dashboard and detail view, the capability status also changes but nothing is shown in the history.

If you want to detect changes in the door status, I would suggest you use subscriptions instead since you’ll get a device event when it gets assigned a new value and based on the observations from the other case, it should be only one.

Note: for this, you would need an API_ONLY app, but let me know if you want further instructions about that.

Hi, thanks for the information! I will look into subscriptions. I’m not sure I can use them in my case as it’s a native android app which is monitoring the garage door state on a relatively slow poll, like once per hour. Only while it’s actively monitoring does it start to query the garage door state a little more, say every 15 seconds. But unfortunately I am seeing that I am getting stale status information for the garage state based on the script I’m using to verify what I am seeing.

Yes, the web dashboard is always showing the proper garage state. It does not bounce between the open/closed state like I’m seeing in the API responses.

I appreciate your assistance. I would be happy to share more details about my setup, or provide unix based scripts that do the same as the powershell above.

And just to confirm, the bouncing state does not show in the device history. It’s only coming from the API queries.

Not to mention that there is no session-stickiness being used if that is happening.

Hi, @Robert_Castles
Just to confirm, Is this the device ID of the one you sent the logs in this post?
Also, could you open support access to your account, please?

  1. Confirm the email account registered in the forum is the same one you use for SmartThings. If not, please share it with me over DM
  2. Enable support access to your account:
  1. Go to the SmartThings Web (my.smartthings.com)
  2. Log in to your Samsung Account
  3. Select Menu (⋮) and choose Settings
  4. Toggle on Account Data Access
  5. Select the time period and confirm - In this step, please select “Until turned off”, once the team finishes, we’ll let you know so you can disable it again.

See more information about this access here: https://support.smartthings.com/hc/en-us/articles/36170233944852-Enabling-Account-Data-Access-for-Support

Hi, replied in DM

Hi, @Robert_Castles

Your account and data provided helped the engineering team’s investigation. They made some changes and tested querying the status for your device consecutively 105 times. Can you verify if the issue is solved using your developed integration, please?

It is looking a lot better with one test. my contact sensor seems stuck reporting as “open” when the door is closed, so hopefully that is just a local issue. I will try to see if I can get more out of it.

I will try again tomorrow as well.

Thank you!

Just to follow up, it’s working great now!