Apollon77 / ioBroker.homee

Homee Adapter for ioBroker
MIT License
14 stars 8 forks source link

Adjustment of decimal place when transmitting temperature & humidity #267

Closed knirsch1 closed 7 months ago

knirsch1 commented 7 months ago

Hi, I use the connector and have noticed that up to 3 decimal places are transferred for some sensors (temperature/humidity).

In homee the values fit with one decimal place. In the backend of the ioBroker 3 digits arrive. In the history adapter I can save the value to 1 decimal place. This is only the case with the real-time data.

Is it possible to sponsor a small update for the adapter? :) Bildschirmfoto 2024-03-01 um 19 38 43 Bildschirmfoto 2024-03-01 um 19 40 00

Apollon77 commented 7 months ago

Ok what exactly the update shopuld do? Round the very detailed values to just provide 2 decimal places also when 3 are there? :-) Does the visu component has no way to configure how to display it? Ideally the visu should take care here and not the data providing adapter, or?

knirsch1 commented 7 months ago

Yes, I find 1 or 2 digits after the decimal point sufficient for temperature and humidity values. :) The "Lovelace" visualization cannot be configured in the "Screen element" and "Entity" cards. Perhaps there are also instructions on how I can generally round these sensors in Home Assisstent. Do you have a tip? :)

Garfonso commented 7 months ago

Hi,

Since I'm the guy behind the lovelace adapter, Ingo asked me to step in. We both don't like the idea to round on the adapter level. It should be done in frontend.

In HomeAssistant it seems rounding is usually done by creating "template sensors". https://community.home-assistant.io/t/round-a-sensor-number-on-a-card/509632

The jinja template system is not supported in iobroker. But since it creates a second entity anyway, you could use the alias system in iobroker to achieve the same. Ie create an alias to the sensor state and use a read function of Math.round(val) (no digits) or Math.round(val*10)/10 for one digit and so on. Then create an entity for this state and use it for visualization.

An easier way could be using custom cards, like this one https://github.com/benct/lovelace-multiple-entity-row#formatting

Since 2023.02 there seems to be a way to round in the frontend that is yet new to me. I'll look into how to support it. If you configured the entity manually, you could try to add "attr_suggested_display_precision": 1 to the lovelace part in common.custom. But that is quite an advanced change. 😁 I'll try it later and see if it works. If so, I'll add it to the settings and it will be visible in the ui. Maybe I even set the default for that to 2 or something.

Apollon77 commented 7 months ago

Then I close here and potentially you continue in a Lovelace issue?! Thank you for your support @Garfonso