Pirate-Weather / pirate-weather-ha

Replacement for the default Dark Sky Home Assistant integration using Pirate Weather
https://pirateweather.net/
Apache License 2.0
367 stars 24 forks source link

Configurable number of decimal places for precip_accumulation entities #192

Closed DeltaNu1142 closed 2 months ago

DeltaNu1142 commented 8 months ago

Describe the feature

There is currently a feature to round values to the nearest integer. More precision is preferable, but the entity values for my precip_accum* sensors are currently delivered out to 11 decimal places. This is far too many, and none of the weather cards I'm using will truncate or round those values to x.x or x.xx.

Home Assistant version

2024.2.1

Integration version

1.4.3

Acknowledgements

cloneofghosts commented 8 months ago

In the 1.4.2 release I added suggested_display_precision to all the sensors and for the precipitation accumulation sensor I set it to only have 4 decimal places. When I look at the sensor in my HA I see the following:

When you look at the sensor in your HA install is it rounded to 4 decimal places or does it show all 11 decimal places? Starting in 2023.3 you are able to change the display precision for each sensor individually which should solve your issue here.

DeltaNu1142 commented 8 months ago

I've actually made some precision changes to some of those PW sensors using the drop-down in the Entity settings UI... to no effect. The entity state remains in its full, extended value.

Have a look at the attachments...

Thanks! [image: Entity State.png][image: Lovelace.png][image: Entity Settings.png]

On Mon, Feb 12, 2024 at 11:39 AM Kev @.***> wrote:

In the 1.4.2 release I added suggested_display_precision to all the sensors and for the precipitation accumulation sensor I set it to only have 4 decimal places. When I look at the sensor in my HA I see the following: image.png (view on web) https://github.com/Pirate-Weather/pirate-weather-ha/assets/10248058/26c3a4a9-d866-48f8-a77e-082145f5cf46

When you look at the sensor in your HA install is it rounded to 4 decimal places or does it show all 11 decimal places? Starting in 2023.3 https://www.home-assistant.io/blog/2023/03/01/release-20233/#sensor-display-precision you are able to change the display precision for each sensor individually which should solve your issue here.

— Reply to this email directly, view it on GitHub https://github.com/Pirate-Weather/pirate-weather-ha/issues/192#issuecomment-1939114002, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASNXDRRU6MG4JLJEUBAZKQLYTJAU5AVCNFSM6AAAAABDEY4XIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZZGEYTIMBQGI . You are receiving this because you authored the thread.Message ID: @.***>

cloneofghosts commented 8 months ago

The images you included didn't attach to your post.

DeltaNu1142 commented 8 months ago

Ah; try this:

https://imgur.com/a/oe0wQYA

I've gone through and set every precip_accum* entity to a precision of x.x and restarted HA. This is the result.

On Mon, Feb 12, 2024 at 12:03 PM Kev @.***> wrote:

The images you included didn't attach to your post.

— Reply to this email directly, view it on GitHub https://github.com/Pirate-Weather/pirate-weather-ha/issues/192#issuecomment-1939154416, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASNXDRW4HRY5XP6FCRBOJYTYTJDKBAVCNFSM6AAAAABDEY4XIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZZGE2TINBRGY . You are receiving this because you authored the thread.Message ID: @.***>

cloneofghosts commented 8 months ago

That link worked thanks. As far as I can tell that option doesn't actually change the value of the sensors which is why the 2nd and 3rd screenshots still show the sensor with 11 decimal places.

What is the weather card you are using in your third screenshot? It's possible that it hasn't been updated to take advantage of the option to change the display precision in HA.

DeltaNu1142 commented 8 months ago

I'm using the Platinum Weather Card, and you're probably right... it likely isn't using the precision attribute. Or, maybe it's not an attribute, but in any case it doesn't change how the sensors are displayed.

On Mon, Feb 12, 2024 at 12:58 PM Kev @.***> wrote:

That link worked thanks. As far as I can tell that option doesn't actually change the value of the sensors which is why the 2nd and 3rd screenshots still show the sensor with 11 decimal places.

What is the weather card you are using in your third screenshot? It's possible that it hasn't been updated to take advantage of the option to change the display precision in HA.

— Reply to this email directly, view it on GitHub https://github.com/Pirate-Weather/pirate-weather-ha/issues/192#issuecomment-1939252282, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASNXDRQVRF6ZZJUTO7ABDCTYTJJ5ZAVCNFSM6AAAAABDEY4XIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZZGI2TEMRYGI . You are receiving this because you authored the thread.Message ID: @.***>

cloneofghosts commented 8 months ago

That weather card hasn't been updated since December 2022 which is before the precision attribute was added to HA.

There was code before which should have rounded the sensors to specific number of decimals but it didn't seem to work but maybe it could be looked into and see if it could start working, There's also another issue where the integration is always using scientific units and then they get converted into local units. I remember seeing that it used to not always be that way but it was causing some issues.

Either way I'll ping @alexander0042 to see what the options for this are.

DeltaNu1142 commented 8 months ago

I appreciate you digging into this, thanks.

On Mon, Feb 12, 2024 at 2:00 PM Kev @.***> wrote:

That weather card hasn't been updated since December 2022 which is before the precision attribute was added to HA.

There was code before which should have rounded the sensors to specific number of decimals but it didn't seem to work but maybe it could be looked into and see if it could start working, There's also another issue where the integration is always using scientific units and then they get converted into local units. I remember seeing that it used to not always be that way but it was causing some issues.

Either way I'll ping @alexander0042 https://github.com/alexander0042 to see what the options for this are.

— Reply to this email directly, view it on GitHub https://github.com/Pirate-Weather/pirate-weather-ha/issues/192#issuecomment-1939349598, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASNXDRVT6A63SLLXFHRJZHTYTJQ4NAVCNFSM6AAAAABDEY4XIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZZGM2DSNJZHA . You are receiving this because you authored the thread.Message ID: @.***>

cloneofghosts commented 8 months ago

I've released a 1.4.4 beta version which should hopefully fix the issue with the ridiculous number of decimal places you're seeing with the sensors. It's not configurable at the moment but it's setup so that if rounding is enabled the precipitation related sensors show two decimal places and all other sensors have no decimal places.

Let me know if this fixes the issue for you and maybe @alexander0042 could set something up for the next big release after V2 of the API has been released.

DeltaNu1142 commented 8 months ago

I've just installed the beta--visually, much better, although now instead of 11 digits after the decimal, the precip_accum* sensors are showing 4 digits after the decimal (rather than two). Vast improvement, in any case. Thank you.

On Wed, Feb 14, 2024 at 1:21 PM Kev @.***> wrote:

I've released a 1.4.4 beta version which should hopefully fix the issue with the ridiculous number of decimal places you're seeing with the sensors. It's not configurable at the moment but it's setup so that if rounding is enabled the precipitation related sensors show two decimal places and all other sensors have no decimal places.

Let me know if this fixes the issue for you.

— Reply to this email directly, view it on GitHub https://github.com/Pirate-Weather/pirate-weather-ha/issues/192#issuecomment-1944365580, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASNXDRX6XA4H74465GCQIPDYTT6BLAVCNFSM6AAAAABDEY4XIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBUGM3DKNJYGA . You are receiving this because you authored the thread.Message ID: @.***>

cloneofghosts commented 8 months ago

Do you have rounding enabled or disabled? If it's enabled it should be showing 2 decimal places instead of 4. If it's not showing 2 decimal places I'll have to debug to see what's going on.

DeltaNu1142 commented 8 months ago

It was showing 4 digits with rounding disabled; I've enabled rounding and it is showing 2 digits.

On Wed, Feb 14, 2024 at 2:25 PM Kev @.***> wrote:

Do you have rounding enabled or disabled? If it's enabled it should be showing 2 decimal places instead of 4. If it's not showing 2 decimal places I'll have to debug to see what's going on.

— Reply to this email directly, view it on GitHub https://github.com/Pirate-Weather/pirate-weather-ha/issues/192#issuecomment-1944453266, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASNXDRS4NJHVBWPGWLSFKH3YTUFRRAVCNFSM6AAAAABDEY4XIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBUGQ2TGMRWGY . You are receiving this because you authored the thread.Message ID: @.***>

cloneofghosts commented 8 months ago

Good to know that it's working for you. I created a PR to merge this in so hopefully it can be reviewed so it can be merged in soon.

If I knew more about HA I could take a stab at trying to make it configurable but alas I don't nor do I have a dev machine setup for this sort of stuff. @alexander0042 is the one who created the integration and knows more about this sort of stuff so I'll leave it to him to set this up. I can do smaller-scale changes which I've done before to fix other issues that have cropped up.

cloneofghosts commented 6 months ago

Haven't forgotten about this! I finally got a devcontainer setup and working so I should be able to take a stab at this soon (if nobody else beats me to it).

I was thinking along the lines of having two sliders - one for the data points which are rounded to 2 decimal points and one for the ones which are rounded to 4 decimal points or do you have a different suggestion.

github-actions[bot] commented 3 months ago

There has been no activity on this issue in the last ninety days and will automatically close in seven days. Leave a comment on this issue to prevent it from closing automatically.

github-actions[bot] commented 2 months ago

This issue has been automatically closed since there has been no further activity after seven days and will be automatically locked in sixty days. Feel free to re-open this issue or you can create a follow-up issue