-
-
Notifications
You must be signed in to change notification settings - Fork 36.4k
Switchbot Cloud: Add new supported device Ai Art Frame #160355
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
base: dev
Are you sure you want to change the base?
Conversation
|
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
|
| self.access_tokens: deque[str] = deque() | ||
| self.access_tokens.append("switchbot_art_frame_token") |
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?
| async def async_update(self) -> None: | ||
| """Async update.""" | ||
| self._attr_image_last_updated = datetime.datetime.now() |
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.
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"" |
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 do we initialize empty?
| 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() |
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 is a service specific call, this should exist in the library
| @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 | ||
| ) |
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.
Internals shouldn't be created independently, instead patch the library to return what we expect and check the state machine
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Breaking change
Proposed change
This is a digital photo frame; you can switch pictures using buttons.
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: