https://api.switch-bot.com/v1.1/scenes returning inconsistent results
Analysis
Hello,
I've been using the API for about 2 years now without any problem, but I recently started encountering a weird problem when pinging the scenes endpoint. Not consistently, and I can't figure out what determines the response I get, but sometimes I get this response instead of my actual scenes:
{'statusCode': 100, 'body': [{'sceneId': 'e9c0e4b8-f42b-44df-a78b-e5052ca059a9', 'sceneName': 'Away Timer'}, {'sceneId': 'T01-202311051051-42770763', 'sceneName': 'Blinds Close'}, {'sceneId': 'T01-202311051052-03879961', 'sceneName': 'Blinds Open'}], 'message': 'success'}
Expected Behavior
{'statusCode': 100, 'body': [{'sceneId': 'd12d1bc4-7aa0-4acd-94f4-bbb6ff5c6d3f', 'sceneName': 'Heat Garage'}, {'sceneId': '13e61baf-d54c-40b3-8693-8e3a89501b52', 'sceneName': 'Alarm Start'}, {'sceneId': '3f17d748-c78b-4d83-84d1-1a456b016f1e', 'sceneName': 'Alarm Stop'}, {'sceneId': 'ac8d7721-62d9-41ee-8c12-f0500243abad', 'sceneName': 'Night Light'}, {'sceneId': '44c0cf31-4d02-4b05-a1d8-c4ca3543fe95', 'sceneName': 'Lights Off'}, {'sceneId': '2a33292e-d067-4d42-8df5-a4d27f8ef449', 'sceneName': 'Toggle Bedroom Light'}], 'message': 'success'}
Steps To Reproduce
Ping https://api.switch-bot.com/v1.1/scenes
Logs
`{'statusCode': 100, 'body': [{'sceneId': 'e9c0e4b8-f42b-44df-a78b-e5052ca059a9', 'sceneName': 'Away Timer'}, {'sceneId': 'T01-202311051051-42770763', 'sceneName': 'Blinds Close'}, {'sceneId': 'T01-202311051052-03879961', 'sceneName': 'Blinds Open'}], 'message': 'success'}`
versus
`{'statusCode': 100, 'body': [{'sceneId': 'd12d1bc4-7aa0-4acd-94f4-bbb6ff5c6d3f', 'sceneName': 'Heat Garage'}, {'sceneId': '13e61baf-d54c-40b3-8693-8e3a89501b52', 'sceneName': 'Alarm Start'}, {'sceneId': '3f17d748-c78b-4d83-84d1-1a456b016f1e', 'sceneName': 'Alarm Stop'}, {'sceneId': 'ac8d7721-62d9-41ee-8c12-f0500243abad', 'sceneName': 'Night Light'}, {'sceneId': '44c0cf31-4d02-4b05-a1d8-c4ca3543fe95', 'sceneName': 'Lights Off'}, {'sceneId': '2a33292e-d067-4d42-8df5-a4d27f8ef449', 'sceneName': 'Toggle Bedroom Light'}], 'message': 'success'}`
Configuration
self.base_url = "https://api.switch-bot.com/"
self.headers = {
"Authorization": token,
"Content-Type": "application/json; charset=utf8",
"t": str(t),
"sign": str(sign, "utf-8"),
"nonce": str(nonce),
}
url = f"{self.base_url}v1.1/scenes"
Environment
- OS: PyOS
- Software: Python
- Node: v14.21.3
- npm: 6.14.18
Additional Context
No response
It's still happening:
Sending get scenes request
Scenes response: {'statusCode': 100, 'body': [{'sceneId': 'e9c0e4b8-f42b-44df-a78b-e5052ca059a9', 'sceneName': 'Away Timer'}, {'sceneId': 'T01-202311051051-42770763', 'sceneName': 'Blinds Close'}, {'sceneId': 'T01-202311051052-03879961', 'sceneName': 'Blinds Open'}], 'message': 'success'}
Sending get scenes request
Scenes response: {'statusCode': 100, 'body': [{'sceneId': 'e9c0e4b8-f42b-44df-a78b-e5052ca059a9', 'sceneName': 'Away Timer'}, {'sceneId': 'T01-202311051051-42770763', 'sceneName': 'Blinds Close'}, {'sceneId': 'T01-202311051052-03879961', 'sceneName': 'Blinds Open'}], 'message': 'success'}
Sending get scenes request
Scenes response: {'statusCode': 100, 'body': [{'sceneId': 'e9c0e4b8-f42b-44df-a78b-e5052ca059a9', 'sceneName': 'Away Timer'}, {'sceneId': 'T01-202311051051-42770763', 'sceneName': 'Blinds Close'}, {'sceneId': 'T01-202311051052-03879961', 'sceneName': 'Blinds Open'}], 'message': 'success'}
Sending get scenes request
Scenes response: {'statusCode': 100, 'body': [{'sceneId': 'e9c0e4b8-f42b-44df-a78b-e5052ca059a9', 'sceneName': 'Away Timer'}, {'sceneId': 'T01-202311051051-42770763', 'sceneName': 'Blinds Close'}, {'sceneId': 'T01-202311051052-03879961', 'sceneName': 'Blinds Open'}], 'message': 'success'}
Sending get scenes request
Scenes response: {'statusCode': 100, 'body': [{'sceneId': 'e9c0e4b8-f42b-44df-a78b-e5052ca059a9', 'sceneName': 'Away Timer'}, {'sceneId': 'T01-202311051051-42770763', 'sceneName': 'Blinds Close'}, {'sceneId': 'T01-202311051052-03879961', 'sceneName': 'Blinds Open'}], 'message': 'success'}
Sending get scenes request
Scenes response: {'statusCode': 100, 'body': [{'sceneId': 'e9c0e4b8-f42b-44df-a78b-e5052ca059a9', 'sceneName': 'Away Timer'}, {'sceneId': 'T01-202311051051-42770763', 'sceneName': 'Blinds Close'}, {'sceneId': 'T01-202311051052-03879961', 'sceneName': 'Blinds Open'}], 'message': 'success'}
Sending get scenes request
Scenes response: {'statusCode': 100, 'body': [{'sceneId': 'd12d1bc4-7aa0-4acd-94f4-bbb6ff5c6d3f', 'sceneName': 'Heat Garage'}, {'sceneId': '13e61baf-d54c-40b3-8693-8e3a89501b52', 'sceneName': 'Alarm Start'}, {'sceneId': '3f17d748-c78b-4d83-84d1-1a456b016f1e', 'sceneName': 'Alarm Stop'}, {'sceneId': 'ac8d7721-62d9-41ee-8c12-f0500243abad', 'sceneName': 'Night Light'}, {'sceneId': '44c0cf31-4d02-4b05-a1d8-c4ca3543fe95', 'sceneName': 'Lights Off'}, {'sceneId': '2a33292e-d067-4d42-8df5-a4d27f8ef449', 'sceneName': 'Toggle Bedroom Light'}], 'message': 'success'}
Sending scene request at ID: ac8d7721-62d9-41ee-8c12-f0500243abad
Scenes response: {'statusCode': 100, 'body': {}, 'message': 'success'}
This code has been working fine for the past two years, so I don't think it's an issue on my end.
I'm encountering the same problem. It started occurring about 1 or 2 weeks ago. Initially it happened sporadically, but now it consistently returns an empty list for me.
{"statusCode": 100, "body": [], "message": "success"}
Not sure if it’s related, but /v1.1/scenes/{sceneId}/execute has also stopped working.
Same here.
"v1.1/scenes" consistently returns an empty list.
{"statusCode":100,"body":[],"message":"success"}
/v1.1/scenes/{sceneId}/execute does not work for me as well.
These conditions started on Oct. 28th.
I recreated scenes on my app, but the returned list was still empty. Execute scenes on my app does work, but scenes API doesn't work at all.
I reset my API token, but it didn't work.
I used my friend's account token to try if my code is wrong and I could retrieve scenes list. So something is wrong with server side or my account, not the code.
me too..
I ran into the same issue. Luckily, I could control the device directly, so I just made a quick workaround in my code to mimic the scene.
I’m in a similar situation. Instead of an empty list, I’m getting a list of old scenes.
I have the same issue. Only scenes with IDs starting with “T02-” that were previously deleted are retrieved.
I can reproduce the same issue.
- GET /v1.1/devices works correctly
- GET /v1.1/scenes always returns an empty list
- One-tap scenes (no conditions) are created in the app
- Token and signature are valid
It seems the Scene API does not reliably return Cloud Scenes.