Skip to content

Commit baca36e

Browse files
committed
Default customname of switch to the swich type
Instead of setting the Name of the switch to "Switch [1-4]", set it to reflect the type of the switch. E.g. "Temperature setpoint".
1 parent 6ca26a0 commit baca36e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/nodes/victron-virtual.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,15 @@ module.exports = function (RED) {
812812
ifaceDesc.properties[key] = { type, format, persist }
813813

814814
let propValue = value
815-
if (name === 'Name') propValue = `Switch ${i}`
815+
if (name === 'Name') {
816+
// Find the format function for Settings/Type
817+
const typeProp = baseProperties.find(p => p.name === 'Settings/Type');
818+
let typeLabel = `Switch ${i}`;
819+
if (typeProp && typeof typeProp.format === 'function') {
820+
typeLabel = typeProp.format(switchType);
821+
}
822+
propValue = typeLabel;
823+
}
816824
if (name === 'Settings/Type') propValue = switchType
817825

818826
iface[key] = propValue !== undefined ? propValue : 0

0 commit comments

Comments
 (0)