Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'override_unit_of_measurement' configuration parameter #3

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ lovelace ui:
```

The field `entity` is required. The `unit_of_measurement` of this entity must be `W` or `kW`.
If not you can override it using the `override_unit_of_measurement` configuration parameter.

There are also several configuration parameters. Thery are not required,
but you can use it to customize the card.
Expand All @@ -47,3 +48,4 @@ but you can use it to customize the card.
| **left_icon** | [`mdi:electron-framework`](https://mdi.bessarabov.com/icon/electron-framework) | Left icon in the card |
| **right_icon** | [`mdi:home`](https://mdi.bessarabov.com/icon/home) | Right icon in the card |
| **show_line** | `false` | Showing a line between icons |
| **override_unit_of_measurement** | | Force the card to ignore the `unit_of_measurement` as provided by the entity and use this instead. Use `W` or `kW` |
2 changes: 1 addition & 1 deletion animated-consumption-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class AnimatedConsumptionCard extends HTMLElement {

if (state) {
var valueStr = state.state;
const unit_of_measurement = state.attributes.unit_of_measurement;
const unit_of_measurement = this.config.override_unit_of_measurement || state.attributes.unit_of_measurement;

if (unit_of_measurement === 'kW') {
value = valueStr * 1;
Expand Down