Skip to content

Commit

Permalink
feat: Add optional name parameter as label
Browse files Browse the repository at this point in the history
  • Loading branch information
Sese-Schneider committed Mar 6, 2023
1 parent c63427e commit d58d213
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A simple card which displays energy usage details of one or multiple entities.
- Variable amount of monitoring entities
- Voltage, Current, Power, Frequency and Power Factor display
- Automatic unit of measurement detection
- Adjustable colors, labels and icons
- Adjustable names, colors, labels and icons
- Configurable dynamic animations adapting to power usage

*Three-phase power monitoring example:*
Expand Down Expand Up @@ -50,6 +50,7 @@ Direct configuration via YAML is also available. For details see below.
| current | state entity | *Optional* | State entity for current | |
| frequency | state entity | *Optional* | State entity for frequency | |
| power_factor | state entity | *Optional* | State entity for power_factor | |
| name | string | *Optional* | Name label | |
| icon_leading | string | *Optional* | Leading MD icon | `mdi:transmission-tower` |
| icon_trailing | string | *Optional* | Trailing MD icon | `mdi:home-lightning-bolt` |
| label_leading | string | *Optional* | Leading label | |
Expand Down
2 changes: 2 additions & 0 deletions src/energy-overview-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export class EnergyOverviewCard extends LitElement {
frequency_unit: this._extractUnit(entity.frequency, UnitOfFrequency.HERTZ),
power_factor: entity.power_factor ? states[entity.power_factor].state : undefined,
power_factor_unit: this._extractUnit(entity.power_factor, ''),
name: entity.name ? entity.name : '',
color: entity.color ? entity.color : 'var(--energy-grid-consumption-color)',
label_trailing: entity.label_trailing ? entity.label_trailing : '',
label_leading: entity.label_leading ? entity.label_leading : '',
Expand Down Expand Up @@ -208,6 +209,7 @@ export class EnergyOverviewCard extends LitElement {
<!--suppress CssUnresolvedCustomProperty -->
<div class="entity entity-${i}"
style="--energy-line-color: ${entity.color};">
${entity.name ? html`<span class="primary name">${entity.name}</span>` : ''}
<div class="metadata">
${entity.current || entity.voltage || entity.frequency ? html`
<div class="metadata-left">
Expand Down
1 change: 1 addition & 0 deletions src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const ENTITY_DATA_SCHEMA = [
];

export const ENTITY_VISUALS_SCHEMA = [
{name: "name", selector: {text: {}}},
{
type: "grid",
name: "",
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface EnergyOverviewEntity {
voltage?: string;
frequency?: string;
power_factor?: string;
name?: string;
label_trailing?: string;
label_leading?: string;
icon_trailing?: string;
Expand Down

0 comments on commit d58d213

Please sign in to comment.