Olen / lovelace-flower-card

Lovelace Flower Card to match the custom plant integration
https://github.com/Olen/homeassistant-plant/
196 stars 31 forks source link

Use Entity-state-formatting #42

Open Olen opened 1 year ago

Olen commented 1 year ago

Replace hard coded labels and units of measurement with https://developers.home-assistant.io/docs/frontend/data#entity-state-formatting

This allows us to simplify the WS data and ensures consistent values.

Olen commented 1 year ago

Should be able to do something like

      var displayVal = hass.formatEntityState(hass.states[sensor[attr]]);

Around line 305. But as we hide the unit on small screens, we would need to split the unit from the number and do some various validations anyway, so maybe this is not really feasible. After all, the WS sends the info from the sensor, so it should be correct. Although #39 could possibly be fixed by this? Are there other ways to get precision for a sensor from the hass-object?

Olen commented 7 months ago

Partial fix in the latest beta. Precision is now fetched gtom formatEntityState, but unit is still fetched from the WS-request.