Comments (9)
I got 3.3 working in my fork and it's now been integrated back. Give it a try and let me know if it doesn't work. I based it on the tuyaapi node.js code and tried to get it to fit into the existing framework.
Once you have a device you can call .set_version(3.3) to use the newer protocol. (There will be a constant once the next pull request is integrated).
from python-tuya.
I confirm, it works now.
from python-tuya.
Same here, works like a charm.
Thank you very much.
from python-tuya.
I can't seem to get 3.3 to work with the most recent version. After entering data = d.status() as per the example, I get the following. Any idea how to fix? Thanks.
Unexpected status() payload=b'3.3\x00\x00\x00\x00\x00\nw\xbf\x00\x00\x00\x01\xd2\x97Q1X\xd5[\xeb\xb6
\xa5k\x04{\xe6\xfe\x1e\x10\xb4\x0e\x0c<\xbd*G\x05\x9c[;\xe0\x12\x98\xa4]\x02\xd4\x14/\x87\xe4g\x1c\x
1e\xfc\xee\x87|\x9e\x9d9\x94A\xa3\x0c\x9c\x03\x94\xf4\xc3\xfe\xc9\xed\x18N\xaa\xd6Ac\xf3\x9a\x13u\xc
5"\x98MW\xe8\xd4\xb0\x1f'
from python-tuya.
Can you pastbin the code?
from python-tuya.
Sorry, what code?
from python-tuya.
Whatever code you're using that calls pytuya. For version 3.3 you need to call d.set_version(3.3) before calling .status() for example.
from python-tuya.
Ah - I was just using the sample code on the front page of this git, which I guess hasn't been updated to note that yet. Did that and it works fine on one of my Tuya plugs thanks. On the other I'm getting this error after checking d.status():
Traceback (most recent call last):
File "", line 1, in
File "C:\Python37\lib\site-packages\pytuya-7.0.4-py3.7.egg\pytuya_init_.py", line 307, in statu
s
result = cipher.decrypt(result, False)
File "C:\Python37\lib\site-packages\pytuya-7.0.4-py3.7.egg\pytuya_init_.py", line 94, in decryp
t
plain_text += cipher.feed() # flush final block
File "C:\Python37\lib\site-packages\pyaes\blockfeeder.py", line 169, in feed
result = self._final(self._buffer, self._padding)
File "C:\Python37\lib\site-packages\pyaes\blockfeeder.py", line 77, in _block_final_decrypt
return strip_PKCS7_padding(self.decrypt(data))
File "C:\Python37\lib\site-packages\pyaes\util.py", line 58, in strip_PKCS7_padding
raise ValueError("invalid padding byte")
ValueError: invalid padding byte
from python-tuya.
I also have problems to get status on 3.3 devices. You can see it does recognise the devices as 3.3, because the code fails in the 3.3 section, so the set_version must be ok. (I believe my devices are using 3.3. When I set the version to 3.2, it stops working completely. Here, the switches successfully turn on and off. )
The code traceback as follows
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 249, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 419, in async_device_update
await self.hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/local_tuya/switch.py", line 158, in update
status = self._device.status()
File "/config/custom_components/local_tuya/switch.py", line 116, in status
self._cached_status = self.__get_status()
File "/config/custom_components/local_tuya/switch.py", line 94, in __get_status
status = self._device.status()
File "/config/custom_components/local_tuya/pytuya/init.py", line 311, in status
result = cipher.decrypt(result, False)
File "/config/custom_components/local_tuya/pytuya/init.py", line 87, in decrypt
raw = cipher.decrypt(enc)
File "/usr/local/lib/python3.7/site-packages/Crypto/Cipher/_mode_ecb.py", line 195, in decrypt
raise ValueError("Data must be aligned to block boundary in ECB mode")
ValueError: Data must be aligned to block boundary in ECB mode
from python-tuya.
Related Issues (20)
- Logo Design Offer as Open Source Contribution HOT 1
- Logging is blocked when pytuya is imported HOT 1
- Web version
- BHT-6000 Thermostat (Decrypt) HOT 3
- dps status
- Vaccum Cleaner HOT 1
- ImportError: No module named 'pytuya' HOT 4
- Cannot use module, OutletDevice method does not exist HOT 2
- Support for curtain switch HOT 2
- Smart Life / Jinvoo request latest release installed HOT 1
- Error when changing color on the light
- Tuya App 2.8 No Longer Valid
- 7.0.4 release on PyPI HOT 2
- new switches different port HOT 3
- PIR & Door/Window Sensor Support? HOT 4
- d.status timeout with a just bought device HOT 8
- Get Device Local Key HOT 1
- 7.0.6 release HOT 2
- socket.timeout: timed out
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-tuya.