jcwillox / lovelace-paper-buttons-row

Adds highly configurable buttons that use actions and per-state styling.
MIT License
273 stars 10 forks source link

[feature] Provide usage of entity unit_of_measurement #80

Open Masterz69 opened 2 years ago

Masterz69 commented 2 years ago

F.e. by adding to layout configuration 'units', which will be entity attribute unit_of_measurement, prefixed with space symbol.

jcwillox commented 2 years ago

For the time being, you can manually add units using a simple template, or even automatically using Jinja2 templates.

- entity: sensor.top_fuel_station
  layout: state
  state:
    postfix: " ¢/L"
Masterz69 commented 2 years ago

Tried to use template in postfix - it not working, imho.

                    - entity: sensor.sns_boiler_out
                      layout: state
                      state:
                        postfix: "{{ state_attr('sensor.sns_boiler_out', 'unit_of_measurement') }}"

produce image

CharlesCage commented 1 year ago

@Masterz69 Templates don't work within cards. However, you do have a couple of additional HACS-available cards that can help. Personally, I've been using custom-template-card in combination with paper-buttons-row to do this kind of thing. (custom-template-card uses javascript instead of jinja2, but it's easy enough to figure out). I have samples if they'd help.

That said, I fully support your request for an enhancement to allow inclusion of units, both to simply allow them to (optionally) be displayed and also to allow separate style control of them.

Numerous times I've wished I could include the unit, but at, say, a smaller font size. Seems like a pretty common UI trope.