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

Request: decimal place configuration #142

Open
melvanderwal opened this issue Feb 17, 2023 · 4 comments
Open

Request: decimal place configuration #142

melvanderwal opened this issue Feb 17, 2023 · 4 comments

Comments

@melvanderwal
Copy link

melvanderwal commented Feb 17, 2023

It would be nice to be able to round kW text to a selected number of decimal places within the icon bubbles. This would mitigate overlap with the bubble perimeter and would increase readability. Could be universal, or perhaps per-device would let people choose more detail for specific devices when it is logical. For myself, I don't need to see more than 1 decimal. I do like the auto-display where it drops trailing zeroes from the number - perhaps a max number of digits following the decimal point would be an option?

Thanks very much for this card - I've been able to clean up so much clutter from gauges and glance cards into a clean, intuitive UX. It was simple to adjust the Power Wall sample code to a Goodwe inverter.

@djfanatix
Copy link

Yes one up for this!
Since HA 2023.3, decimals are configured in the UI, and some are messed up. (such as my battery %)

@PierreScerri
Copy link

That would be nice. It would save having duplicate template sensors.

@melvanderwal
Copy link
Author

melvanderwal commented Mar 7, 2023

I figured out something that works for me - rounding the APF xxxx Entities to the nearest 100 Watts. In the card, the entity is then shown as an integer when it is watts, and to 1 decimal place when it is kilowatts (and maintains the trimming of the trailing zero, like the grid entity shown below). You could similarly round to 10 Watts or 1000 Watts for different levels of decimal precision.
e.g. For the APF House Entity:
state: "{{ (states('sensor.load')|float / 100)|round(0) * 100 }}"

Would still be handy to do it via the config, but this also works.

image

@mkanet
Copy link

mkanet commented Nov 1, 2023

I figured out something that works for me - rounding the APF xxxx Entities to the nearest 100 Watts. In the card, the entity is then shown as an integer when it is watts, and to 1 decimal place when it is kilowatts (and maintains the trimming of the trailing zero, like the grid entity shown below). You could similarly round to 10 Watts or 1000 Watts for different levels of decimal precision. e.g. For the APF House Entity: state: "{{ (states('sensor.load')|float / 100)|round(0) * 100 }}"


@melvanderwal I hope you're still watching this thread. Could you please do me a huge favor and copy and paste all your template sensors related to tesla-style-solar-power-card as
tesla-style-solar-power-card lovelace code?

I think something must have changed in Home Assistant or the Integration to make your example not correct anymore. When I use your example above, all my AFP values show as 0. It looks like your suggested code is presuming that my tesla powerwall Entities are in Watts. They are actually in Kilowatts for me.

Below are my template sensors:

      - name: APF Grid Entity
        device_class: power
        state_class: measurement
        unit_of_measurement: W
        state: "{{ ((0 - states('sensor.powerwall_site_power')|float * 1000) / 100)|round(0) * 100 }}"
      - name: APF House Entity
        device_class: power
        state_class: measurement
        unit_of_measurement: W
        state: "{{ (states('sensor.powerwall_load_power')|float * 1000 / 100)|round(0) * 100 }}"
      - name: APF Generation Entity
        device_class: power
        state_class: measurement
        unit_of_measurement: W
        state: "{{ (states('sensor.powerwall_solar_power')|float * 1000 / 100)|round(0) * 100 }}"
      - name: APF Battery Entity
        device_class: power
        state_class: measurement
        unit_of_measurement: W
        state: "{{ ((0 - states('sensor.powerwall_battery_power')|float * 1000) / 100)|round(0) * 100 }}"
      - name: APF Grid Import
        device_class: power
        state_class: measurement
        unit_of_measurement: W
        state: >
          {% if states('sensor.apf_grid_entity')|int(default=0) < 0 %}
            {{ states('sensor.apf_grid_entity')|int(default=0)|abs }}
          {% else %}
            0
          {% endif %}

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

No branches or pull requests

4 participants