animated-consumption-card icon indicating copy to clipboard operation
animated-consumption-card copied to clipboard

Add unit_of_measurement setting

Open stast1 opened this issue 4 years ago • 8 comments

Hello! Is it possible to add a setting for units of measure, for example in Russian - 'Вт' and 'кВт'?

stast1 avatar May 22 '20 07:05 stast1

Can you please add additional details of what you need.

Do you have a sensor in Home Assistant that has unit Вт/кВт:

sensor:
  - platform: template
    sensors:
      total_power_consumption:
        unit_of_measurement: Вт
        ....

Or the sensor in Home Assistant has unit_of_measurement kWh/W, but you want to this card to display text in russian language in this card?

Screenshot 2020-05-22 at 11 28 35

If you want to change the text in the card I have one more question. Is is ok if there is no additional settings in the card, but the card just uses the language of Home Assistant interface.

bessarabov avatar May 22 '20 08:05 bessarabov

Привет! Я на русском буду, так проще, знаю Вас по каналу в телеграмм. У меня весь интерфейс на русском. И датчик входной мощности в ваттах (Вт). Для Вашей карты пришлось сделать template sensor в kW. Оно конечно работает, но это лишний сенсор. Ну и картинка с kW тоже выделяется на фоне остального интерфейса:

image

Если бы в настройках карточки можно было настраивать единицу измерения - это бы решило проблему.

stast1 avatar May 22 '20 08:05 stast1

К языку интерфейса привязываться наверное неправильно. Не у всех пользователей в русском интерфейсе единицы измерения тоже русские.

stast1 avatar May 22 '20 08:05 stast1

Спасибо за пояснение. Все понятно. Я согласен что должна быть возможность работать с карточкой и без создания отдельного сенсора с нужными unit_of_measurement.

Я доработаю эту карточку, чтобы вы смогли убрать дополнительный сенсор. (но ничего не могу сказать про сроки решения этой задачи)

bessarabov avatar May 22 '20 09:05 bessarabov

Ок, спасибо!

stast1 avatar May 22 '20 09:05 stast1

Hi, I would second this change. I do have a sensor that has an unit of measurement of something else, in this case Watt instead of W. I know I can use templates and exclude that sensor from the recorder, but preferably I do not want to add to the already rather huge list of entities that are available. I could always see if the integration can fix this, as W might be more future-proof.

What's your take on it?

SerhatG avatar Jun 11 '20 09:06 SerhatG

@SerhatG I will definitely update this card and make it possible to work with any unit of measurement (I'm sorry but I can't say the exact date when it is ready) After that this card will work with your Watt sensor.

bessarabov avatar Jun 11 '20 09:06 bessarabov

@bessarabov I don't mind taking a crack at it and contribute. What did you have in mind? Simply adding Watt to the list of units or assuming everything is W and therefor kW is the only special unit. Something else?

[EDIT] I added a possible solution in PR #3 . Let me know if you want to take a different approach.

SerhatG avatar Jun 11 '20 12:06 SerhatG