Skip to content

Commit

Permalink
feat: add secondary decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
flixlix committed Jun 13, 2023
1 parent 2446b6e commit e20a2bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/energy-flow-card-plus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ export default class EnergyFlowCardPlus extends SubscribeMixin(LitElement) {
icon: entities.grid?.secondary_info?.icon,
unit: entities.grid?.secondary_info?.unit_of_measurement,
unit_white_space: entities.grid?.secondary_info?.unit_white_space,
decimals: entities.grid?.secondary_info?.decimals,
energyDateSelection: entities.grid?.secondary_info?.energy_date_selection || false,
color: {
type: entities.grid?.secondary_info?.color_value,
Expand All @@ -458,6 +459,7 @@ export default class EnergyFlowCardPlus extends SubscribeMixin(LitElement) {
state: initialSecondaryState,
icon: entities.solar?.secondary_info?.icon,
unit: entities.solar?.secondary_info?.unit_of_measurement,
decimals: entities.solar?.secondary_info?.decimals,
unit_white_space: entities.solar?.secondary_info?.unit_white_space,
energyDateSelection: entities.solar?.secondary_info?.energy_date_selection || false,
},
Expand Down Expand Up @@ -537,6 +539,7 @@ export default class EnergyFlowCardPlus extends SubscribeMixin(LitElement) {
unit: entities[field]?.secondary_info?.unit_of_measurement,
unit_white_space: entities[field]?.secondary_info?.unit_white_space,
displayZero: entities[field]?.secondary_info?.display_zero,
decimals: entities[field]?.secondary_info?.decimals,
displayZeroTolerance: entities[field]?.secondary_info?.display_zero_tolerance,
energyDateSelection: entities[field]?.secondary_info?.energy_date_selection || false,
},
Expand Down Expand Up @@ -1125,7 +1128,7 @@ export default class EnergyFlowCardPlus extends SubscribeMixin(LitElement) {
className: key,
entityId: field.secondary.entity,
icon: field.secondary.icon,
value: this.displayValue(field.secondary.state, field.secondary.unit, field.secondary.unit_white_space),
value: this.displayValue(field.secondary.state, field.secondary.unit, field.secondary.unit_white_space, field?.secondary?.decimals),
})}`
: ''}`;
};
Expand Down
3 changes: 2 additions & 1 deletion src/ui-editor/schema/_schema-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ export const secondaryInfoSchema = [
{ name: 'unit_of_measurement', label: 'Unit of Measurement', selector: { text: {} } },
{ name: 'color_value', label: 'Color Value', selector: { boolean: {} } },
{ name: 'unit_white_space', label: 'Unit White Space', selector: { boolean: {} } },
{ name: 'display_zero', label: 'Display Zero', selector: { boolean: {} } },
{ name: 'display_zero_tolerance', label: 'Display Zero Tolerance', selector: { number: { mode: 'box', min: 0, max: 1000000, step: 0.1 } } },
{ name: 'decimals', label: 'Decimals', selector: { number: { mode: 'box', min: 0, max: 10, step: 1 } } },
{ name: 'display_zero', label: 'Display Zero', selector: { boolean: {} } },
{ name: 'energy_date_selection', label: 'Energy Date Selection', selector: { boolean: {} } },
],
},
Expand Down

0 comments on commit e20a2bd

Please sign in to comment.