-
Notifications
You must be signed in to change notification settings - Fork 279
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
Add support for additional data point values in Tuya payloads #483
Conversation
@hacker-cb could you review this? |
@gmbnomis where you found about multiply dp in one command? There is no such information in official tuya document. |
Please have a look into the corresponding issue #478. I have a water leakage sensor that sends such a payload. You are right, the Zigbee part does not mention it explicitly, but if you look at the serial protocol it is possible to send multiple DP values back-to-back. ("Sending multiple commands are supported in obj type data points"). I reckon that in my case, these back-to-back data point values are just put into the Zcl "DP data" |
@gmbnomis seems you are right, I can accept version that MCU DPs data is transfered transparently via Zigbee. I think right way is completely replace single-dp behaviour with multi-dp because may be other devices also use multi-dp format and currently we just ignore this. Of cause, need to refactor converters in this case. After brief lookup, for incoming dp:
For outgoing dp:
So, @Koenkk how do you think? |
@hacker-cb Makes sense. Essentially, we would convert these by changing
There is also
I would propose:
|
Sounds good to me, I think such change has quite a risk so once ready I will merge it after the next release on 1 January. |
Great! @hacker-cb As you have looked into the outgoing part in more detail, should we split up the work? (I can continue to work on the incoming part, which will mostly happen in other repositories I suppose) |
be8667d
to
1c35f56
Compare
@gmbnomis I think at least this things of the outgoing part should be merged together with incoming to avoid double refactoring of the
@Koenkk this PR should be merged very quickly to avoid situations like this. |
Does this pr also require any changes to zigbee-herdman-converters? |
@Koenkk Yes, this PR totally breaks all "from Zigbee" Tuya converters. The necessary adaptations are at Koenkk/zigbee-herdsman-converters#3572. As you said before, this change is quite risky (although I tried to be as conservative as possible), as I can't test any of those converters. So you might want to merge it after releasing. Additional changes will be necessary for the documentation on how to add TuYa devices. (I plan to provide these as well, but haven't started working on those yet) This is the input side. Then there is the output (sending) side of things. @hacker-cb I am not sure if I understand your statement on the output side above. In your view, should the changes to the sending methods become part of this PR, or should this PR be merged first to get the output changes on top as quickly as possible? |
I mean that all |
I will set a reminder for 2 January, will ping you to update the zigbee-herdsman-converters pr then. |
1c35f56
to
c66ec8b
Compare
I have done the input and output side now, see also Koenkk/zigbee-herdsman-converters#3572.
done
done
I have not done this: Looking at the existing "to Zigbee" converters, the main use case will still be to send a single DP. @hacker-cb Could you have a look? Additionally, if you have a TuYa device that accepts outgoing DP commands, could you test this with a real device? (I verified that the outgoing payloads are the same, but I can't verify with a real device) |
I agree with you to keep convenience functions.
I can't test on real Tuya devices because I'm not in office till end of the NY holidays. May be @Koenkk can ask somebody else... |
@hacker-cb no rush, will merge this after new years eve. |
Also there is one more thing left to do: I wrote comment in review of the Processing all dp data in incoming message with for/foreach loop. So, @gmbnomis - what about that? |
@hacker-cb Sorry, I can't find a comment at Koenkk/zigbee-herdsman-converters#3572? |
@hacker-cb Ah, that looks like a "Pending" comment that is only visible to you. You will need to submit the review to make it visible. |
@gmbnomis, sorry, submitted, try now :) |
@gmbnomis I plan to merge everything tomorrow:
|
Although most TuYa devices send only one data point value in a data report/command, it is possible to include values for multiple data points in such a payload. Change the definitions of those receiving commands to decode all values present. Store them in the `dpValues` array. Additionally, remove the `fn` field: It is just the high byte of the length of the data buffer and isn't used by converters. **NOTE:** This breaks all existing Tuya converters using `dataResponse`, `dataReport`, or `activeStatusReport`. They need to be adapted to use the first entry of `dpValues`
Change the definitions of the sending commands to use an array of DP values. **NOTE:** This is a breaking change to the tuya library function in zigbee-herdsman-converters.
c66ec8b
to
cd133e4
Compare
Yes, all PRs are final from my point of view
Overall, there are three PRs:
(I will post the changes for the actual device needing this feature after they are merged) |
@gmbnomis merged all, big thanks for working on this! |
Although most TuYa devices send only one data point value in a data
report/command, it is possible to include values for multiple data points in
such a payload.
Extend the definitions of those receiving commands to decode all values
present. Store them in the
dpValues
array. Additionally, remove thefn
field: It is just the high byte of the length of the data buffer and isn't
used by converters.
Change the definitions of the sending commands to use an array of DP values
as well.
NOTE:
dataResponse
,dataReport
, oractiveStatusReport
. They need to be adapted to use thefirst entry of
dpValues
Closes #478