joBr99 / nspanel-lovelace-ui

Custom Firmware for NsPanel with the design of HomeAssistant's lovelace UI in mind, works with Tasmota.
GNU General Public License v3.0
891 stars 190 forks source link

[Feature Request] Possibility to define precision of displayed sensors #284

Closed ivdimitro closed 2 years ago

ivdimitro commented 2 years ago

Describe the solution you'd like I have some temperature sensors which display temperature with two digits after the decimal point. When added on a grid card the last digit is not fully rendered in the grid slot. (see the attachment) I would like to be possible to define the accuracy of the sensor or automatically round the number.

Additional context I know it is possible to create new sensor which copies the values from my sensors and reduce the accuracy in HA but this seems like clunkier solution.

Panel / Firmware Version 3.0 EU PXL_20220614_075827130

joBr99 commented 2 years ago

I guess it should be enough to change the cap of maximum chars for this page. More than 4 chars won't fit there anyways.

https://github.com/joBr99/nspanel-lovelace-ui/blob/a9576adf2f782777e8fa0752878830b86d1ead39/apps/nspanel-lovelace-ui/luibackend/pages.py#L237

joBr99 commented 2 years ago

I changed it to 4 chars and released the change with v3.0.5

ivdimitro commented 2 years ago

Hi, the fix will not work in all cases. I have a "navigation" entity in the grid and the number is shown via sensor status:

       - entity: navigate.cardThermo_bathRad
            status: sensor.bath_rad_air_temperature
            name: bathroom

I saw in the code that you are reducing the number of displayed chars only in the case when the sensor is the grid item directly:

if cardType == "cardGrid" and entityType == "sensor":

I think you should add "or entityType == "navigation"

joBr99 commented 2 years ago

this change should help, can you give this a try

https://github.com/joBr99/nspanel-lovelace-ui/commit/2b252d4327ed7d197341e5b40f072d261ae6026a

ivdimitro commented 2 years ago

Hi, I tested the change and it fixed the issue with navigate items. I would prefer the keep the number of chars to 4. Otherwise if the limit is 3 and you have only one digit after the dot it removes it and we lose precision.

Even if you have a number with 4 digits it displays correctly. PXL_20220615_221901421

The position of the decimal dot doesn't make difference. PXL_20220615_222829864

joBr99 commented 2 years ago

Wdym? the limit should be 4 chars, never changed it to 3 (only if the last char is an dot)

ivdimitro commented 2 years ago

At least in patch you included above the char limit is 3. Maybe a typo. image

joBr99 commented 2 years ago

I guess you are right, decreased the limit from 4 to 3 on you initial message, wasn't aware that this was only an issue on navigate items, try to download main in HACS and restart AppDeamon, should be fixed.

ivdimitro commented 2 years ago

Now it is OK. Thanks.