Skip to content

Commit e982ac1

Browse files
XiaoLing-gitfrenck
authored andcommitted
Switchbot Cloud: Fix Roller Shade not work issue (home-assistant#152528)
1 parent b4747ea commit e982ac1

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

homeassistant/components/switchbot_cloud/cover.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,13 @@ class SwitchBotCloudCoverRollerShade(SwitchBotCloudCover):
109109

110110
async def async_open_cover(self, **kwargs: Any) -> None:
111111
"""Open the cover."""
112-
await self.send_api_command(RollerShadeCommands.SET_POSITION, parameters=str(0))
112+
await self.send_api_command(RollerShadeCommands.SET_POSITION, parameters=0)
113113
await asyncio.sleep(COVER_ENTITY_AFTER_COMMAND_REFRESH)
114114
await self.coordinator.async_request_refresh()
115115

116116
async def async_close_cover(self, **kwargs: Any) -> None:
117117
"""Close the cover."""
118-
await self.send_api_command(
119-
RollerShadeCommands.SET_POSITION, parameters=str(100)
120-
)
118+
await self.send_api_command(RollerShadeCommands.SET_POSITION, parameters=100)
121119
await asyncio.sleep(COVER_ENTITY_AFTER_COMMAND_REFRESH)
122120
await self.coordinator.async_request_refresh()
123121

@@ -126,7 +124,7 @@ async def async_set_cover_position(self, **kwargs: Any) -> None:
126124
position: int | None = kwargs.get("position")
127125
if position is not None:
128126
await self.send_api_command(
129-
RollerShadeCommands.SET_POSITION, parameters=str(100 - position)
127+
RollerShadeCommands.SET_POSITION, parameters=(100 - position)
130128
)
131129
await asyncio.sleep(COVER_ENTITY_AFTER_COMMAND_REFRESH)
132130
await self.coordinator.async_request_refresh()

homeassistant/components/switchbot_cloud/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def send_api_command(
4444
self,
4545
command: Commands,
4646
command_type: str = "command",
47-
parameters: dict | str = "default",
47+
parameters: dict | str | int = "default",
4848
) -> None:
4949
"""Send command to device."""
5050
await self._api.send_command(

tests/components/switchbot_cloud/test_cover.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ async def test_roller_shade_features(
319319
blocking=True,
320320
)
321321
mock_send_command.assert_called_once_with(
322-
"cover-id-1", RollerShadeCommands.SET_POSITION, "command", "0"
322+
"cover-id-1", RollerShadeCommands.SET_POSITION, "command", 0
323323
)
324324

325325
await configure_integration(hass)
@@ -334,7 +334,7 @@ async def test_roller_shade_features(
334334
blocking=True,
335335
)
336336
mock_send_command.assert_called_once_with(
337-
"cover-id-1", RollerShadeCommands.SET_POSITION, "command", "100"
337+
"cover-id-1", RollerShadeCommands.SET_POSITION, "command", 100
338338
)
339339

340340
await configure_integration(hass)
@@ -349,7 +349,7 @@ async def test_roller_shade_features(
349349
blocking=True,
350350
)
351351
mock_send_command.assert_called_once_with(
352-
"cover-id-1", RollerShadeCommands.SET_POSITION, "command", "50"
352+
"cover-id-1", RollerShadeCommands.SET_POSITION, "command", 50
353353
)
354354

355355

0 commit comments

Comments
 (0)