|
switchbot_ros package from jsk_3rdparty repovoicevox zdepth chaplus_ros emotion_analyzer gdrive_ros google_chat_ros influxdb_store jsk_power_switching_tools nfc_ros respeaker_ros ros_speech_recognition rospatlite rosping sesame_ros switchbot_ros zdepth_image_transport |
ROS Distro
|
Package Summary
| Version | 3.0.2 |
| License | BSD-3-Clause |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Description | |
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_3rdparty.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-26 |
| Dev Status | DEVELOPED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
- Yoshiki Obinata
Authors
- Yoshiki Obinata
switchbot_ros
Controls SwitchBot devices from ROS through the
SwitchBot API. switchbot_ros_server.py publishes the list of
your devices and provides an action to send commands to them (press a Bot, turn on a light, an infrared remote, …);
switchbot_status_publisher.py publishes the status of one device (a meter, a plug, a bot, …) periodically.
Client libraries for rospy/rclpy and roseus are included.
System Component

JSK members can edit the original file here.
Requirements
- Install the SwitchBot app on your phone (iPhone, Android) and create your SwitchBot account.
-
Set up the SwitchBot devices with the app. Give each device a name (the
device_nameof the action) and enable the cloud service. Devices which talk Bluetooth only (e.g. a Bot) need a SwitchBot Hub to be controlled from the cloud. - Get your token and secret: in the app, open Profile > Preferences (Settings), tap the app version 10 times; the developer options show the token and the secret key. With a secret, the nodes use the SwitchBot API v1.1; without it (empty), the API v1.0. The token and the secret can be given as they are or as the path of a file of them.
For JSK members, please see this slide for the account, the token and the SwitchBots installed in our lab.
The nodes need the internet; the Python package requests (python3-requests) is used.
Usage
ROS 2
colcon build --packages-up-to switchbot_ros
source install/setup.bash
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET
# with the status publisher of one device
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET \
pub_status:=true pub_device_name:=YOUR_DEVICE_NAME
See the devices and send a command:
ros2 topic echo --once /switchbot_ros/devices
ros2 action send_goal --feedback /switchbot_ros/switch switchbot_ros/action/SwitchBotCommand \
"{device_name: '/myroom/light', command: 'turnOn'}"
ros2 topic echo /switchbot_status_publisher/YOUR_DEVICE_NAME
Without the launch file:
ros2 run switchbot_ros switchbot_ros_server.py --ros-args -r __node:=switchbot_ros \
-p token:=YOUR_TOKEN -p secret:=YOUR_SECRET
ROS 1
roslaunch switchbot_ros switchbot.launch token:=YOUR_TOKEN secret:=YOUR_SECRET
rostopic echo -n 1 /switchbot_ros/devices
rostopic pub -1 /switchbot_ros/switch/goal switchbot_ros/SwitchBotCommandActionGoal \
"{goal: {device_name: '/myroom/light', command: 'turnOn', parameter: '', command_type: ''}}"
rostopic echo /switchbot_ros/switch/result
Launch arguments
switchbot.launch (ROS 1) and switchbot.launch.xml (ROS 2) have the same arguments:
| Argument | Default | Meaning |
|---|---|---|
token |
(required) | the token, or the path of a file of it |
secret |
'' |
the secret key, or the path of a file of it; empty uses the API v1.0 |
respawn |
true |
respawn the nodes |
pub_status |
false |
also start switchbot_status_publisher
|
pub_status_rate |
0.1 |
the rate [Hz] of the status publisher |
pub_device_name |
bot74a |
the device of the status publisher |
Interface
switchbot_ros_server.py
The node is named switchbot_ros by the launch files (switchbot when run without them).
Published topics:
-
~devices(switchbot_ros/DeviceArray, latched): thenameandtypeof your devices and infrared remotes, published once the API client is ready.
Actions:
File truncated at 100 lines see the full file
Changelog for package switchbot_ros
3.0.2 (2026-11-26)
- Merge pull request #594 from k-okada/fix-error-handling
- switchbot_ros: exit cleanly when status publisher is misconfigured SwitchBotStatusPublisher.__init_() logs an error and returns early when ~device_name is empty, unknown, or of a device type without a status message, but __main_ still calls spin(), which then crashed with AttributeError (no device_type / msg_class) or KeyError from device_status(), hiding the real error message under a traceback. Mark the publisher ready only at the end of __init_ and make spin() return immediately otherwise, so the node logs the configuration error and exits. A correctly configured publisher runs exactly as before (the Remote case already returned from spin()). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: check HTTP status before parsing the response JSON SwitchBotAPIClient.request() called response.json() before response.raise_for_status(). When the API answers 4XX/5XX with a non-JSON body (an HTML error page, a plain "Too Many Requests"), a JSONDecodeError was raised and the dedicated InvalidRequestError (422) / ExceededRequestError (429) / HTTPError handling was never reached. Parse the body only after the status check succeeded; response_json is used only in that branch. Successful responses and 4XX/5XX responses with a JSON body behave exactly as before (checked with mocked requests: 200, statusCode 152, 401 JSON are unchanged; 422/429/500 with a non-JSON body now raise InvalidRequestError/ExceededRequestError/ HTTPError instead of JSONDecodeError). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: abort the action goal when the command fails execute_cb() always called set_succeeded() from its finally block, so a failed command (unknown device, offline device, API error, ...) was reported to action clients as SUCCEEDED with result.done == False. Errors not in the except list (HTTP errors / no connection from requests, ValueError for an unknown statusCode or a non-JSON reply) were even reported as SUCCEEDED with done == True before the exception escaped the callback. Catch those too, and call set_aborted() when the command failed. The feedback, the logged error and result.done are the same as before, and successful commands are still SUCCEEDED, so clients that only read result.done (SwitchBotROSClient.control_device()) see no change; only the goal state now tells the truth on failure. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #595 from k-okada/readme-update Update the READMEs for ROS 1 / ROS 2, with badges and demos
- switchbot_ros: update README.md for ROS 1 / ROS 2 Describe how to run it on ROS 2 and ROS 1, its interface (topics, services, actions, parameters) as in the source, and its requirements. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #584 from k-okada/release-3.0.1
- Contributors: Kei Okada
3.0.1 (2026-11-10)
- Merge pull request #583 from k-okada/rosdistro-55247-review rosdistro#55247 review: rename power_switching_tools_ros to jsk_power_switching_tools, fix licenses
- use SPDX license identifiers (BSD-3-Clause, Apache-2.0) in package.xml BSD -> BSD-3-Clause and Apache / "Apache License, Version 2.0" -> Apache-2.0 in all packages (ros/rosdistro#55247 review). The LICENSE files of all of them are BSD 3-Clause and Apache 2.0 respectively. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
- Contributors: Kei Okada
3.0.0 (2026-11-06)
-
Merge pull request #581 from k-okada/ros2-buildfarm-ros-environment Fix ROS2 buildfarm binary jobs: ros_environment, bundled flac, numpy wheel
-
[voicevox, chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros, ros_speech_recognition, rospatlite, sesame_ros, switchbot_ros] depend on ros_environment for ROS2 buildfarm The buildfarm builds each package with only its own build dependencies, so without ros_environment $ROS_VERSION is empty and CMakeLists.txt takes the ROS1 branch (same as jsk_common#1835). voicevox also guesses ROS_VERSION from AMENT_PREFIX_PATH when it is unset. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge branch 'master' into fix_hoya
-
Merge branch 'master' into voicevox-ros1-ros2
-
AMENT_IGNORE: do not add AMENT_IGNORE to packages already ported to ROS2 chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros,
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
Dependant Packages
Launch files
- launch/switchbot.launch
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
- launch/switchbot.launch.xml
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
Messages
Services
Plugins
Recent questions tagged switchbot_ros at Robotics Stack Exchange
|
switchbot_ros package from jsk_3rdparty repovoicevox zdepth chaplus_ros emotion_analyzer gdrive_ros google_chat_ros influxdb_store jsk_power_switching_tools nfc_ros respeaker_ros ros_speech_recognition rospatlite rosping sesame_ros switchbot_ros zdepth_image_transport |
ROS Distro
|
Package Summary
| Version | 3.0.2 |
| License | BSD-3-Clause |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Description | |
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_3rdparty.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-26 |
| Dev Status | DEVELOPED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
- Yoshiki Obinata
Authors
- Yoshiki Obinata
switchbot_ros
Controls SwitchBot devices from ROS through the
SwitchBot API. switchbot_ros_server.py publishes the list of
your devices and provides an action to send commands to them (press a Bot, turn on a light, an infrared remote, …);
switchbot_status_publisher.py publishes the status of one device (a meter, a plug, a bot, …) periodically.
Client libraries for rospy/rclpy and roseus are included.
System Component

JSK members can edit the original file here.
Requirements
- Install the SwitchBot app on your phone (iPhone, Android) and create your SwitchBot account.
-
Set up the SwitchBot devices with the app. Give each device a name (the
device_nameof the action) and enable the cloud service. Devices which talk Bluetooth only (e.g. a Bot) need a SwitchBot Hub to be controlled from the cloud. - Get your token and secret: in the app, open Profile > Preferences (Settings), tap the app version 10 times; the developer options show the token and the secret key. With a secret, the nodes use the SwitchBot API v1.1; without it (empty), the API v1.0. The token and the secret can be given as they are or as the path of a file of them.
For JSK members, please see this slide for the account, the token and the SwitchBots installed in our lab.
The nodes need the internet; the Python package requests (python3-requests) is used.
Usage
ROS 2
colcon build --packages-up-to switchbot_ros
source install/setup.bash
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET
# with the status publisher of one device
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET \
pub_status:=true pub_device_name:=YOUR_DEVICE_NAME
See the devices and send a command:
ros2 topic echo --once /switchbot_ros/devices
ros2 action send_goal --feedback /switchbot_ros/switch switchbot_ros/action/SwitchBotCommand \
"{device_name: '/myroom/light', command: 'turnOn'}"
ros2 topic echo /switchbot_status_publisher/YOUR_DEVICE_NAME
Without the launch file:
ros2 run switchbot_ros switchbot_ros_server.py --ros-args -r __node:=switchbot_ros \
-p token:=YOUR_TOKEN -p secret:=YOUR_SECRET
ROS 1
roslaunch switchbot_ros switchbot.launch token:=YOUR_TOKEN secret:=YOUR_SECRET
rostopic echo -n 1 /switchbot_ros/devices
rostopic pub -1 /switchbot_ros/switch/goal switchbot_ros/SwitchBotCommandActionGoal \
"{goal: {device_name: '/myroom/light', command: 'turnOn', parameter: '', command_type: ''}}"
rostopic echo /switchbot_ros/switch/result
Launch arguments
switchbot.launch (ROS 1) and switchbot.launch.xml (ROS 2) have the same arguments:
| Argument | Default | Meaning |
|---|---|---|
token |
(required) | the token, or the path of a file of it |
secret |
'' |
the secret key, or the path of a file of it; empty uses the API v1.0 |
respawn |
true |
respawn the nodes |
pub_status |
false |
also start switchbot_status_publisher
|
pub_status_rate |
0.1 |
the rate [Hz] of the status publisher |
pub_device_name |
bot74a |
the device of the status publisher |
Interface
switchbot_ros_server.py
The node is named switchbot_ros by the launch files (switchbot when run without them).
Published topics:
-
~devices(switchbot_ros/DeviceArray, latched): thenameandtypeof your devices and infrared remotes, published once the API client is ready.
Actions:
File truncated at 100 lines see the full file
Changelog for package switchbot_ros
3.0.2 (2026-11-26)
- Merge pull request #594 from k-okada/fix-error-handling
- switchbot_ros: exit cleanly when status publisher is misconfigured SwitchBotStatusPublisher.__init_() logs an error and returns early when ~device_name is empty, unknown, or of a device type without a status message, but __main_ still calls spin(), which then crashed with AttributeError (no device_type / msg_class) or KeyError from device_status(), hiding the real error message under a traceback. Mark the publisher ready only at the end of __init_ and make spin() return immediately otherwise, so the node logs the configuration error and exits. A correctly configured publisher runs exactly as before (the Remote case already returned from spin()). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: check HTTP status before parsing the response JSON SwitchBotAPIClient.request() called response.json() before response.raise_for_status(). When the API answers 4XX/5XX with a non-JSON body (an HTML error page, a plain "Too Many Requests"), a JSONDecodeError was raised and the dedicated InvalidRequestError (422) / ExceededRequestError (429) / HTTPError handling was never reached. Parse the body only after the status check succeeded; response_json is used only in that branch. Successful responses and 4XX/5XX responses with a JSON body behave exactly as before (checked with mocked requests: 200, statusCode 152, 401 JSON are unchanged; 422/429/500 with a non-JSON body now raise InvalidRequestError/ExceededRequestError/ HTTPError instead of JSONDecodeError). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: abort the action goal when the command fails execute_cb() always called set_succeeded() from its finally block, so a failed command (unknown device, offline device, API error, ...) was reported to action clients as SUCCEEDED with result.done == False. Errors not in the except list (HTTP errors / no connection from requests, ValueError for an unknown statusCode or a non-JSON reply) were even reported as SUCCEEDED with done == True before the exception escaped the callback. Catch those too, and call set_aborted() when the command failed. The feedback, the logged error and result.done are the same as before, and successful commands are still SUCCEEDED, so clients that only read result.done (SwitchBotROSClient.control_device()) see no change; only the goal state now tells the truth on failure. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #595 from k-okada/readme-update Update the READMEs for ROS 1 / ROS 2, with badges and demos
- switchbot_ros: update README.md for ROS 1 / ROS 2 Describe how to run it on ROS 2 and ROS 1, its interface (topics, services, actions, parameters) as in the source, and its requirements. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #584 from k-okada/release-3.0.1
- Contributors: Kei Okada
3.0.1 (2026-11-10)
- Merge pull request #583 from k-okada/rosdistro-55247-review rosdistro#55247 review: rename power_switching_tools_ros to jsk_power_switching_tools, fix licenses
- use SPDX license identifiers (BSD-3-Clause, Apache-2.0) in package.xml BSD -> BSD-3-Clause and Apache / "Apache License, Version 2.0" -> Apache-2.0 in all packages (ros/rosdistro#55247 review). The LICENSE files of all of them are BSD 3-Clause and Apache 2.0 respectively. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
- Contributors: Kei Okada
3.0.0 (2026-11-06)
-
Merge pull request #581 from k-okada/ros2-buildfarm-ros-environment Fix ROS2 buildfarm binary jobs: ros_environment, bundled flac, numpy wheel
-
[voicevox, chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros, ros_speech_recognition, rospatlite, sesame_ros, switchbot_ros] depend on ros_environment for ROS2 buildfarm The buildfarm builds each package with only its own build dependencies, so without ros_environment $ROS_VERSION is empty and CMakeLists.txt takes the ROS1 branch (same as jsk_common#1835). voicevox also guesses ROS_VERSION from AMENT_PREFIX_PATH when it is unset. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge branch 'master' into fix_hoya
-
Merge branch 'master' into voicevox-ros1-ros2
-
AMENT_IGNORE: do not add AMENT_IGNORE to packages already ported to ROS2 chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros,
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
Dependant Packages
Launch files
- launch/switchbot.launch
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
- launch/switchbot.launch.xml
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
Messages
Services
Plugins
Recent questions tagged switchbot_ros at Robotics Stack Exchange
|
switchbot_ros package from jsk_3rdparty repovoicevox zdepth chaplus_ros emotion_analyzer gdrive_ros google_chat_ros influxdb_store jsk_power_switching_tools nfc_ros respeaker_ros ros_speech_recognition rospatlite rosping sesame_ros switchbot_ros zdepth_image_transport |
ROS Distro
|
Package Summary
| Version | 3.0.2 |
| License | BSD-3-Clause |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Description | |
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_3rdparty.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-26 |
| Dev Status | DEVELOPED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
- Yoshiki Obinata
Authors
- Yoshiki Obinata
switchbot_ros
Controls SwitchBot devices from ROS through the
SwitchBot API. switchbot_ros_server.py publishes the list of
your devices and provides an action to send commands to them (press a Bot, turn on a light, an infrared remote, …);
switchbot_status_publisher.py publishes the status of one device (a meter, a plug, a bot, …) periodically.
Client libraries for rospy/rclpy and roseus are included.
System Component

JSK members can edit the original file here.
Requirements
- Install the SwitchBot app on your phone (iPhone, Android) and create your SwitchBot account.
-
Set up the SwitchBot devices with the app. Give each device a name (the
device_nameof the action) and enable the cloud service. Devices which talk Bluetooth only (e.g. a Bot) need a SwitchBot Hub to be controlled from the cloud. - Get your token and secret: in the app, open Profile > Preferences (Settings), tap the app version 10 times; the developer options show the token and the secret key. With a secret, the nodes use the SwitchBot API v1.1; without it (empty), the API v1.0. The token and the secret can be given as they are or as the path of a file of them.
For JSK members, please see this slide for the account, the token and the SwitchBots installed in our lab.
The nodes need the internet; the Python package requests (python3-requests) is used.
Usage
ROS 2
colcon build --packages-up-to switchbot_ros
source install/setup.bash
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET
# with the status publisher of one device
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET \
pub_status:=true pub_device_name:=YOUR_DEVICE_NAME
See the devices and send a command:
ros2 topic echo --once /switchbot_ros/devices
ros2 action send_goal --feedback /switchbot_ros/switch switchbot_ros/action/SwitchBotCommand \
"{device_name: '/myroom/light', command: 'turnOn'}"
ros2 topic echo /switchbot_status_publisher/YOUR_DEVICE_NAME
Without the launch file:
ros2 run switchbot_ros switchbot_ros_server.py --ros-args -r __node:=switchbot_ros \
-p token:=YOUR_TOKEN -p secret:=YOUR_SECRET
ROS 1
roslaunch switchbot_ros switchbot.launch token:=YOUR_TOKEN secret:=YOUR_SECRET
rostopic echo -n 1 /switchbot_ros/devices
rostopic pub -1 /switchbot_ros/switch/goal switchbot_ros/SwitchBotCommandActionGoal \
"{goal: {device_name: '/myroom/light', command: 'turnOn', parameter: '', command_type: ''}}"
rostopic echo /switchbot_ros/switch/result
Launch arguments
switchbot.launch (ROS 1) and switchbot.launch.xml (ROS 2) have the same arguments:
| Argument | Default | Meaning |
|---|---|---|
token |
(required) | the token, or the path of a file of it |
secret |
'' |
the secret key, or the path of a file of it; empty uses the API v1.0 |
respawn |
true |
respawn the nodes |
pub_status |
false |
also start switchbot_status_publisher
|
pub_status_rate |
0.1 |
the rate [Hz] of the status publisher |
pub_device_name |
bot74a |
the device of the status publisher |
Interface
switchbot_ros_server.py
The node is named switchbot_ros by the launch files (switchbot when run without them).
Published topics:
-
~devices(switchbot_ros/DeviceArray, latched): thenameandtypeof your devices and infrared remotes, published once the API client is ready.
Actions:
File truncated at 100 lines see the full file
Changelog for package switchbot_ros
3.0.2 (2026-11-26)
- Merge pull request #594 from k-okada/fix-error-handling
- switchbot_ros: exit cleanly when status publisher is misconfigured SwitchBotStatusPublisher.__init_() logs an error and returns early when ~device_name is empty, unknown, or of a device type without a status message, but __main_ still calls spin(), which then crashed with AttributeError (no device_type / msg_class) or KeyError from device_status(), hiding the real error message under a traceback. Mark the publisher ready only at the end of __init_ and make spin() return immediately otherwise, so the node logs the configuration error and exits. A correctly configured publisher runs exactly as before (the Remote case already returned from spin()). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: check HTTP status before parsing the response JSON SwitchBotAPIClient.request() called response.json() before response.raise_for_status(). When the API answers 4XX/5XX with a non-JSON body (an HTML error page, a plain "Too Many Requests"), a JSONDecodeError was raised and the dedicated InvalidRequestError (422) / ExceededRequestError (429) / HTTPError handling was never reached. Parse the body only after the status check succeeded; response_json is used only in that branch. Successful responses and 4XX/5XX responses with a JSON body behave exactly as before (checked with mocked requests: 200, statusCode 152, 401 JSON are unchanged; 422/429/500 with a non-JSON body now raise InvalidRequestError/ExceededRequestError/ HTTPError instead of JSONDecodeError). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: abort the action goal when the command fails execute_cb() always called set_succeeded() from its finally block, so a failed command (unknown device, offline device, API error, ...) was reported to action clients as SUCCEEDED with result.done == False. Errors not in the except list (HTTP errors / no connection from requests, ValueError for an unknown statusCode or a non-JSON reply) were even reported as SUCCEEDED with done == True before the exception escaped the callback. Catch those too, and call set_aborted() when the command failed. The feedback, the logged error and result.done are the same as before, and successful commands are still SUCCEEDED, so clients that only read result.done (SwitchBotROSClient.control_device()) see no change; only the goal state now tells the truth on failure. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #595 from k-okada/readme-update Update the READMEs for ROS 1 / ROS 2, with badges and demos
- switchbot_ros: update README.md for ROS 1 / ROS 2 Describe how to run it on ROS 2 and ROS 1, its interface (topics, services, actions, parameters) as in the source, and its requirements. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #584 from k-okada/release-3.0.1
- Contributors: Kei Okada
3.0.1 (2026-11-10)
- Merge pull request #583 from k-okada/rosdistro-55247-review rosdistro#55247 review: rename power_switching_tools_ros to jsk_power_switching_tools, fix licenses
- use SPDX license identifiers (BSD-3-Clause, Apache-2.0) in package.xml BSD -> BSD-3-Clause and Apache / "Apache License, Version 2.0" -> Apache-2.0 in all packages (ros/rosdistro#55247 review). The LICENSE files of all of them are BSD 3-Clause and Apache 2.0 respectively. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
- Contributors: Kei Okada
3.0.0 (2026-11-06)
-
Merge pull request #581 from k-okada/ros2-buildfarm-ros-environment Fix ROS2 buildfarm binary jobs: ros_environment, bundled flac, numpy wheel
-
[voicevox, chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros, ros_speech_recognition, rospatlite, sesame_ros, switchbot_ros] depend on ros_environment for ROS2 buildfarm The buildfarm builds each package with only its own build dependencies, so without ros_environment $ROS_VERSION is empty and CMakeLists.txt takes the ROS1 branch (same as jsk_common#1835). voicevox also guesses ROS_VERSION from AMENT_PREFIX_PATH when it is unset. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge branch 'master' into fix_hoya
-
Merge branch 'master' into voicevox-ros1-ros2
-
AMENT_IGNORE: do not add AMENT_IGNORE to packages already ported to ROS2 chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros,
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
Dependant Packages
Launch files
- launch/switchbot.launch
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
- launch/switchbot.launch.xml
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
Messages
Services
Plugins
Recent questions tagged switchbot_ros at Robotics Stack Exchange
|
switchbot_ros package from jsk_3rdparty repovoicevox zdepth chaplus_ros emotion_analyzer gdrive_ros google_chat_ros influxdb_store jsk_power_switching_tools nfc_ros respeaker_ros ros_speech_recognition rospatlite rosping sesame_ros switchbot_ros zdepth_image_transport |
ROS Distro
|
Package Summary
| Version | 3.0.2 |
| License | BSD-3-Clause |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Description | |
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_3rdparty.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-26 |
| Dev Status | DEVELOPED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
- Yoshiki Obinata
Authors
- Yoshiki Obinata
switchbot_ros
Controls SwitchBot devices from ROS through the
SwitchBot API. switchbot_ros_server.py publishes the list of
your devices and provides an action to send commands to them (press a Bot, turn on a light, an infrared remote, …);
switchbot_status_publisher.py publishes the status of one device (a meter, a plug, a bot, …) periodically.
Client libraries for rospy/rclpy and roseus are included.
System Component

JSK members can edit the original file here.
Requirements
- Install the SwitchBot app on your phone (iPhone, Android) and create your SwitchBot account.
-
Set up the SwitchBot devices with the app. Give each device a name (the
device_nameof the action) and enable the cloud service. Devices which talk Bluetooth only (e.g. a Bot) need a SwitchBot Hub to be controlled from the cloud. - Get your token and secret: in the app, open Profile > Preferences (Settings), tap the app version 10 times; the developer options show the token and the secret key. With a secret, the nodes use the SwitchBot API v1.1; without it (empty), the API v1.0. The token and the secret can be given as they are or as the path of a file of them.
For JSK members, please see this slide for the account, the token and the SwitchBots installed in our lab.
The nodes need the internet; the Python package requests (python3-requests) is used.
Usage
ROS 2
colcon build --packages-up-to switchbot_ros
source install/setup.bash
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET
# with the status publisher of one device
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET \
pub_status:=true pub_device_name:=YOUR_DEVICE_NAME
See the devices and send a command:
ros2 topic echo --once /switchbot_ros/devices
ros2 action send_goal --feedback /switchbot_ros/switch switchbot_ros/action/SwitchBotCommand \
"{device_name: '/myroom/light', command: 'turnOn'}"
ros2 topic echo /switchbot_status_publisher/YOUR_DEVICE_NAME
Without the launch file:
ros2 run switchbot_ros switchbot_ros_server.py --ros-args -r __node:=switchbot_ros \
-p token:=YOUR_TOKEN -p secret:=YOUR_SECRET
ROS 1
roslaunch switchbot_ros switchbot.launch token:=YOUR_TOKEN secret:=YOUR_SECRET
rostopic echo -n 1 /switchbot_ros/devices
rostopic pub -1 /switchbot_ros/switch/goal switchbot_ros/SwitchBotCommandActionGoal \
"{goal: {device_name: '/myroom/light', command: 'turnOn', parameter: '', command_type: ''}}"
rostopic echo /switchbot_ros/switch/result
Launch arguments
switchbot.launch (ROS 1) and switchbot.launch.xml (ROS 2) have the same arguments:
| Argument | Default | Meaning |
|---|---|---|
token |
(required) | the token, or the path of a file of it |
secret |
'' |
the secret key, or the path of a file of it; empty uses the API v1.0 |
respawn |
true |
respawn the nodes |
pub_status |
false |
also start switchbot_status_publisher
|
pub_status_rate |
0.1 |
the rate [Hz] of the status publisher |
pub_device_name |
bot74a |
the device of the status publisher |
Interface
switchbot_ros_server.py
The node is named switchbot_ros by the launch files (switchbot when run without them).
Published topics:
-
~devices(switchbot_ros/DeviceArray, latched): thenameandtypeof your devices and infrared remotes, published once the API client is ready.
Actions:
File truncated at 100 lines see the full file
Changelog for package switchbot_ros
3.0.2 (2026-11-26)
- Merge pull request #594 from k-okada/fix-error-handling
- switchbot_ros: exit cleanly when status publisher is misconfigured SwitchBotStatusPublisher.__init_() logs an error and returns early when ~device_name is empty, unknown, or of a device type without a status message, but __main_ still calls spin(), which then crashed with AttributeError (no device_type / msg_class) or KeyError from device_status(), hiding the real error message under a traceback. Mark the publisher ready only at the end of __init_ and make spin() return immediately otherwise, so the node logs the configuration error and exits. A correctly configured publisher runs exactly as before (the Remote case already returned from spin()). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: check HTTP status before parsing the response JSON SwitchBotAPIClient.request() called response.json() before response.raise_for_status(). When the API answers 4XX/5XX with a non-JSON body (an HTML error page, a plain "Too Many Requests"), a JSONDecodeError was raised and the dedicated InvalidRequestError (422) / ExceededRequestError (429) / HTTPError handling was never reached. Parse the body only after the status check succeeded; response_json is used only in that branch. Successful responses and 4XX/5XX responses with a JSON body behave exactly as before (checked with mocked requests: 200, statusCode 152, 401 JSON are unchanged; 422/429/500 with a non-JSON body now raise InvalidRequestError/ExceededRequestError/ HTTPError instead of JSONDecodeError). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: abort the action goal when the command fails execute_cb() always called set_succeeded() from its finally block, so a failed command (unknown device, offline device, API error, ...) was reported to action clients as SUCCEEDED with result.done == False. Errors not in the except list (HTTP errors / no connection from requests, ValueError for an unknown statusCode or a non-JSON reply) were even reported as SUCCEEDED with done == True before the exception escaped the callback. Catch those too, and call set_aborted() when the command failed. The feedback, the logged error and result.done are the same as before, and successful commands are still SUCCEEDED, so clients that only read result.done (SwitchBotROSClient.control_device()) see no change; only the goal state now tells the truth on failure. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #595 from k-okada/readme-update Update the READMEs for ROS 1 / ROS 2, with badges and demos
- switchbot_ros: update README.md for ROS 1 / ROS 2 Describe how to run it on ROS 2 and ROS 1, its interface (topics, services, actions, parameters) as in the source, and its requirements. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #584 from k-okada/release-3.0.1
- Contributors: Kei Okada
3.0.1 (2026-11-10)
- Merge pull request #583 from k-okada/rosdistro-55247-review rosdistro#55247 review: rename power_switching_tools_ros to jsk_power_switching_tools, fix licenses
- use SPDX license identifiers (BSD-3-Clause, Apache-2.0) in package.xml BSD -> BSD-3-Clause and Apache / "Apache License, Version 2.0" -> Apache-2.0 in all packages (ros/rosdistro#55247 review). The LICENSE files of all of them are BSD 3-Clause and Apache 2.0 respectively. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
- Contributors: Kei Okada
3.0.0 (2026-11-06)
-
Merge pull request #581 from k-okada/ros2-buildfarm-ros-environment Fix ROS2 buildfarm binary jobs: ros_environment, bundled flac, numpy wheel
-
[voicevox, chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros, ros_speech_recognition, rospatlite, sesame_ros, switchbot_ros] depend on ros_environment for ROS2 buildfarm The buildfarm builds each package with only its own build dependencies, so without ros_environment $ROS_VERSION is empty and CMakeLists.txt takes the ROS1 branch (same as jsk_common#1835). voicevox also guesses ROS_VERSION from AMENT_PREFIX_PATH when it is unset. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge branch 'master' into fix_hoya
-
Merge branch 'master' into voicevox-ros1-ros2
-
AMENT_IGNORE: do not add AMENT_IGNORE to packages already ported to ROS2 chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros,
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
Dependant Packages
Launch files
- launch/switchbot.launch
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
- launch/switchbot.launch.xml
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
Messages
Services
Plugins
Recent questions tagged switchbot_ros at Robotics Stack Exchange
|
switchbot_ros package from jsk_3rdparty repovoicevox zdepth chaplus_ros emotion_analyzer gdrive_ros google_chat_ros influxdb_store jsk_power_switching_tools nfc_ros respeaker_ros ros_speech_recognition rospatlite rosping sesame_ros switchbot_ros zdepth_image_transport |
ROS Distro
|
Package Summary
| Version | 3.0.2 |
| License | BSD-3-Clause |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Description | |
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_3rdparty.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-26 |
| Dev Status | DEVELOPED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
- Yoshiki Obinata
Authors
- Yoshiki Obinata
switchbot_ros
Controls SwitchBot devices from ROS through the
SwitchBot API. switchbot_ros_server.py publishes the list of
your devices and provides an action to send commands to them (press a Bot, turn on a light, an infrared remote, …);
switchbot_status_publisher.py publishes the status of one device (a meter, a plug, a bot, …) periodically.
Client libraries for rospy/rclpy and roseus are included.
System Component

JSK members can edit the original file here.
Requirements
- Install the SwitchBot app on your phone (iPhone, Android) and create your SwitchBot account.
-
Set up the SwitchBot devices with the app. Give each device a name (the
device_nameof the action) and enable the cloud service. Devices which talk Bluetooth only (e.g. a Bot) need a SwitchBot Hub to be controlled from the cloud. - Get your token and secret: in the app, open Profile > Preferences (Settings), tap the app version 10 times; the developer options show the token and the secret key. With a secret, the nodes use the SwitchBot API v1.1; without it (empty), the API v1.0. The token and the secret can be given as they are or as the path of a file of them.
For JSK members, please see this slide for the account, the token and the SwitchBots installed in our lab.
The nodes need the internet; the Python package requests (python3-requests) is used.
Usage
ROS 2
colcon build --packages-up-to switchbot_ros
source install/setup.bash
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET
# with the status publisher of one device
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET \
pub_status:=true pub_device_name:=YOUR_DEVICE_NAME
See the devices and send a command:
ros2 topic echo --once /switchbot_ros/devices
ros2 action send_goal --feedback /switchbot_ros/switch switchbot_ros/action/SwitchBotCommand \
"{device_name: '/myroom/light', command: 'turnOn'}"
ros2 topic echo /switchbot_status_publisher/YOUR_DEVICE_NAME
Without the launch file:
ros2 run switchbot_ros switchbot_ros_server.py --ros-args -r __node:=switchbot_ros \
-p token:=YOUR_TOKEN -p secret:=YOUR_SECRET
ROS 1
roslaunch switchbot_ros switchbot.launch token:=YOUR_TOKEN secret:=YOUR_SECRET
rostopic echo -n 1 /switchbot_ros/devices
rostopic pub -1 /switchbot_ros/switch/goal switchbot_ros/SwitchBotCommandActionGoal \
"{goal: {device_name: '/myroom/light', command: 'turnOn', parameter: '', command_type: ''}}"
rostopic echo /switchbot_ros/switch/result
Launch arguments
switchbot.launch (ROS 1) and switchbot.launch.xml (ROS 2) have the same arguments:
| Argument | Default | Meaning |
|---|---|---|
token |
(required) | the token, or the path of a file of it |
secret |
'' |
the secret key, or the path of a file of it; empty uses the API v1.0 |
respawn |
true |
respawn the nodes |
pub_status |
false |
also start switchbot_status_publisher
|
pub_status_rate |
0.1 |
the rate [Hz] of the status publisher |
pub_device_name |
bot74a |
the device of the status publisher |
Interface
switchbot_ros_server.py
The node is named switchbot_ros by the launch files (switchbot when run without them).
Published topics:
-
~devices(switchbot_ros/DeviceArray, latched): thenameandtypeof your devices and infrared remotes, published once the API client is ready.
Actions:
File truncated at 100 lines see the full file
Changelog for package switchbot_ros
3.0.2 (2026-11-26)
- Merge pull request #594 from k-okada/fix-error-handling
- switchbot_ros: exit cleanly when status publisher is misconfigured SwitchBotStatusPublisher.__init_() logs an error and returns early when ~device_name is empty, unknown, or of a device type without a status message, but __main_ still calls spin(), which then crashed with AttributeError (no device_type / msg_class) or KeyError from device_status(), hiding the real error message under a traceback. Mark the publisher ready only at the end of __init_ and make spin() return immediately otherwise, so the node logs the configuration error and exits. A correctly configured publisher runs exactly as before (the Remote case already returned from spin()). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: check HTTP status before parsing the response JSON SwitchBotAPIClient.request() called response.json() before response.raise_for_status(). When the API answers 4XX/5XX with a non-JSON body (an HTML error page, a plain "Too Many Requests"), a JSONDecodeError was raised and the dedicated InvalidRequestError (422) / ExceededRequestError (429) / HTTPError handling was never reached. Parse the body only after the status check succeeded; response_json is used only in that branch. Successful responses and 4XX/5XX responses with a JSON body behave exactly as before (checked with mocked requests: 200, statusCode 152, 401 JSON are unchanged; 422/429/500 with a non-JSON body now raise InvalidRequestError/ExceededRequestError/ HTTPError instead of JSONDecodeError). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: abort the action goal when the command fails execute_cb() always called set_succeeded() from its finally block, so a failed command (unknown device, offline device, API error, ...) was reported to action clients as SUCCEEDED with result.done == False. Errors not in the except list (HTTP errors / no connection from requests, ValueError for an unknown statusCode or a non-JSON reply) were even reported as SUCCEEDED with done == True before the exception escaped the callback. Catch those too, and call set_aborted() when the command failed. The feedback, the logged error and result.done are the same as before, and successful commands are still SUCCEEDED, so clients that only read result.done (SwitchBotROSClient.control_device()) see no change; only the goal state now tells the truth on failure. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #595 from k-okada/readme-update Update the READMEs for ROS 1 / ROS 2, with badges and demos
- switchbot_ros: update README.md for ROS 1 / ROS 2 Describe how to run it on ROS 2 and ROS 1, its interface (topics, services, actions, parameters) as in the source, and its requirements. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #584 from k-okada/release-3.0.1
- Contributors: Kei Okada
3.0.1 (2026-11-10)
- Merge pull request #583 from k-okada/rosdistro-55247-review rosdistro#55247 review: rename power_switching_tools_ros to jsk_power_switching_tools, fix licenses
- use SPDX license identifiers (BSD-3-Clause, Apache-2.0) in package.xml BSD -> BSD-3-Clause and Apache / "Apache License, Version 2.0" -> Apache-2.0 in all packages (ros/rosdistro#55247 review). The LICENSE files of all of them are BSD 3-Clause and Apache 2.0 respectively. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
- Contributors: Kei Okada
3.0.0 (2026-11-06)
-
Merge pull request #581 from k-okada/ros2-buildfarm-ros-environment Fix ROS2 buildfarm binary jobs: ros_environment, bundled flac, numpy wheel
-
[voicevox, chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros, ros_speech_recognition, rospatlite, sesame_ros, switchbot_ros] depend on ros_environment for ROS2 buildfarm The buildfarm builds each package with only its own build dependencies, so without ros_environment $ROS_VERSION is empty and CMakeLists.txt takes the ROS1 branch (same as jsk_common#1835). voicevox also guesses ROS_VERSION from AMENT_PREFIX_PATH when it is unset. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge branch 'master' into fix_hoya
-
Merge branch 'master' into voicevox-ros1-ros2
-
AMENT_IGNORE: do not add AMENT_IGNORE to packages already ported to ROS2 chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros,
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
Dependant Packages
Launch files
- launch/switchbot.launch
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
- launch/switchbot.launch.xml
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
Messages
Services
Plugins
Recent questions tagged switchbot_ros at Robotics Stack Exchange
|
switchbot_ros package from jsk_3rdparty repovoicevox zdepth chaplus_ros emotion_analyzer gdrive_ros google_chat_ros influxdb_store jsk_power_switching_tools nfc_ros respeaker_ros ros_speech_recognition rospatlite rosping sesame_ros switchbot_ros zdepth_image_transport |
ROS Distro
|
Package Summary
| Version | 3.0.2 |
| License | BSD-3-Clause |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Description | |
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_3rdparty.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-26 |
| Dev Status | DEVELOPED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
- Yoshiki Obinata
Authors
- Yoshiki Obinata
switchbot_ros
Controls SwitchBot devices from ROS through the
SwitchBot API. switchbot_ros_server.py publishes the list of
your devices and provides an action to send commands to them (press a Bot, turn on a light, an infrared remote, …);
switchbot_status_publisher.py publishes the status of one device (a meter, a plug, a bot, …) periodically.
Client libraries for rospy/rclpy and roseus are included.
System Component

JSK members can edit the original file here.
Requirements
- Install the SwitchBot app on your phone (iPhone, Android) and create your SwitchBot account.
-
Set up the SwitchBot devices with the app. Give each device a name (the
device_nameof the action) and enable the cloud service. Devices which talk Bluetooth only (e.g. a Bot) need a SwitchBot Hub to be controlled from the cloud. - Get your token and secret: in the app, open Profile > Preferences (Settings), tap the app version 10 times; the developer options show the token and the secret key. With a secret, the nodes use the SwitchBot API v1.1; without it (empty), the API v1.0. The token and the secret can be given as they are or as the path of a file of them.
For JSK members, please see this slide for the account, the token and the SwitchBots installed in our lab.
The nodes need the internet; the Python package requests (python3-requests) is used.
Usage
ROS 2
colcon build --packages-up-to switchbot_ros
source install/setup.bash
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET
# with the status publisher of one device
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET \
pub_status:=true pub_device_name:=YOUR_DEVICE_NAME
See the devices and send a command:
ros2 topic echo --once /switchbot_ros/devices
ros2 action send_goal --feedback /switchbot_ros/switch switchbot_ros/action/SwitchBotCommand \
"{device_name: '/myroom/light', command: 'turnOn'}"
ros2 topic echo /switchbot_status_publisher/YOUR_DEVICE_NAME
Without the launch file:
ros2 run switchbot_ros switchbot_ros_server.py --ros-args -r __node:=switchbot_ros \
-p token:=YOUR_TOKEN -p secret:=YOUR_SECRET
ROS 1
roslaunch switchbot_ros switchbot.launch token:=YOUR_TOKEN secret:=YOUR_SECRET
rostopic echo -n 1 /switchbot_ros/devices
rostopic pub -1 /switchbot_ros/switch/goal switchbot_ros/SwitchBotCommandActionGoal \
"{goal: {device_name: '/myroom/light', command: 'turnOn', parameter: '', command_type: ''}}"
rostopic echo /switchbot_ros/switch/result
Launch arguments
switchbot.launch (ROS 1) and switchbot.launch.xml (ROS 2) have the same arguments:
| Argument | Default | Meaning |
|---|---|---|
token |
(required) | the token, or the path of a file of it |
secret |
'' |
the secret key, or the path of a file of it; empty uses the API v1.0 |
respawn |
true |
respawn the nodes |
pub_status |
false |
also start switchbot_status_publisher
|
pub_status_rate |
0.1 |
the rate [Hz] of the status publisher |
pub_device_name |
bot74a |
the device of the status publisher |
Interface
switchbot_ros_server.py
The node is named switchbot_ros by the launch files (switchbot when run without them).
Published topics:
-
~devices(switchbot_ros/DeviceArray, latched): thenameandtypeof your devices and infrared remotes, published once the API client is ready.
Actions:
File truncated at 100 lines see the full file
Changelog for package switchbot_ros
3.0.2 (2026-11-26)
- Merge pull request #594 from k-okada/fix-error-handling
- switchbot_ros: exit cleanly when status publisher is misconfigured SwitchBotStatusPublisher.__init_() logs an error and returns early when ~device_name is empty, unknown, or of a device type without a status message, but __main_ still calls spin(), which then crashed with AttributeError (no device_type / msg_class) or KeyError from device_status(), hiding the real error message under a traceback. Mark the publisher ready only at the end of __init_ and make spin() return immediately otherwise, so the node logs the configuration error and exits. A correctly configured publisher runs exactly as before (the Remote case already returned from spin()). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: check HTTP status before parsing the response JSON SwitchBotAPIClient.request() called response.json() before response.raise_for_status(). When the API answers 4XX/5XX with a non-JSON body (an HTML error page, a plain "Too Many Requests"), a JSONDecodeError was raised and the dedicated InvalidRequestError (422) / ExceededRequestError (429) / HTTPError handling was never reached. Parse the body only after the status check succeeded; response_json is used only in that branch. Successful responses and 4XX/5XX responses with a JSON body behave exactly as before (checked with mocked requests: 200, statusCode 152, 401 JSON are unchanged; 422/429/500 with a non-JSON body now raise InvalidRequestError/ExceededRequestError/ HTTPError instead of JSONDecodeError). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: abort the action goal when the command fails execute_cb() always called set_succeeded() from its finally block, so a failed command (unknown device, offline device, API error, ...) was reported to action clients as SUCCEEDED with result.done == False. Errors not in the except list (HTTP errors / no connection from requests, ValueError for an unknown statusCode or a non-JSON reply) were even reported as SUCCEEDED with done == True before the exception escaped the callback. Catch those too, and call set_aborted() when the command failed. The feedback, the logged error and result.done are the same as before, and successful commands are still SUCCEEDED, so clients that only read result.done (SwitchBotROSClient.control_device()) see no change; only the goal state now tells the truth on failure. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #595 from k-okada/readme-update Update the READMEs for ROS 1 / ROS 2, with badges and demos
- switchbot_ros: update README.md for ROS 1 / ROS 2 Describe how to run it on ROS 2 and ROS 1, its interface (topics, services, actions, parameters) as in the source, and its requirements. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #584 from k-okada/release-3.0.1
- Contributors: Kei Okada
3.0.1 (2026-11-10)
- Merge pull request #583 from k-okada/rosdistro-55247-review rosdistro#55247 review: rename power_switching_tools_ros to jsk_power_switching_tools, fix licenses
- use SPDX license identifiers (BSD-3-Clause, Apache-2.0) in package.xml BSD -> BSD-3-Clause and Apache / "Apache License, Version 2.0" -> Apache-2.0 in all packages (ros/rosdistro#55247 review). The LICENSE files of all of them are BSD 3-Clause and Apache 2.0 respectively. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
- Contributors: Kei Okada
3.0.0 (2026-11-06)
-
Merge pull request #581 from k-okada/ros2-buildfarm-ros-environment Fix ROS2 buildfarm binary jobs: ros_environment, bundled flac, numpy wheel
-
[voicevox, chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros, ros_speech_recognition, rospatlite, sesame_ros, switchbot_ros] depend on ros_environment for ROS2 buildfarm The buildfarm builds each package with only its own build dependencies, so without ros_environment $ROS_VERSION is empty and CMakeLists.txt takes the ROS1 branch (same as jsk_common#1835). voicevox also guesses ROS_VERSION from AMENT_PREFIX_PATH when it is unset. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge branch 'master' into fix_hoya
-
Merge branch 'master' into voicevox-ros1-ros2
-
AMENT_IGNORE: do not add AMENT_IGNORE to packages already ported to ROS2 chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros,
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
Dependant Packages
Launch files
- launch/switchbot.launch
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
- launch/switchbot.launch.xml
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
Messages
Services
Plugins
Recent questions tagged switchbot_ros at Robotics Stack Exchange
|
switchbot_ros package from jsk_3rdparty repovoicevox zdepth chaplus_ros emotion_analyzer gdrive_ros google_chat_ros influxdb_store jsk_power_switching_tools nfc_ros respeaker_ros ros_speech_recognition rospatlite rosping sesame_ros switchbot_ros zdepth_image_transport |
ROS Distro
|
Package Summary
| Version | 3.0.2 |
| License | BSD-3-Clause |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Description | |
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_3rdparty.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-26 |
| Dev Status | DEVELOPED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
- Yoshiki Obinata
Authors
- Yoshiki Obinata
switchbot_ros
Controls SwitchBot devices from ROS through the
SwitchBot API. switchbot_ros_server.py publishes the list of
your devices and provides an action to send commands to them (press a Bot, turn on a light, an infrared remote, …);
switchbot_status_publisher.py publishes the status of one device (a meter, a plug, a bot, …) periodically.
Client libraries for rospy/rclpy and roseus are included.
System Component

JSK members can edit the original file here.
Requirements
- Install the SwitchBot app on your phone (iPhone, Android) and create your SwitchBot account.
-
Set up the SwitchBot devices with the app. Give each device a name (the
device_nameof the action) and enable the cloud service. Devices which talk Bluetooth only (e.g. a Bot) need a SwitchBot Hub to be controlled from the cloud. - Get your token and secret: in the app, open Profile > Preferences (Settings), tap the app version 10 times; the developer options show the token and the secret key. With a secret, the nodes use the SwitchBot API v1.1; without it (empty), the API v1.0. The token and the secret can be given as they are or as the path of a file of them.
For JSK members, please see this slide for the account, the token and the SwitchBots installed in our lab.
The nodes need the internet; the Python package requests (python3-requests) is used.
Usage
ROS 2
colcon build --packages-up-to switchbot_ros
source install/setup.bash
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET
# with the status publisher of one device
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET \
pub_status:=true pub_device_name:=YOUR_DEVICE_NAME
See the devices and send a command:
ros2 topic echo --once /switchbot_ros/devices
ros2 action send_goal --feedback /switchbot_ros/switch switchbot_ros/action/SwitchBotCommand \
"{device_name: '/myroom/light', command: 'turnOn'}"
ros2 topic echo /switchbot_status_publisher/YOUR_DEVICE_NAME
Without the launch file:
ros2 run switchbot_ros switchbot_ros_server.py --ros-args -r __node:=switchbot_ros \
-p token:=YOUR_TOKEN -p secret:=YOUR_SECRET
ROS 1
roslaunch switchbot_ros switchbot.launch token:=YOUR_TOKEN secret:=YOUR_SECRET
rostopic echo -n 1 /switchbot_ros/devices
rostopic pub -1 /switchbot_ros/switch/goal switchbot_ros/SwitchBotCommandActionGoal \
"{goal: {device_name: '/myroom/light', command: 'turnOn', parameter: '', command_type: ''}}"
rostopic echo /switchbot_ros/switch/result
Launch arguments
switchbot.launch (ROS 1) and switchbot.launch.xml (ROS 2) have the same arguments:
| Argument | Default | Meaning |
|---|---|---|
token |
(required) | the token, or the path of a file of it |
secret |
'' |
the secret key, or the path of a file of it; empty uses the API v1.0 |
respawn |
true |
respawn the nodes |
pub_status |
false |
also start switchbot_status_publisher
|
pub_status_rate |
0.1 |
the rate [Hz] of the status publisher |
pub_device_name |
bot74a |
the device of the status publisher |
Interface
switchbot_ros_server.py
The node is named switchbot_ros by the launch files (switchbot when run without them).
Published topics:
-
~devices(switchbot_ros/DeviceArray, latched): thenameandtypeof your devices and infrared remotes, published once the API client is ready.
Actions:
File truncated at 100 lines see the full file
Changelog for package switchbot_ros
3.0.2 (2026-11-26)
- Merge pull request #594 from k-okada/fix-error-handling
- switchbot_ros: exit cleanly when status publisher is misconfigured SwitchBotStatusPublisher.__init_() logs an error and returns early when ~device_name is empty, unknown, or of a device type without a status message, but __main_ still calls spin(), which then crashed with AttributeError (no device_type / msg_class) or KeyError from device_status(), hiding the real error message under a traceback. Mark the publisher ready only at the end of __init_ and make spin() return immediately otherwise, so the node logs the configuration error and exits. A correctly configured publisher runs exactly as before (the Remote case already returned from spin()). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: check HTTP status before parsing the response JSON SwitchBotAPIClient.request() called response.json() before response.raise_for_status(). When the API answers 4XX/5XX with a non-JSON body (an HTML error page, a plain "Too Many Requests"), a JSONDecodeError was raised and the dedicated InvalidRequestError (422) / ExceededRequestError (429) / HTTPError handling was never reached. Parse the body only after the status check succeeded; response_json is used only in that branch. Successful responses and 4XX/5XX responses with a JSON body behave exactly as before (checked with mocked requests: 200, statusCode 152, 401 JSON are unchanged; 422/429/500 with a non-JSON body now raise InvalidRequestError/ExceededRequestError/ HTTPError instead of JSONDecodeError). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: abort the action goal when the command fails execute_cb() always called set_succeeded() from its finally block, so a failed command (unknown device, offline device, API error, ...) was reported to action clients as SUCCEEDED with result.done == False. Errors not in the except list (HTTP errors / no connection from requests, ValueError for an unknown statusCode or a non-JSON reply) were even reported as SUCCEEDED with done == True before the exception escaped the callback. Catch those too, and call set_aborted() when the command failed. The feedback, the logged error and result.done are the same as before, and successful commands are still SUCCEEDED, so clients that only read result.done (SwitchBotROSClient.control_device()) see no change; only the goal state now tells the truth on failure. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #595 from k-okada/readme-update Update the READMEs for ROS 1 / ROS 2, with badges and demos
- switchbot_ros: update README.md for ROS 1 / ROS 2 Describe how to run it on ROS 2 and ROS 1, its interface (topics, services, actions, parameters) as in the source, and its requirements. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #584 from k-okada/release-3.0.1
- Contributors: Kei Okada
3.0.1 (2026-11-10)
- Merge pull request #583 from k-okada/rosdistro-55247-review rosdistro#55247 review: rename power_switching_tools_ros to jsk_power_switching_tools, fix licenses
- use SPDX license identifiers (BSD-3-Clause, Apache-2.0) in package.xml BSD -> BSD-3-Clause and Apache / "Apache License, Version 2.0" -> Apache-2.0 in all packages (ros/rosdistro#55247 review). The LICENSE files of all of them are BSD 3-Clause and Apache 2.0 respectively. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
- Contributors: Kei Okada
3.0.0 (2026-11-06)
-
Merge pull request #581 from k-okada/ros2-buildfarm-ros-environment Fix ROS2 buildfarm binary jobs: ros_environment, bundled flac, numpy wheel
-
[voicevox, chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros, ros_speech_recognition, rospatlite, sesame_ros, switchbot_ros] depend on ros_environment for ROS2 buildfarm The buildfarm builds each package with only its own build dependencies, so without ros_environment $ROS_VERSION is empty and CMakeLists.txt takes the ROS1 branch (same as jsk_common#1835). voicevox also guesses ROS_VERSION from AMENT_PREFIX_PATH when it is unset. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge branch 'master' into fix_hoya
-
Merge branch 'master' into voicevox-ros1-ros2
-
AMENT_IGNORE: do not add AMENT_IGNORE to packages already ported to ROS2 chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros,
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
Dependant Packages
Launch files
- launch/switchbot.launch
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
- launch/switchbot.launch.xml
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
Messages
Services
Plugins
Recent questions tagged switchbot_ros at Robotics Stack Exchange
|
switchbot_ros package from jsk_3rdparty repovoicevox zdepth chaplus_ros emotion_analyzer gdrive_ros google_chat_ros influxdb_store jsk_power_switching_tools nfc_ros respeaker_ros ros_speech_recognition rospatlite rosping sesame_ros switchbot_ros zdepth_image_transport |
ROS Distro
|
Package Summary
| Version | 3.0.2 |
| License | BSD-3-Clause |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Description | |
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_3rdparty.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-26 |
| Dev Status | DEVELOPED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
- Yoshiki Obinata
Authors
- Yoshiki Obinata
switchbot_ros
Controls SwitchBot devices from ROS through the
SwitchBot API. switchbot_ros_server.py publishes the list of
your devices and provides an action to send commands to them (press a Bot, turn on a light, an infrared remote, …);
switchbot_status_publisher.py publishes the status of one device (a meter, a plug, a bot, …) periodically.
Client libraries for rospy/rclpy and roseus are included.
System Component

JSK members can edit the original file here.
Requirements
- Install the SwitchBot app on your phone (iPhone, Android) and create your SwitchBot account.
-
Set up the SwitchBot devices with the app. Give each device a name (the
device_nameof the action) and enable the cloud service. Devices which talk Bluetooth only (e.g. a Bot) need a SwitchBot Hub to be controlled from the cloud. - Get your token and secret: in the app, open Profile > Preferences (Settings), tap the app version 10 times; the developer options show the token and the secret key. With a secret, the nodes use the SwitchBot API v1.1; without it (empty), the API v1.0. The token and the secret can be given as they are or as the path of a file of them.
For JSK members, please see this slide for the account, the token and the SwitchBots installed in our lab.
The nodes need the internet; the Python package requests (python3-requests) is used.
Usage
ROS 2
colcon build --packages-up-to switchbot_ros
source install/setup.bash
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET
# with the status publisher of one device
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET \
pub_status:=true pub_device_name:=YOUR_DEVICE_NAME
See the devices and send a command:
ros2 topic echo --once /switchbot_ros/devices
ros2 action send_goal --feedback /switchbot_ros/switch switchbot_ros/action/SwitchBotCommand \
"{device_name: '/myroom/light', command: 'turnOn'}"
ros2 topic echo /switchbot_status_publisher/YOUR_DEVICE_NAME
Without the launch file:
ros2 run switchbot_ros switchbot_ros_server.py --ros-args -r __node:=switchbot_ros \
-p token:=YOUR_TOKEN -p secret:=YOUR_SECRET
ROS 1
roslaunch switchbot_ros switchbot.launch token:=YOUR_TOKEN secret:=YOUR_SECRET
rostopic echo -n 1 /switchbot_ros/devices
rostopic pub -1 /switchbot_ros/switch/goal switchbot_ros/SwitchBotCommandActionGoal \
"{goal: {device_name: '/myroom/light', command: 'turnOn', parameter: '', command_type: ''}}"
rostopic echo /switchbot_ros/switch/result
Launch arguments
switchbot.launch (ROS 1) and switchbot.launch.xml (ROS 2) have the same arguments:
| Argument | Default | Meaning |
|---|---|---|
token |
(required) | the token, or the path of a file of it |
secret |
'' |
the secret key, or the path of a file of it; empty uses the API v1.0 |
respawn |
true |
respawn the nodes |
pub_status |
false |
also start switchbot_status_publisher
|
pub_status_rate |
0.1 |
the rate [Hz] of the status publisher |
pub_device_name |
bot74a |
the device of the status publisher |
Interface
switchbot_ros_server.py
The node is named switchbot_ros by the launch files (switchbot when run without them).
Published topics:
-
~devices(switchbot_ros/DeviceArray, latched): thenameandtypeof your devices and infrared remotes, published once the API client is ready.
Actions:
File truncated at 100 lines see the full file
Changelog for package switchbot_ros
3.0.2 (2026-11-26)
- Merge pull request #594 from k-okada/fix-error-handling
- switchbot_ros: exit cleanly when status publisher is misconfigured SwitchBotStatusPublisher.__init_() logs an error and returns early when ~device_name is empty, unknown, or of a device type without a status message, but __main_ still calls spin(), which then crashed with AttributeError (no device_type / msg_class) or KeyError from device_status(), hiding the real error message under a traceback. Mark the publisher ready only at the end of __init_ and make spin() return immediately otherwise, so the node logs the configuration error and exits. A correctly configured publisher runs exactly as before (the Remote case already returned from spin()). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: check HTTP status before parsing the response JSON SwitchBotAPIClient.request() called response.json() before response.raise_for_status(). When the API answers 4XX/5XX with a non-JSON body (an HTML error page, a plain "Too Many Requests"), a JSONDecodeError was raised and the dedicated InvalidRequestError (422) / ExceededRequestError (429) / HTTPError handling was never reached. Parse the body only after the status check succeeded; response_json is used only in that branch. Successful responses and 4XX/5XX responses with a JSON body behave exactly as before (checked with mocked requests: 200, statusCode 152, 401 JSON are unchanged; 422/429/500 with a non-JSON body now raise InvalidRequestError/ExceededRequestError/ HTTPError instead of JSONDecodeError). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: abort the action goal when the command fails execute_cb() always called set_succeeded() from its finally block, so a failed command (unknown device, offline device, API error, ...) was reported to action clients as SUCCEEDED with result.done == False. Errors not in the except list (HTTP errors / no connection from requests, ValueError for an unknown statusCode or a non-JSON reply) were even reported as SUCCEEDED with done == True before the exception escaped the callback. Catch those too, and call set_aborted() when the command failed. The feedback, the logged error and result.done are the same as before, and successful commands are still SUCCEEDED, so clients that only read result.done (SwitchBotROSClient.control_device()) see no change; only the goal state now tells the truth on failure. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #595 from k-okada/readme-update Update the READMEs for ROS 1 / ROS 2, with badges and demos
- switchbot_ros: update README.md for ROS 1 / ROS 2 Describe how to run it on ROS 2 and ROS 1, its interface (topics, services, actions, parameters) as in the source, and its requirements. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #584 from k-okada/release-3.0.1
- Contributors: Kei Okada
3.0.1 (2026-11-10)
- Merge pull request #583 from k-okada/rosdistro-55247-review rosdistro#55247 review: rename power_switching_tools_ros to jsk_power_switching_tools, fix licenses
- use SPDX license identifiers (BSD-3-Clause, Apache-2.0) in package.xml BSD -> BSD-3-Clause and Apache / "Apache License, Version 2.0" -> Apache-2.0 in all packages (ros/rosdistro#55247 review). The LICENSE files of all of them are BSD 3-Clause and Apache 2.0 respectively. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
- Contributors: Kei Okada
3.0.0 (2026-11-06)
-
Merge pull request #581 from k-okada/ros2-buildfarm-ros-environment Fix ROS2 buildfarm binary jobs: ros_environment, bundled flac, numpy wheel
-
[voicevox, chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros, ros_speech_recognition, rospatlite, sesame_ros, switchbot_ros] depend on ros_environment for ROS2 buildfarm The buildfarm builds each package with only its own build dependencies, so without ros_environment $ROS_VERSION is empty and CMakeLists.txt takes the ROS1 branch (same as jsk_common#1835). voicevox also guesses ROS_VERSION from AMENT_PREFIX_PATH when it is unset. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge branch 'master' into fix_hoya
-
Merge branch 'master' into voicevox-ros1-ros2
-
AMENT_IGNORE: do not add AMENT_IGNORE to packages already ported to ROS2 chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros,
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
Dependant Packages
Launch files
- launch/switchbot.launch
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
- launch/switchbot.launch.xml
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
Messages
Services
Plugins
Recent questions tagged switchbot_ros at Robotics Stack Exchange
|
switchbot_ros package from jsk_3rdparty repovoicevox zdepth chaplus_ros emotion_analyzer gdrive_ros google_chat_ros influxdb_store jsk_power_switching_tools nfc_ros respeaker_ros ros_speech_recognition rospatlite rosping sesame_ros switchbot_ros zdepth_image_transport |
ROS Distro
|
Package Summary
| Version | 3.0.2 |
| License | BSD-3-Clause |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Description | |
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_3rdparty.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-26 |
| Dev Status | DEVELOPED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
- Yoshiki Obinata
Authors
- Yoshiki Obinata
switchbot_ros
Controls SwitchBot devices from ROS through the
SwitchBot API. switchbot_ros_server.py publishes the list of
your devices and provides an action to send commands to them (press a Bot, turn on a light, an infrared remote, …);
switchbot_status_publisher.py publishes the status of one device (a meter, a plug, a bot, …) periodically.
Client libraries for rospy/rclpy and roseus are included.
System Component

JSK members can edit the original file here.
Requirements
- Install the SwitchBot app on your phone (iPhone, Android) and create your SwitchBot account.
-
Set up the SwitchBot devices with the app. Give each device a name (the
device_nameof the action) and enable the cloud service. Devices which talk Bluetooth only (e.g. a Bot) need a SwitchBot Hub to be controlled from the cloud. - Get your token and secret: in the app, open Profile > Preferences (Settings), tap the app version 10 times; the developer options show the token and the secret key. With a secret, the nodes use the SwitchBot API v1.1; without it (empty), the API v1.0. The token and the secret can be given as they are or as the path of a file of them.
For JSK members, please see this slide for the account, the token and the SwitchBots installed in our lab.
The nodes need the internet; the Python package requests (python3-requests) is used.
Usage
ROS 2
colcon build --packages-up-to switchbot_ros
source install/setup.bash
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET
# with the status publisher of one device
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET \
pub_status:=true pub_device_name:=YOUR_DEVICE_NAME
See the devices and send a command:
ros2 topic echo --once /switchbot_ros/devices
ros2 action send_goal --feedback /switchbot_ros/switch switchbot_ros/action/SwitchBotCommand \
"{device_name: '/myroom/light', command: 'turnOn'}"
ros2 topic echo /switchbot_status_publisher/YOUR_DEVICE_NAME
Without the launch file:
ros2 run switchbot_ros switchbot_ros_server.py --ros-args -r __node:=switchbot_ros \
-p token:=YOUR_TOKEN -p secret:=YOUR_SECRET
ROS 1
roslaunch switchbot_ros switchbot.launch token:=YOUR_TOKEN secret:=YOUR_SECRET
rostopic echo -n 1 /switchbot_ros/devices
rostopic pub -1 /switchbot_ros/switch/goal switchbot_ros/SwitchBotCommandActionGoal \
"{goal: {device_name: '/myroom/light', command: 'turnOn', parameter: '', command_type: ''}}"
rostopic echo /switchbot_ros/switch/result
Launch arguments
switchbot.launch (ROS 1) and switchbot.launch.xml (ROS 2) have the same arguments:
| Argument | Default | Meaning |
|---|---|---|
token |
(required) | the token, or the path of a file of it |
secret |
'' |
the secret key, or the path of a file of it; empty uses the API v1.0 |
respawn |
true |
respawn the nodes |
pub_status |
false |
also start switchbot_status_publisher
|
pub_status_rate |
0.1 |
the rate [Hz] of the status publisher |
pub_device_name |
bot74a |
the device of the status publisher |
Interface
switchbot_ros_server.py
The node is named switchbot_ros by the launch files (switchbot when run without them).
Published topics:
-
~devices(switchbot_ros/DeviceArray, latched): thenameandtypeof your devices and infrared remotes, published once the API client is ready.
Actions:
File truncated at 100 lines see the full file
Changelog for package switchbot_ros
3.0.2 (2026-11-26)
- Merge pull request #594 from k-okada/fix-error-handling
- switchbot_ros: exit cleanly when status publisher is misconfigured SwitchBotStatusPublisher.__init_() logs an error and returns early when ~device_name is empty, unknown, or of a device type without a status message, but __main_ still calls spin(), which then crashed with AttributeError (no device_type / msg_class) or KeyError from device_status(), hiding the real error message under a traceback. Mark the publisher ready only at the end of __init_ and make spin() return immediately otherwise, so the node logs the configuration error and exits. A correctly configured publisher runs exactly as before (the Remote case already returned from spin()). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: check HTTP status before parsing the response JSON SwitchBotAPIClient.request() called response.json() before response.raise_for_status(). When the API answers 4XX/5XX with a non-JSON body (an HTML error page, a plain "Too Many Requests"), a JSONDecodeError was raised and the dedicated InvalidRequestError (422) / ExceededRequestError (429) / HTTPError handling was never reached. Parse the body only after the status check succeeded; response_json is used only in that branch. Successful responses and 4XX/5XX responses with a JSON body behave exactly as before (checked with mocked requests: 200, statusCode 152, 401 JSON are unchanged; 422/429/500 with a non-JSON body now raise InvalidRequestError/ExceededRequestError/ HTTPError instead of JSONDecodeError). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: abort the action goal when the command fails execute_cb() always called set_succeeded() from its finally block, so a failed command (unknown device, offline device, API error, ...) was reported to action clients as SUCCEEDED with result.done == False. Errors not in the except list (HTTP errors / no connection from requests, ValueError for an unknown statusCode or a non-JSON reply) were even reported as SUCCEEDED with done == True before the exception escaped the callback. Catch those too, and call set_aborted() when the command failed. The feedback, the logged error and result.done are the same as before, and successful commands are still SUCCEEDED, so clients that only read result.done (SwitchBotROSClient.control_device()) see no change; only the goal state now tells the truth on failure. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #595 from k-okada/readme-update Update the READMEs for ROS 1 / ROS 2, with badges and demos
- switchbot_ros: update README.md for ROS 1 / ROS 2 Describe how to run it on ROS 2 and ROS 1, its interface (topics, services, actions, parameters) as in the source, and its requirements. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #584 from k-okada/release-3.0.1
- Contributors: Kei Okada
3.0.1 (2026-11-10)
- Merge pull request #583 from k-okada/rosdistro-55247-review rosdistro#55247 review: rename power_switching_tools_ros to jsk_power_switching_tools, fix licenses
- use SPDX license identifiers (BSD-3-Clause, Apache-2.0) in package.xml BSD -> BSD-3-Clause and Apache / "Apache License, Version 2.0" -> Apache-2.0 in all packages (ros/rosdistro#55247 review). The LICENSE files of all of them are BSD 3-Clause and Apache 2.0 respectively. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
- Contributors: Kei Okada
3.0.0 (2026-11-06)
-
Merge pull request #581 from k-okada/ros2-buildfarm-ros-environment Fix ROS2 buildfarm binary jobs: ros_environment, bundled flac, numpy wheel
-
[voicevox, chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros, ros_speech_recognition, rospatlite, sesame_ros, switchbot_ros] depend on ros_environment for ROS2 buildfarm The buildfarm builds each package with only its own build dependencies, so without ros_environment $ROS_VERSION is empty and CMakeLists.txt takes the ROS1 branch (same as jsk_common#1835). voicevox also guesses ROS_VERSION from AMENT_PREFIX_PATH when it is unset. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge branch 'master' into fix_hoya
-
Merge branch 'master' into voicevox-ros1-ros2
-
AMENT_IGNORE: do not add AMENT_IGNORE to packages already ported to ROS2 chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros,
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
Dependant Packages
Launch files
- launch/switchbot.launch
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
- launch/switchbot.launch.xml
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
Messages
Services
Plugins
Recent questions tagged switchbot_ros at Robotics Stack Exchange
|
switchbot_ros package from jsk_3rdparty repovoicevox zdepth chaplus_ros emotion_analyzer gdrive_ros google_chat_ros influxdb_store jsk_power_switching_tools nfc_ros respeaker_ros ros_speech_recognition rospatlite rosping sesame_ros switchbot_ros zdepth_image_transport |
ROS Distro
|
Package Summary
| Version | 3.0.2 |
| License | BSD-3-Clause |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Description | |
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_3rdparty.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-26 |
| Dev Status | DEVELOPED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
- Yoshiki Obinata
Authors
- Yoshiki Obinata
switchbot_ros
Controls SwitchBot devices from ROS through the
SwitchBot API. switchbot_ros_server.py publishes the list of
your devices and provides an action to send commands to them (press a Bot, turn on a light, an infrared remote, …);
switchbot_status_publisher.py publishes the status of one device (a meter, a plug, a bot, …) periodically.
Client libraries for rospy/rclpy and roseus are included.
System Component

JSK members can edit the original file here.
Requirements
- Install the SwitchBot app on your phone (iPhone, Android) and create your SwitchBot account.
-
Set up the SwitchBot devices with the app. Give each device a name (the
device_nameof the action) and enable the cloud service. Devices which talk Bluetooth only (e.g. a Bot) need a SwitchBot Hub to be controlled from the cloud. - Get your token and secret: in the app, open Profile > Preferences (Settings), tap the app version 10 times; the developer options show the token and the secret key. With a secret, the nodes use the SwitchBot API v1.1; without it (empty), the API v1.0. The token and the secret can be given as they are or as the path of a file of them.
For JSK members, please see this slide for the account, the token and the SwitchBots installed in our lab.
The nodes need the internet; the Python package requests (python3-requests) is used.
Usage
ROS 2
colcon build --packages-up-to switchbot_ros
source install/setup.bash
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET
# with the status publisher of one device
ros2 launch switchbot_ros switchbot.launch.xml token:=YOUR_TOKEN secret:=YOUR_SECRET \
pub_status:=true pub_device_name:=YOUR_DEVICE_NAME
See the devices and send a command:
ros2 topic echo --once /switchbot_ros/devices
ros2 action send_goal --feedback /switchbot_ros/switch switchbot_ros/action/SwitchBotCommand \
"{device_name: '/myroom/light', command: 'turnOn'}"
ros2 topic echo /switchbot_status_publisher/YOUR_DEVICE_NAME
Without the launch file:
ros2 run switchbot_ros switchbot_ros_server.py --ros-args -r __node:=switchbot_ros \
-p token:=YOUR_TOKEN -p secret:=YOUR_SECRET
ROS 1
roslaunch switchbot_ros switchbot.launch token:=YOUR_TOKEN secret:=YOUR_SECRET
rostopic echo -n 1 /switchbot_ros/devices
rostopic pub -1 /switchbot_ros/switch/goal switchbot_ros/SwitchBotCommandActionGoal \
"{goal: {device_name: '/myroom/light', command: 'turnOn', parameter: '', command_type: ''}}"
rostopic echo /switchbot_ros/switch/result
Launch arguments
switchbot.launch (ROS 1) and switchbot.launch.xml (ROS 2) have the same arguments:
| Argument | Default | Meaning |
|---|---|---|
token |
(required) | the token, or the path of a file of it |
secret |
'' |
the secret key, or the path of a file of it; empty uses the API v1.0 |
respawn |
true |
respawn the nodes |
pub_status |
false |
also start switchbot_status_publisher
|
pub_status_rate |
0.1 |
the rate [Hz] of the status publisher |
pub_device_name |
bot74a |
the device of the status publisher |
Interface
switchbot_ros_server.py
The node is named switchbot_ros by the launch files (switchbot when run without them).
Published topics:
-
~devices(switchbot_ros/DeviceArray, latched): thenameandtypeof your devices and infrared remotes, published once the API client is ready.
Actions:
File truncated at 100 lines see the full file
Changelog for package switchbot_ros
3.0.2 (2026-11-26)
- Merge pull request #594 from k-okada/fix-error-handling
- switchbot_ros: exit cleanly when status publisher is misconfigured SwitchBotStatusPublisher.__init_() logs an error and returns early when ~device_name is empty, unknown, or of a device type without a status message, but __main_ still calls spin(), which then crashed with AttributeError (no device_type / msg_class) or KeyError from device_status(), hiding the real error message under a traceback. Mark the publisher ready only at the end of __init_ and make spin() return immediately otherwise, so the node logs the configuration error and exits. A correctly configured publisher runs exactly as before (the Remote case already returned from spin()). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: check HTTP status before parsing the response JSON SwitchBotAPIClient.request() called response.json() before response.raise_for_status(). When the API answers 4XX/5XX with a non-JSON body (an HTML error page, a plain "Too Many Requests"), a JSONDecodeError was raised and the dedicated InvalidRequestError (422) / ExceededRequestError (429) / HTTPError handling was never reached. Parse the body only after the status check succeeded; response_json is used only in that branch. Successful responses and 4XX/5XX responses with a JSON body behave exactly as before (checked with mocked requests: 200, statusCode 152, 401 JSON are unchanged; 422/429/500 with a non-JSON body now raise InvalidRequestError/ExceededRequestError/ HTTPError instead of JSONDecodeError). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- switchbot_ros: abort the action goal when the command fails execute_cb() always called set_succeeded() from its finally block, so a failed command (unknown device, offline device, API error, ...) was reported to action clients as SUCCEEDED with result.done == False. Errors not in the except list (HTTP errors / no connection from requests, ValueError for an unknown statusCode or a non-JSON reply) were even reported as SUCCEEDED with done == True before the exception escaped the callback. Catch those too, and call set_aborted() when the command failed. The feedback, the logged error and result.done are the same as before, and successful commands are still SUCCEEDED, so clients that only read result.done (SwitchBotROSClient.control_device()) see no change; only the goal state now tells the truth on failure. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #595 from k-okada/readme-update Update the READMEs for ROS 1 / ROS 2, with badges and demos
- switchbot_ros: update README.md for ROS 1 / ROS 2 Describe how to run it on ROS 2 and ROS 1, its interface (topics, services, actions, parameters) as in the source, and its requirements. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>> Claude-Session: https://claude.ai/code/session_01Xo6jRt2Rcht9sQS6ms6A4p
- Merge pull request #584 from k-okada/release-3.0.1
- Contributors: Kei Okada
3.0.1 (2026-11-10)
- Merge pull request #583 from k-okada/rosdistro-55247-review rosdistro#55247 review: rename power_switching_tools_ros to jsk_power_switching_tools, fix licenses
- use SPDX license identifiers (BSD-3-Clause, Apache-2.0) in package.xml BSD -> BSD-3-Clause and Apache / "Apache License, Version 2.0" -> Apache-2.0 in all packages (ros/rosdistro#55247 review). The LICENSE files of all of them are BSD 3-Clause and Apache 2.0 respectively. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
- Contributors: Kei Okada
3.0.0 (2026-11-06)
-
Merge pull request #581 from k-okada/ros2-buildfarm-ros-environment Fix ROS2 buildfarm binary jobs: ros_environment, bundled flac, numpy wheel
-
[voicevox, chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros, ros_speech_recognition, rospatlite, sesame_ros, switchbot_ros] depend on ros_environment for ROS2 buildfarm The buildfarm builds each package with only its own build dependencies, so without ros_environment $ROS_VERSION is empty and CMakeLists.txt takes the ROS1 branch (same as jsk_common#1835). voicevox also guesses ROS_VERSION from AMENT_PREFIX_PATH when it is unset. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge branch 'master' into fix_hoya
-
Merge branch 'master' into voicevox-ros1-ros2
-
AMENT_IGNORE: do not add AMENT_IGNORE to packages already ported to ROS2 chaplus_ros, emotion_analyzer, gdrive_ros, google_chat_ros, influxdb_store, power_switching_tools_ros, respeaker_ros,
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
Dependant Packages
Launch files
- launch/switchbot.launch
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]
- launch/switchbot.launch.xml
-
- token
- secret [default: '']
- respawn [default: true]
- pub_status [default: false]
- pub_status_rate [default: 0.1]
- pub_device_name [default: bot74a]