Add support for Tapo H110 IR Air Conditioners#1716
Conversation
…into feature/tpap
|
|
||
| @staticmethod | ||
| def _sha256_hex_upper(value: str) -> str: | ||
| return hashlib.sha256(value.encode()).hexdigest().upper() # noqa: S324 |
| encoding=serialization.Encoding.X962, | ||
| format=serialization.PublicFormat.UncompressedPoint, | ||
| ) | ||
|
|
| cls, password: str, prefix: str, rounds_from_params: int | None = None | ||
| ) -> str | None: | ||
| if not prefix: | ||
| return None |
| return "default_userpw" | ||
| if 3 in pake: | ||
| return "shared_token" | ||
| if 1 in pake or 2 in pake or 5 in pake: |
rytilahti
left a comment
There was a problem hiding this comment.
Hey @Andrei965, really nice to see new contributors to the project! I left few comments inline, feel free to take a look. As this requires a new comms protocol that has not been merged, I ignored the parts related to that for now.
We might create a separate feature branch for TPAP soon to make it easier to review PRs that require it, but until then, feel free to take a look at my comments and let me know what you think. And please create a PR to add a fixture file for testing (or include it to this PR), as seeing the data makes it easier to review the code.
| from .smartirac import SmartIrAC | ||
|
|
||
| __all__ = ["SmartDevice", "SmartChildDevice"] | ||
| __all__ = ["SmartDevice", "SmartChildDevice", "SmartIrAC"] |
There was a problem hiding this comment.
As this is a child device, there should be no need to export this.
| async def _try_create_child( | ||
| self, info: dict, child_components: dict | ||
| ) -> SmartDevice | None: | ||
| if info.get("category") == "ir.remote" and info.get("model") == "AC": |
There was a problem hiding this comment.
As this is a child device, please move the initialization to happen inside SmartChildDevice.create().
| def device_type(self) -> DeviceType: | ||
| """Return the device type.""" | ||
| try: | ||
| return DeviceType.Climate | ||
| except AttributeError: | ||
| return DeviceType.Thermostat |
| """Update the internal info state.""" | ||
| super()._update_internal_state(info) | ||
|
|
||
| ac_status = info.get("ac_status") |
There was a problem hiding this comment.
We want to have a less fragile parsing of the status. I cannot off the bat recommend how it should look like (could you create a PR to add a fixture?), but we want to make it more robust to avoid breaking if the device responses change suddenly.
If this is a regular smart device, maybe it is only necessary to implement a module to handle this case? Let me know what do you think & if you need any help with deciphering how to bolt modules in!
Based on #1590
Description:
This PR introduces support for Air Conditioner virtual remotes connected via the Tapo H110 Hub using the TPAP/KLAP protocol.
Because IR remotes are stateless and require sending the entire state payload in a single IR blast, this PR implements a dedicated SmartIrAC class subclassing SmartDevice that overrides standard behavior. Instead of updating properties individually, it uses the hub's control_child method to send a sendIrCmdByStatus request containing all AC properties (power, on, mode, temp, wind_speed, wind_direct).
Key Changes:
Testing Performed: