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

lib/tuya: tuyaTz.datapoints wrongly updates { state: } object #8233

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

robvanoostenrijk
Copy link
Contributor

After looking more into the behavior reported in Koenkk/zigbee2mqtt#24425, it happens only for Tuya devices and its not an error in Zigbee2MQTT itself.

Problem:

When publishing a set message with multiple properties specified, the tuzaTz.datapoints default converter fails to update the state correctly.

tuyaTz.datapoints loops through the properties in the current message (because ConverterSet is called only once.

However when it builds the state object to return it uses the key parameter of the main call, not the loop variable attr.
This causes the values to be overwritten in the state object under the same key.

For example:

{ "preset": "manual", "system_mode": "cool", "current_heating_setpoint": 27 }

Leads to state:

{ "preset": 27 }

And

{ "current_heating_setpoint": 27, "preset": "manual", "system_mode": "cool"  }

to

{ "current_heating_setpoint": "cool" }

This PR resolves the issue by correctly using the attr loop variable to build the return state.

Note: The device values were set correctly, however the state in Zigbee2MQTT did not reflect the device state due to the wrong return value.

@Koenkk Koenkk merged commit 0012650 into Koenkk:master Nov 1, 2024
2 checks passed
@Koenkk
Copy link
Owner

Koenkk commented Nov 1, 2024

Thanks!

@robvanoostenrijk robvanoostenrijk deleted the fix/tuya-datapoints branch February 4, 2025 10:03
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.

2 participants