Skip to content

Comments

Update default precision for instantaneous demand + current#624

Merged
TheJulianJES merged 3 commits intozigpy:devfrom
TheJulianJES:tjj/sensors_update_precision
Feb 25, 2026
Merged

Update default precision for instantaneous demand + current#624
TheJulianJES merged 3 commits intozigpy:devfrom
TheJulianJES:tjj/sensors_update_precision

Conversation

@TheJulianJES
Copy link
Contributor

@TheJulianJES TheJulianJES commented Jan 14, 2026

This updates the suggested display precision for the instantaneous demand entity and the RMS current entity.

The instantaneous demand entity then aligns with the EM active power entities (suggested precision 1).
The RMS current entity uses suggested precision 2 to not cut off low-power draw devices, often attached to smart plugs. HA would already use 2 by default, but we currently override this to 1 in the Base EM sensor class, which is not ideal.

@codecov
Copy link

codecov bot commented Jan 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.49%. Comparing base (6dcd547) to head (f4e05de).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #624   +/-   ##
=======================================
  Coverage   97.49%   97.49%           
=======================================
  Files          62       62           
  Lines       10917    10919    +2     
=======================================
+ Hits        10643    10645    +2     
  Misses        274      274           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheJulianJES
Copy link
Contributor Author

TL;DR: IMO we should merge this now but go through all EM related sensors and see if the HA defaults are better at a later date.


I think both changes make sense. We set _attr_suggested_display_precision = 1 in the base EM class. We should reevaluate doing that, since HA has better defaults depending on device class + unit.

For current, it would already use 2 decimals, but due to the EM base class, it's set to 1. So we just fix it to 2 decimals, just for current now.
I don't want to unintentionally affect a bunch of entities by setting everything to None and letting HA use its defaults (at the moment). That wouldn't show up in our diagnostics. I'll reevaluate all these suggested precisions in the future.

For instantaneous demand, HA uses 0 decimals currently. That seems too little, as a lot of smart plugs offer higher resolution than that. I guess that's why we also set it to 1 for all EM entities. So to match that, it's set to 1 in this PR.

@TheJulianJES TheJulianJES marked this pull request as ready for review February 24, 2026 23:56
@TheJulianJES TheJulianJES force-pushed the tjj/sensors_update_precision branch from d1d7ca8 to f4e05de Compare February 25, 2026 01:26
@TheJulianJES
Copy link
Contributor Author

Merging this per the above comment. It's better aligned with HA standards and existing power sensors.

@TheJulianJES TheJulianJES merged commit df5fe2f into zigpy:dev Feb 25, 2026
7 checks passed
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.

1 participant