better name for device trigger

This commit is contained in:
ari committed 2022-06-17 22:22:37 -04:00
1 parent 537bfe824b
commit 4bada614b9
2 files changed
+16 -14

No files matched your search

+15
View File
@@ -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");
});
+1 -14
View File
@@ -61,20 +61,7 @@ export const getDescriptionFromAutomationNode = <N extends AutomationNodeTypes>(
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;
}