-
-
Notifications
You must be signed in to change notification settings - Fork 239
Initial TapoCamera support #1165
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e07acf2
Initial TapoCamera support
sdb9696 2234b85
Add new aes discovery
sdb9696 51fc8af
Clean up SslAesTransport and move SmartCamera
sdb9696 559e62f
Always send dicts as multiple requests
sdb9696 d97c2de
Remove inline import binascii
sdb9696 7d83809
Merge remote-tracking branch 'upstream/master' into feat/tapo_cam
sdb9696 0df73fb
Handle single requests
sdb9696 8491a6b
Address review comments
sdb9696 795ee26
Fix tests
sdb9696 d68c619
Hide smart camera behind experimental flag
sdb9696 98dca54
Update post review and enable smart camera connect in cli
sdb9696 b30cbe2
Add extra handshake step
sdb9696 fe5f037
Try password hash handshake
sdb9696 bef8715
Update DiscoveryResult for new fields
sdb9696 0992d00
Remove camera specific queries
sdb9696 5103ebc
Check for error_code in single response
sdb9696 49d1274
Set ssl context on secure passthrough
sdb9696 60552c0
Revert extra handshake steps
sdb9696 da1cf69
Fix type test
sdb9696 cfb959e
Add discovery encryption test
sdb9696 1d04c04
Merge remote-tracking branch 'upstream/master' into feat/tapo_cam
sdb9696 422f3fd
Move SslAesTransport into experimental
sdb9696 8716aa7
Do not import experimental classes into package
sdb9696 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Package for experimental.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| """Package for experimental enabled.""" | ||
|
|
||
|
|
||
| class Enabled: | ||
| """Class for enabling experimental functionality.""" | ||
|
|
||
| value = False | ||
|
|
||
| @classmethod | ||
| def set(cls, value): | ||
| """Set the enabled value.""" | ||
| cls.value = value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| """Module for smartcamera.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from ..device_type import DeviceType | ||
| from ..smart import SmartDevice | ||
| from .sslaestransport import SmartErrorCode | ||
|
|
||
|
|
||
| class SmartCamera(SmartDevice): | ||
| """Class for smart cameras.""" | ||
|
|
||
| async def update(self, update_children: bool = False): | ||
| """Update the device.""" | ||
| initial_query = { | ||
| "getDeviceInfo": {"device_info": {"name": ["basic_info", "info"]}}, | ||
| "getLensMaskConfig": {"lens_mask": {"name": ["lens_mask_info"]}}, | ||
| } | ||
| resp = await self.protocol.query(initial_query) | ||
| self._last_update.update(resp) | ||
| info = self._try_get_response(resp, "getDeviceInfo") | ||
| self._info = self._map_info(info["device_info"]) | ||
| self._last_update = resp | ||
|
|
||
| def _map_info(self, device_info: dict) -> dict: | ||
| basic_info = device_info["basic_info"] | ||
| return { | ||
| "model": basic_info["device_model"], | ||
| "type": basic_info["device_type"], | ||
| "alias": basic_info["device_alias"], | ||
| "fw_ver": basic_info["sw_version"], | ||
| "hw_ver": basic_info["hw_version"], | ||
| "mac": basic_info["mac"], | ||
| "hwId": basic_info["hw_id"], | ||
| "oem_id": basic_info["oem_id"], | ||
| } | ||
|
|
||
| @property | ||
| def is_on(self) -> bool: | ||
| """Return true if the device is on.""" | ||
| if isinstance(self._last_update["getLensMaskConfig"], SmartErrorCode): | ||
| return True | ||
| return ( | ||
| self._last_update["getLensMaskConfig"]["lens_mask"]["lens_mask_info"][ | ||
| "enabled" | ||
| ] | ||
| == "on" | ||
| ) | ||
|
|
||
| async def set_state(self, on: bool): | ||
| """Set the device state.""" | ||
| if isinstance(self._last_update["getLensMaskConfig"], SmartErrorCode): | ||
| return | ||
| query = { | ||
| "setLensMaskConfig": { | ||
| "lens_mask": {"lens_mask_info": {"enabled": "on" if on else "off"}} | ||
| }, | ||
| } | ||
| return await self.protocol.query(query) | ||
|
|
||
| @property | ||
| def device_type(self) -> DeviceType: | ||
| """Return the device type.""" | ||
| return DeviceType.Camera | ||
|
|
||
| @property | ||
| def alias(self) -> str | None: | ||
| """Returns the device alias or nickname.""" | ||
| if self._info: | ||
| return self._info.get("alias") | ||
| return None | ||
|
|
||
| @property | ||
| def hw_info(self) -> dict: | ||
| """Return hardware info for the device.""" | ||
| return { | ||
| "sw_ver": self._info.get("hw_ver"), | ||
| "hw_ver": self._info.get("fw_ver"), | ||
| "mac": self._info.get("mac"), | ||
| "type": self._info.get("type"), | ||
| "hwId": self._info.get("hwId"), | ||
| "dev_name": self.alias, | ||
| "oemId": self._info.get("oem_id"), | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.