-
-
Notifications
You must be signed in to change notification settings - Fork 36.5k
Add delta report type support for Tuya sensors #160285
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
base: dev
Are you sure you want to change the base?
Conversation
|
Hey there @tuya, @zlinoliver, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
Please rebase after the merge of the dependency bump |
Updated as requested.
I have rebased onto the latest dev branch. |
I don't think you rebased properly - as you have picked up some unlinked changes. |
c68fb71 to
014d825
Compare
- Support report_type attribute from Tuya API (sum/minux/un_known) - Implement delta value accumulation for 'sum' report type sensors - Use RestoreSensor to persist accumulated values across restarts - Add REPORT_TYPE_ENABLED_CATEGORIES for controlled feature rollout - Include report_type in diagnostics output - Bump tuya-device-sharing-sdk to 0.2.8 Supported device categories: CZ, XNYJCN, ZNDB, DLQ, TDQ, KG, PC, SFKZQ
c84fb48 to
5993b68
Compare
Co-authored-by: epenet <[email protected]>
Breaking change
None
Proposed change
This PR adds support for the
report_typeattribute from the Tuya API to properly handle different energy reporting mechanisms.Background: Some Tuya devices report energy consumption as incremental deltas (
sumtype) rather than cumulative totals (minuxtype). Without proper handling, these delta values would be displayed directly, resulting in incorrect energy readings (e.g., showing 0.1 kWh repeatedly instead of accumulating to the actual total).Implementation:
report_typefrom Tuya API (sum,minux,un_known)sum(delta) type sensors: accumulate incremental values locally and persist across restarts usingRestoreSensorminux(cumulative) type sensors: use the value directly asTOTAL_INCREASINGdp_timestampsto prevent double-countingREPORT_TYPE_ENABLED_CATEGORIESSupported device categories: CZ (Socket), XNYJCN (Solar Inverter), ZNDB (Circuit Breaker), DLQ (Leakage Protector), TDQ (Switch with Metering), KG (Switch), PC (Power Strip), SFKZQ (Third Party Gateway)
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.Dependency update:
tuya-device-sharing-sdk0.2.7 → 0.2.8 (addsreport_typeattribute toDeviceStatusRange)To help with the load of incoming pull requests: