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

Configure decimal places for entities #492

Closed
PhillyGilly opened this issue Jan 10, 2022 · 31 comments
Closed

Configure decimal places for entities #492

PhillyGilly opened this issue Jan 10, 2022 · 31 comments
Labels
enhancement New feature or request
Milestone

Comments

@PhillyGilly
Copy link

Would it be possible to configure the number of decimal places in entity configuration or globally?
image
I've got kWh showing the nearest 0.1W and different W precisions?

@bramstroker
Copy link
Owner

Not sure why you have different precisions for the power sensors. What happens when they have a non 0 value?
Do they have similar powercalc configuration?

Why do you want different precision for the energy sensor? I don't see an issue to have this at 4 decimals.
Of course I can make it configurable, but I also want to avoid an overkill on configuration parameters when it is not necessary.

@bramstroker bramstroker added the enhancement New feature or request label Jan 10, 2022
@bramstroker
Copy link
Owner

@PhillyGilly Did you see my questions?

@PhillyGilly
Copy link
Author

Hi @bramstroker. 1. I have only seen this with zero values. 2.The powercalc sensors are cut and paste clones. 3. Two thoughts on using 4 decimal places a) the precision implies accuracy that isn't being achieved, b) I was taught that in the metric system with Greek prefixes used the maximum number of decimal places is three. So here, if we want to measure fractions of a Watt we should measure in Watts not kW. I will try to source that.

@bramstroker
Copy link
Owner

Thanks for your answer and considerations. I will have a look into the 0 and 0.00 differences. My question was about which kind of powercalc sensors are this? lut, fixed or linear mode? Than I can see if I am able to reproduce this.

About the energy sensor decimal places. There was an issue where this was discussed and changed. #104.
The precision is achieved, as you can also see in your screenshot, the individual watt hours are calculated.
I will consider to make it configurable to allow you to set your own precision.
I don't think we should change the unit from kWh to Wh as this will cause errors in the statistics for everyone, as old statistics need to change to the new unit as well to match.

@bramstroker bramstroker added this to the 0.18 milestone Feb 10, 2022
@bramstroker
Copy link
Owner

Added option to configure precision #546. Has been released in v0.18.0-beta.1

@PhillyGilly
Copy link
Author

I'll try that. Do I download specific files from the dev fork, copy into my config/subfolder and then restart HA?

@bramstroker
Copy link
Owner

Did you use HACS to install?

@PhillyGilly
Copy link
Author

PhillyGilly commented Feb 12, 2022

yes. I'm just upgrading to v0.17.0

@bramstroker
Copy link
Owner

You can click the three dots, than "redownload", and check the "Show beta versions" box.
Than you can install the master branch, or the v0.18.0-beta.2, which also contains the option to configure decimal places.

@PhillyGilly
Copy link
Author

Thanks. I wasn't aware of that option
I've added

######################
# powercalc global   #
######################
powercalc:
  scan_interval: 00:01:00 #Each minute
  energy_sensor_precision: 3

and I get
image

Which is great, but I'm still getting the power in varying precision.
The config for these sensors is:

- platform: powercalc
  entity_id: climate.bathroom_1
  name: Bathroom 1
  fixed:
    states_power:
      hvac_action|idle: 0
      hvac_action|cooling: 0
      hvac_action|heating: 160
- platform: powercalc
  entity_id: climate.bathroom_2
  name: Bathroom 2
  fixed:
    states_power:
      hvac_action|idle: 0
      hvac_action|cooling: 0
      hvac_action|heating: 160
- platform: powercalc
  entity_id: climate.bathroom_3
  name: Bathroom 3
  fixed:
    states_power:
      hvac_action|idle: 0
      hvac_action|cooling: 0
      hvac_action|heating: 160
- platform: powercalc
  entity_id: climate.garden_studio
  name: Garden Studio
  fixed:
    states_power:
      hvac_action|idle: 0
      hvac_action|cooling: 0
      hvac_action|heating: 600

So I have no idea why they display different precisions.

@bramstroker
Copy link
Owner

Yes, I only did have a look yet at the energy sensors. Nothing has changed regarding the power sensors yet.

It's a bit strange, particularly because you have similar configurations for both of them.
Could you have a look into the current states of climate.bathroom_1, climate.bathroom_2, climate.bathroom_3` entities in developer tools. Are they all the same?

@bramstroker
Copy link
Owner

I was able to reproduce some inconsistent roundings on my development instance.
Made some changes in the code to use another data type to get consistent roundings. See #553

Now all my power sensors have 2 decimals. There are 20 more which didn't fit on this screenshot.

Screenshot 2022-02-13 at 09 53 46

Has been merged into the master branch.
Are you able to test as well?

@bramstroker
Copy link
Owner

Also released in v0.18.0-beta.3

@PhillyGilly
Copy link
Author

Hi. Sure I can test beta 3 soon.
I did check the entity sates in developer tools as I wondered about the themostats having different firmware but that can't make any difference, surely? I mean its on or off times the defined constant?
image

@PhillyGilly
Copy link
Author

image
Bingo! That's spot on, thank you.

@bramstroker
Copy link
Owner

Awesome. Cool it's working as expected for you too.
I will release v0.18.0 stable somewhere next week when there are not issues reported by other users which are running the beta.

@PhillyGilly
Copy link
Author

Hi @bramstroker
I was just looking at logging energy used every day and it looks like your fix above didn't reach the utility meters?
image

@bramstroker
Copy link
Owner

I did not have a look into the utility meters. Will see if it's also possible to do for them.

@bramstroker bramstroker reopened this Mar 5, 2022
@bramstroker
Copy link
Owner

I have also added presicion for the utility meters. Are you able to test with v0.19.0-beta.1?

@PhillyGilly
Copy link
Author

That seems to have fixed the _energy (total) meters but not the _energy_daily ones. BTW there is the mini graph card that you kindly pointed out (still WIP).
image

@bramstroker
Copy link
Owner

I see you only have the issue with the sensors having exactly 0 kWh.
You are sure you are using the correct powercalc version?

This is from my development instance. I have tens of utility meters more, but just added some to lovelace dashboard.

Screenshot 2022-03-13 at 13 54 01

I also have a sensor which is 0 as you see, but that one is succesfully rounded to 0.000 kWh

@PhillyGilly
Copy link
Author

I am on v0.19.0-beta.1.
Is it possible that the meters have a zero value from when they were created under an older version and haven't moved off zero yet? I will turn them on and see what happens......

image

Well I think that answers it. I'm happy now, if you are. Thanks!

@PhillyGilly
Copy link
Author

Having said that I checked this morning and the new daily utility meters are not created with
the correct precision.
File 14-03-2022, 06 52 12

@bramstroker
Copy link
Owner

I am not sure how to fix this as I am unable to reproduce.
Do you still experience this issue with the latest version of HA and powercalc?
I think I need to close this issue as I'm unable to make any further progress and it's only esthetic issue anyway.

@PhillyGilly
Copy link
Author

Hi. I'm on 1.9.5 and latest HA core 2022.3.8. The problem is only with sensors that don't move off zero (they are in guest room). As soon as the devices switch on the correct precision is shown.

@bramstroker
Copy link
Owner

@PhillyGilly I did have another look and was able to reproduce. Should be resolved now with latest master branch. Are you able to test?

@PhillyGilly
Copy link
Author

Is that v0.19.11? I'm still seeing this:
image

@bramstroker
Copy link
Owner

No, it's not yet released. Only on master branch. You can install that by clicking reinstall in HACS and enabling the check for "beta versions".

@PhillyGilly
Copy link
Author

I misunderstood "master". I've got the right one but still looks the same
image
until the meter starts measuring then :
image

@bramstroker
Copy link
Owner

Very strange. Maybe you could try with v0.19.2 which I just issued and also contains the fix.

@PhillyGilly
Copy link
Author

That’s it! Thank you.

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

No branches or pull requests

2 participants