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

feat: Add currency symbol position option to power consumption chip #1534

Closed
wants to merge 3 commits into from
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ chip_power_consumption:
triggers_update:
- "[[[ return variables.ulm_chip_electric_price ]]]"
- "[[[ return variables.ulm_chip_electric_consumption ]]]"
variables:
ulm_chip_electric_currency_symbol_first: false
label: |
[[[
var amount = variables.ulm_chip_electric_price != "" ? true : false
if (amount){
return "⚡ " + states[variables.ulm_chip_electric_price].state + variables.ulm_translation_currency;
var amount = variables.ulm_chip_electric_price != "" ? true : false;
var symbol_before = variables.ulm_chip_electric_currency_symbol_first === true;

if (amount) {
var price = states[variables.ulm_chip_electric_price].state + variables.ulm_translation_currency;
return "⚡ " + (symbol_before ? variables.ulm_translation_currency + states[variables.ulm_chip_electric_price].state : states[variables.ulm_chip_electric_price].state + variables.ulm_translation_currency);
} else {
return "⚡ " + helpers.localize(states[variables.ulm_chip_electric_consumption]);
return "⚡ " + helpers.localize(states[variables.ulm_chip_electric_consumption]);
}
]]]
1 change: 1 addition & 0 deletions docs/usage/chips/chip_power_consumption.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This `chip` shows you the electric consumption from a sensor. Configurable to sh
|----------|---------|------------------|-------------------|
| ulm_chip_electric_consumption | | :material-check: | Variable / Entry Example Required ulm_chip_electric_consumption sensor.my_electric_power_consumption true. This is your consumed energy. This is the sensor, that shows how many *kWh*s are consumed. |
|ulm_chip_electric_price| | :material-check: | This is the price for your consumed energy, if you have such a sensor. This should be a sensor that shows a price in your defined currency. If this variable is not set, the chip shows only the *kWh*s! If this variable is set the chip shows the price for the consumed energy! |
ulm_chip_electric_currency_symbol_first | false | :material-close: | Determines whether the currency symbol (€, $, £ etc) is shown before the price for the energy consumed. For example, when set to true the chip shows €0.19. |

## Usage

Expand Down
Loading