diff --git a/webapp/src/utils/formatting.test.ts b/webapp/src/utils/formatting.test.ts index b1fb9c0..21b3746 100644 --- a/webapp/src/utils/formatting.test.ts +++ b/webapp/src/utils/formatting.test.ts @@ -269,3 +269,18 @@ test("pretty naming", () => { expect(prettyName("device_tracker")).toEqual("Device Tracker"); expect(prettyName("Baby Name")).toEqual("Baby Name"); }); + +test("get descrption for device action", () => { + expect( + getDescriptionFromAutomationNode( + { + platform: "device", + type: "no_motion", + device_id: "d148a585c041a9a1b352a670d64e0c58", + entity_id: "binary_sensor.motion_office_inv", + domain: "binary_sensor", + }, + dummyNamer + ) + ).toEqual("binary_sensor.motion_office_inv No Motion"); +}); diff --git a/webapp/src/utils/formatting.ts b/webapp/src/utils/formatting.ts index 1e42aa7..4c8b567 100644 --- a/webapp/src/utils/formatting.ts +++ b/webapp/src/utils/formatting.ts @@ -61,20 +61,7 @@ export const getDescriptionFromAutomationNode = ( return out; } if (node.platform === "device") { - let out = ""; - if (node.device_id) { - out = namer.getDeviceName(node.device_id); - } - if (!out && node.entity_id) { - out = namer.getEntityName(node.entity_id); - } - if (node.type) { - out += node.type; - } - if (!out) { - out = node.platform; - } - return out; + return getDescriptionForDeviceType(node, namer, true); } return node.platform; }