Olen / lovelace-flower-card

Lovelace Flower Card to match the custom plant integration

Home Page:https://github.com/Olen/homeassistant-plant/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use Entity-state-formatting

Olen opened this issue · comments

commented

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.

commented

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?

commented

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