Giter Site home page Giter Site logo

Tuya 3.3 version support about python-tuya HOT 9 OPEN

clach04 avatar clach04 commented on September 25, 2024 2
Tuya 3.3 version support

from python-tuya.

Comments (9)

belzedaar avatar belzedaar commented on September 25, 2024

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.

sunwire avatar sunwire commented on September 25, 2024

I confirm, it works now.

from python-tuya.

Jalleronline avatar Jalleronline commented on September 25, 2024

Same here, works like a charm.
Thank you very much.

from python-tuya.

mobamoba avatar mobamoba commented on September 25, 2024

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.

belzedaar avatar belzedaar commented on September 25, 2024

Can you pastbin the code?

from python-tuya.

mobamoba avatar mobamoba commented on September 25, 2024

Sorry, what code?

from python-tuya.

belzedaar avatar belzedaar commented on September 25, 2024

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.

mobamoba avatar mobamoba commented on September 25, 2024

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.

cschutte avatar cschutte commented on September 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.