|
1 | 1 | .. py:module:: kasa.modules |
2 | 2 |
|
| 3 | +
|
3 | 4 | .. _library_design: |
4 | 5 |
|
5 | 6 | Library Design & Modules |
@@ -46,6 +47,7 @@ While the properties are designed to provide a nice API to use for common use ca |
46 | 47 | you may sometimes want to access the raw, cached data as returned by the device. |
47 | 48 | This can be done using the :attr:`~kasa.SmartDevice.internal_state` property. |
48 | 49 |
|
| 50 | + |
49 | 51 | .. _modules: |
50 | 52 |
|
51 | 53 | Modules |
@@ -61,6 +63,42 @@ You can get the list of supported modules for a given device instance using :att |
61 | 63 | If you only need some module-specific information, |
62 | 64 | you can call the wanted method on the module to avoid using :meth:`~kasa.SmartDevice.update`. |
63 | 65 |
|
| 66 | +Protocols and Transports |
| 67 | +************************ |
| 68 | + |
| 69 | +The library supports two different TP-Link protocols, ``IOT`` and ``SMART``. |
| 70 | +``IOT`` is the original Kasa protocol and ``SMART`` is the newer protocol supported by TAPO devices and newer KASA devices. |
| 71 | +The original protocol has a ``target``, ``command``, ``args`` interface whereas the new protocol uses a different set of |
| 72 | +commands and has a ``method``, ``parameters`` interface. |
| 73 | +Confusingly TP-Link originally called the Kasa line "Kasa Smart" and hence this library used "Smart" in a lot of the |
| 74 | +module and class names but actually they were built to work with the ``IOT`` protocol. |
| 75 | + |
| 76 | +In 2021 TP-Link started updating the underlying communication transport used by Kasa devices to make them more secure. |
| 77 | +It switched from a TCP connection with static XOR type of encryption to a transport called ``KLAP`` which communicates |
| 78 | +over http and uses handshakes to negotiate a dynamic encryption cipher. |
| 79 | +This automatic update was put on hold and only seemed to affect UK HS100 models. |
| 80 | + |
| 81 | +In 2023 TP-Link started updating the underlying communication transport used by Tapo devices to make them more secure. |
| 82 | +It switched from AES encryption via public key exchange to use ``KLAP`` encryption and negotiation due to concerns |
| 83 | +around impersonation with AES. |
| 84 | +The encryption cipher is the same as for Kasa KLAP but the handshake seeds are slightly different. |
| 85 | +Also in 2023 TP-Link started releasing newer Kasa branded devices using the ``SMART`` protocol. |
| 86 | +This appears to be driven by hardware version rather than firmware. |
| 87 | + |
| 88 | + |
| 89 | +In order to support these different configurations the library migrated from a single :class:`TPLinkSmartHomeProtocol <kasa.protocol.TPLinkSmartHomeProtocol>` |
| 90 | +to support pluggable transports and protocols. |
| 91 | +The classes providing this functionality are: |
| 92 | + |
| 93 | +- :class:`BaseProtocol <kasa.protocol.BaseProtocol>` |
| 94 | +- :class:`IotProtocol <kasa.iotprotocol.IotProtocol>` |
| 95 | +- :class:`SmartProtocol <kasa.smartprotocol.SmartProtocol>` |
| 96 | + |
| 97 | +- :class:`BaseTransport <kasa.protocol.BaseTransport>` |
| 98 | +- :class:`AesTransport <kasa.aestransport.AesTransport>` |
| 99 | +- :class:`KlapTransport <kasa.klaptransport.KlapTransport>` |
| 100 | +- :class:`KlapTransportV2 <kasa.klaptransport.KlapTransportV2>` |
| 101 | + |
64 | 102 |
|
65 | 103 | API documentation for modules |
66 | 104 | ***************************** |
@@ -70,3 +108,48 @@ API documentation for modules |
70 | 108 | :members: |
71 | 109 | :inherited-members: |
72 | 110 | :undoc-members: |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | +API documentation for protocols and transports |
| 115 | +********************************************** |
| 116 | + |
| 117 | +.. autoclass:: kasa.protocol.BaseProtocol |
| 118 | + :members: |
| 119 | + :inherited-members: |
| 120 | + :undoc-members: |
| 121 | + |
| 122 | +.. autoclass:: kasa.iotprotocol.IotProtocol |
| 123 | + :members: |
| 124 | + :inherited-members: |
| 125 | + :undoc-members: |
| 126 | + |
| 127 | +.. autoclass:: kasa.smartprotocol.SmartProtocol |
| 128 | + :members: |
| 129 | + :inherited-members: |
| 130 | + :undoc-members: |
| 131 | + |
| 132 | +.. autoclass:: kasa.protocol.BaseTransport |
| 133 | + :members: |
| 134 | + :inherited-members: |
| 135 | + :undoc-members: |
| 136 | + |
| 137 | +.. autoclass:: kasa.klaptransport.KlapTransport |
| 138 | + :members: |
| 139 | + :inherited-members: |
| 140 | + :undoc-members: |
| 141 | + |
| 142 | +.. autoclass:: kasa.klaptransport.KlapTransportV2 |
| 143 | + :members: |
| 144 | + :inherited-members: |
| 145 | + :undoc-members: |
| 146 | + |
| 147 | +.. autoclass:: kasa.aestransport.AesTransport |
| 148 | + :members: |
| 149 | + :inherited-members: |
| 150 | + :undoc-members: |
| 151 | + |
| 152 | +.. autoclass:: kasa.protocol.TPLinkSmartHomeProtocol |
| 153 | + :members: |
| 154 | + :inherited-members: |
| 155 | + :undoc-members: |