Skip to content
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

Protocol 3.4 #1222

Merged
merged 13 commits into from
Jan 10, 2023
Merged

Protocol 3.4 #1222

merged 13 commits into from
Jan 10, 2023

Conversation

rospogrigio
Copy link
Owner

Introduced support for 3.4 protocol (and incidentally, 3.2), merging code from tinytuya project.

@MindFreeze
Copy link

MindFreeze commented Jan 9, 2023

I was able to add an energy meter and it got the initial values but then it is not updating. I tried scan interval to 10 and still no update

Correction: It does update sometimes but sporadically and definitely doesn't respect scan interval

@rospogrigio
Copy link
Owner Author

Well, sorry to read this. Can you enable debugging and post some interesting snippet of output so maybe I can understand the reason? The device I've been testing does not provide energy meter values...

@plandregan
Copy link

Will this be merged in with the Master at some point once tested? So that HomeAssistant recognized |LocalTuya has been updated?

@rospogrigio
Copy link
Owner Author

Of course, that is the plan. But I'd need to have some feedback to make sure everything is working properly before I merge it.

@thedfordfox
Copy link

thedfordfox commented Jan 9, 2023

Mine ended up being a v3.2 firmware but this did fix it. All DPs were discovered and I can fully control the lights. It's this one btw: https://monsterilluminessence.com/product/smart-led-light-strip/

Thanks so much for your work on this integration. I sent you a few euros :)

@MindFreeze
Copy link

Turns out debugging was already enabled. Here are some errors:

First occurred: 15:17:56 (1 occurrences)
Last logged: 15:17:56

Error doing job: Exception in callback _SelectorDatagramTransport._read_ready()
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 1027, in _read_ready
    self._protocol.datagram_received(data, addr)
  File "/config/custom_components/localtuya/discovery.py", line 70, in datagram_received
    self.device_found(decoded)
  File "/config/custom_components/localtuya/discovery.py", line 79, in device_found
    self._callback(device)
  File "/config/custom_components/localtuya/__init__.py", line 142, in _device_discovered
    device = hass.data[DOMAIN][TUYA_DEVICES][device_id]
KeyError: 'bfdedb3886511a2174yzy3'
First occurred: 13:36:15 (612 occurrences)
Last logged: 17:42:15

Error doing job: Fatal error: protocol.data_received() call failed.
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 868, in _read_ready__data_received
    self._protocol.data_received(data)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 611, in data_received
    self.dispatcher.add_data(data)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 423, in add_data
    msg = unpack_message(self.buffer, header=header, hmac_key=hmac_key, logger=self);
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 282, in unpack_message
    raise DecodeError('Not enough data to unpack header')
NameError: name 'DecodeError' is not defined
First occurred: 13:35:54 (1225 occurrences)
Last logged: 17:42:20

[bf0...flb] Got message type 3 for unknown listener 1: TuyaMessage(seqno=1, cmd=3, retcode=1, payload=b'd\xc5\xd8\xc8', crc=b'\\D\xe6?Q\xd1\x91g\xb32\xb3/\x10\x08\xbc\xaaJ\x10\xb1\xc2\x9cr\x16+\x19{L\xcc\xa2b%\x8b', crc_good=False)
[bf0...flb] Got message type 3 for unknown listener 3: TuyaMessage(seqno=3, cmd=3, retcode=1, payload=b'd\xc5\xd8\xc8', crc=b'\\D\xe6?Q\xd1\x91g\xb32\xb3/\x10\x08\xbc\xaaJ\x10\xb1\xc2\x9cr\x16+\x19{L\xcc>?sR', crc_good=False)

@mf42
Copy link

mf42 commented Jan 9, 2023

Just added a Ledvance RGB bulb with v3.4 and it works like a charm. Couldn't find the Color Temp dps but that does not matter. Great, thanks!

@plandregan
Copy link

plandregan commented Jan 9, 2023 via email

@MindFreeze
Copy link

@rospogrigio ignore the errors above. They were caused by another energy meter that is not supported and on 3.3 . I removed it and there are no errors now but the updates are still random. Checking the full log for anything relevant

@MindFreeze
Copy link

Opened the energy meter in the tuya app and it started updating according to scan interval. Closed the app and it continued. Hope it holds.
Either way this shouldn't block the PR

@bentessel
Copy link

Had a attributeError

2023-01-10 11:14:21.388 ERROR (MainThread) [custom_components.localtuya.config_flow] Unexpected exception
Traceback (most recent call last):
File "/config/custom_components/localtuya/config_flow.py", line 586, in async_step_configure_device
File "/config/custom_components/localtuya/config_flow.py", line 251, in validate_input
try:
File "/config/custom_components/localtuya/pytuya/init.py", line 1158, in connect
_, protocol = await loop.create_connection(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1089, in create_connection
transport, protocol = await self._create_connection_transport(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1107, in _create_connection_transport
protocol = protocol_factory()
File "/config/custom_components/localtuya/pytuya/init.py", line 1159, in
lambda: TuyaProtocol(
File "/config/custom_components/localtuya/pytuya/init.py", line 567, in init
self.dispatcher = self._setup_dispatcher()
File "/config/custom_components/localtuya/pytuya/init.py", line 621, in _setup_dispatcher
return MessageDispatcher(self.id, _status_update, self.version, self.local_key)
AttributeError: 'TuyaProtocol' object has no attribute 'version'

@rospogrigio
Copy link
Owner Author

@bentessel yeah, that was reported also by another user, I have just pushed a fix, can you update and retry?
Thank you

@bentessel
Copy link

@rospogrigio That seems to do the trick, i was able to add the device. 👍

@RayLation
Copy link

Hello
Newbie here... How can I test this? Can I force HACS to download this version instead ? Or should I manually download files that have changed and overwrite in hass?
Thanks!

@rospogrigio
Copy link
Owner Author

No, can't use HACS for this, you should download the files and overwrite them. Actually only config_flow.py and pytuya/__init__.py are the needed ones. Let me know how it goes.

@manuelsoldini
Copy link

3.4 Working perfectly for a light, an external switch and a wall switch! Love it, also tested 3.3 devices and work perfectly

@rospogrigio
Copy link
Owner Author

OK looks like I only got positive feedbacks, I'll publish a release shortly.
Thank you all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants