Skip to content

Commit

Permalink
Clean up toggle check usage (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
benct committed Mar 29, 2021
1 parent a01197e commit 9838e33
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 2 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { handleClick, secondsToDuration } from 'custom-card-helpers';
import { checkEntity, entityName, entityStateDisplay, entityStyles, entityUnit, entityValue } from './entity';
import {
getEntityIds,
hasConfigOrEntitiesChanged,
hasGenericSecondaryInfo,
hasToggle,
isObject,
hideUnavailable,
} from './util';
import { getEntityIds, hasConfigOrEntitiesChanged, hasGenericSecondaryInfo, isObject, hideUnavailable } from './util';
import { style } from './styles';

const LitElement =
Expand Down Expand Up @@ -125,7 +118,7 @@ class MultipleEntityRow extends LitElement {
}

renderValue(stateObj, config) {
if (hasToggle(stateObj, config)) {
if (config.toggle === true) {
return html`<ha-entity-toggle .stateObj="${stateObj}" .hass="${this._hass}"></ha-entity-toggle>`;
}
if (config.format) {
Expand Down
2 changes: 0 additions & 2 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export const hideUnavailable = (stateObj, config) =>
config.hide_unavailable &&
(isUnavailable(stateObj) || (config.attribute && stateObj.attributes[config.attribute] === undefined));

export const hasToggle = (stateObj, config) => config.toggle === true;

export const hasGenericSecondaryInfo = (config) => typeof config === 'string' && SECONDARY_INFO_VALUES.includes(config);

export const getEntityIds = (config) =>
Expand Down

0 comments on commit 9838e33

Please sign in to comment.