Skip to content

Commit 8b5383f

Browse files
committed
fix: update attribute access to use optional chaining for safer property retrieval
1 parent d2c8eae commit 8b5383f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/landroid-card.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
stateIcon,
66
} from 'custom-card-helpers'; // computeStateDisplay,
77
import registerTemplates from 'ha-template';
8-
import get from 'lodash.get';
8+
// import get from 'lodash.get';
99
import localize from './localize';
1010
import styles from './styles';
1111
import defaultImage from './landroid.svg';
@@ -775,9 +775,13 @@ class LandroidCard extends LitElement {
775775
}
776776

777777
try {
778+
// Usinglodash.get;
779+
// const value = entity_id
780+
// ? this.hass.states[entity_id].state
781+
// : get(this.entity.attributes, attribute);
778782
const value = entity_id
779783
? this.hass.states[entity_id].state
780-
: get(this.entity.attributes, attribute);
784+
: this.entity?.attributes?.[attribute];
781785

782786
return html`
783787
<div

0 commit comments

Comments
 (0)