Delete part of an object in Context

my bad, i should have tested it more thoroughly ..
it seems the [ ] syntax doesnt work when setting Context for Objects.
the code should have been
global.set("Battery.SBP-Right.DesiredChargeRate", undefined);

which was a bit confusing because in javascript when you have the special dash / minus - character in the property name you need to use the [ ] syntax so i presumed that it would work.

Test Flow

[{"id":"75f5e3b9b7132219","type":"inject","z":"4895ea10b4ee9ead","name":"set","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":270,"y":300,"wires":[["41b4634b728fe281"]]},{"id":"41b4634b728fe281","type":"function","z":"4895ea10b4ee9ead","name":"","func":"global.set(\"test.SBP-Right.DesiredChargeRate\", 123);\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":300,"wires":[[]]},{"id":"7b6697bcbf49b32e","type":"inject","z":"4895ea10b4ee9ead","name":"del","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":270,"y":360,"wires":[["b30bc3a7fc1eb202"]]},{"id":"b30bc3a7fc1eb202","type":"function","z":"4895ea10b4ee9ead","name":"","func":"global.set(\"test.SBP-Right.DesiredChargeRate\", undefined);\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":360,"wires":[[]]}]

Found the post i read about setting to undefined. it was here

1 Like