Skip to content

Conversation

@XiaoLing-git
Copy link
Contributor

@XiaoLing-git XiaoLing-git commented Jan 6, 2026

Breaking change

Proposed change

This is a digital photo frame; you can switch pictures using buttons.

  1. get battery level
  2. get display mode
  3. switch picture
  4. display current picture

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link

home-assistant bot commented Jan 6, 2026

Hey there @SeraphicRav, @laurence-presland, @Gigatrappeur, mind taking a look at this pull request as it has been labeled with an integration (switchbot_cloud) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of switchbot_cloud can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign switchbot_cloud Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

Comment on lines +46 to +47
self.access_tokens: deque[str] = deque()
self.access_tokens.append("switchbot_art_frame_token")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Comment on lines +55 to +57
async def async_update(self) -> None:
"""Async update."""
self._attr_image_last_updated = datetime.datetime.now()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but this doesn't change it

super().__init__(api, device, coordinator)
self.access_tokens: deque[str] = deque()
self.access_tokens.append("switchbot_art_frame_token")
self._image_content = b""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we initialize empty?

Comment on lines +59 to +68
async def download_image(self) -> None:
"""Download image."""
if not isinstance(self.image_url, str) or len(self.image_url.strip()) == 0:
self._image_content = b""
return
timeout = ClientTimeout(total=30, connect=5, sock_read=20)
session = async_get_clientsession(self.coordinator.hass)
async with session.get(self.image_url, timeout=timeout) as response:
response.raise_for_status()
self._image_content = await response.read()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a service specific call, this should exist in the library

Comment on lines +20 to +46
@pytest.fixture
def mock_api():
"""Fixture for mock SwitchBotAPI."""
return Mock(name="SwitchBotAPI")


@pytest.fixture
def mock_device():
"""Fixture for mock Device/Remote."""
return Mock(name="Device", device_id="test_device_123")


@pytest.fixture
def mock_coordinator():
"""Fixture for mock SwitchBotCoordinator."""
coordinator = Mock(name="SwitchBotCoordinator")
coordinator.hass = Mock(name="HASS")
coordinator.data = None
return coordinator


@pytest.fixture
def image_entity(mock_api, mock_device, mock_coordinator):
"""Fixture for SwitchBotCloudImage entity."""
return SwitchBotCloudImage(
api=mock_api, device=mock_device, coordinator=mock_coordinator
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internals shouldn't be created independently, instead patch the library to return what we expect and check the state machine

@home-assistant home-assistant bot marked this pull request as draft January 6, 2026 18:12
@home-assistant
Copy link

home-assistant bot commented Jan 6, 2026

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants