-
-
Notifications
You must be signed in to change notification settings - Fork 32k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Bot in SwitchBot Cloud #135606
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Hey there @SeraphicRav, @laurence-presland, @Gigatrappeur, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
c8b2139
to
d67d159
Compare
await hass.config_entries.async_forward_entry_setups(config, PLATFORMS) | ||
await gather( | ||
*[coordinator.async_refresh() for coordinator in coordinators_by_id.values()] | ||
) | ||
await hass.config_entries.async_forward_entry_setups(config, PLATFORMS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is correct, but we should do this in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR opened: #135625
if "Bot" in device.device_type: | ||
if ( | ||
coordinator.data is not None | ||
and coordinator.data.get("deviceMode") == "pressMode" | ||
): | ||
# pressMode Bots are handled by the Button platform | ||
return None | ||
return SwitchBotCloudSwitch(api, device, coordinator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this here? The switch platform doesn't create things for the Bot right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bots can be configured to behaved in two different modes:
- in
switchMode
, there are two actions,on
(the little arm goes out and stays out) andoff
(the little arm goes back in and stays in) - in
pressMode
, there is only one action: the little arm comes out and immediately goes back in.
(there's a third mode customizeMode
that has the same actions as switchMode
but the behavior is customizable).
I've mapped the switchMode
/customizeMode
to the switch platform and the pressMode
to the button platform.
@@ -111,6 +113,10 @@ def make_device_data( | |||
devices_data.locks.append( | |||
prepare_device(hass, api, device, coordinators_by_id) | |||
) | |||
if isinstance(device, Device) and device.device_type in ["Bot"]: | |||
devices_data.buttons.append( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buttons
is never used. the button
platform is using switches
instead. is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a mistake on my part, I've updated the button
platform code to use buttons
d67d159
to
1575c00
Compare
1575c00
to
949d308
Compare
Proposed change
Adds support for SwitchBot Bots (in SwitchBot Cloud) both as switches for Bots in
switchMode
andcustomizeMode
, as well as buttons for Bots inpressMode
.Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: