Skip to content

Commit

Permalink
Merge pull request #695 from brunosabot/fix/allow-data-set-to-0
Browse files Browse the repository at this point in the history
fix: 0 is a valid attributes, state or last change
  • Loading branch information
Clooos authored Aug 10, 2024
2 parents d3a1cd8 + 2a66082 commit c4ab799
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/tools/global-changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,13 @@ export function changeSubButtonState(context, container = context.content, appen
// Build the displayed state string
let displayedState = '';
const formattedState = state && showState ? context._hass.formatEntityState(state) : '';
const formattedAttribute = state && attribute && showAttribute ? context._hass.formatEntityAttributeValue(state, attributeType) ?? attribute : '';
const formattedAttribute = state && attribute !== '' && showAttribute ? context._hass.formatEntityAttributeValue(state, attributeType) ?? attribute : '';
const formattedLastChanged = state && showLastChanged ? formatDateTime(state.last_changed, context._hass.locale.language) : '';

if (showName && name) displayedState += name;
if (formattedState) displayedState += (displayedState ? ' · ' : '') + formattedState;
if (formattedLastChanged) displayedState += (displayedState ? ' · ' : '') + formattedLastChanged;
if (formattedAttribute) displayedState += (displayedState ? ' · ' : '') + formattedAttribute;
if (showName && name !== '') displayedState += name;
if (formattedState !== '') displayedState += (displayedState ? ' · ' : '') + formattedState;
if (formattedLastChanged !== '') displayedState += (displayedState ? ' · ' : '') + formattedLastChanged;
if (formattedAttribute !== '') displayedState += (displayedState ? ' · ' : '') + formattedAttribute;

displayedState = displayedState.charAt(0).toUpperCase() + displayedState.slice(1);

Expand Down

0 comments on commit c4ab799

Please sign in to comment.