Skip to content

Commit f696821

Browse files
committed
fix: hide attribute if null
1 parent 6417b94 commit f696821

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/entity-helper.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ export const extractAttributes = (
5959
if (item.attributes.hasOwnProperty(c.value)) {
6060
const attributeValue = item.attributes[c.value];
6161
if (attributeValue === null) {
62-
const attributeName = hass.formatEntityAttributeName ? hass.formatEntityAttributeName(item, c.value) : c.value;
63-
p.push({
64-
name: c.label ? c.label : attributeName,
65-
value: 'null',
66-
});
6762
return p;
6863
}
6964
if (typeof attributeValue === 'object' && !Array.isArray(attributeValue)) {

test/history.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ describe('attributes', () => {
270270
});
271271
});
272272

273-
test('attributes with null', () => {
273+
test('attributes with null should be ignored', () => {
274274
const raw = [
275275
{
276276
entity_id: 'sensor.notify_last_redmi_all_attr',
@@ -299,11 +299,8 @@ describe('attributes', () => {
299299

300300
const history = toHistory(raw, hass, configuration);
301301
history.forEach(h => {
302-
expect(h.attributes.length).toBe(2);
303-
expect(h.attributes).toEqual([
304-
{ name: 'Apps', value: 'null' },
305-
{ name: 'icon', value: 'mdi:message' },
306-
]);
302+
expect(h.attributes.length).toBe(1);
303+
expect(h.attributes).toEqual([{ name: 'icon', value: 'mdi:message' }]);
307304
});
308305
});
309306

0 commit comments

Comments
 (0)