Let me give you some explanations first (sorry if you already know this):
The purpose of "storage.getItem" and "storage.setItem" is to remember (inside local storage which is kept even after Studio restarts) the last parameters that you entered, so when you start script again you will be greeted with same parameters you used last time. If you don't need this feature you can remove it, so your script can look like this:
var defaultValues = {
startCurrent: 1.5,
stopCurrent: 0.1,
maxChargeTime: 10,
};
var values = await input({
title: "Start Dlog",
fields: [
{
name: "startCurrent",
displayName: "Charging current",
unit: "current",
validators: [validators.rangeInclusive(0.1, 5)]
},
{
name: "stopCurrent",
displayName: "End ocf charge current",
unit: "current",
validators: [validators.rangeInclusive(0.01, 0.5)]
},
{
name: "maxChargeTime",
displayName: "Max charging time",
unit: "time",
validators: [validators.rangeInclusive(1, 86400000)]
}
]
}, defaultValues);
if (!values) {
session.deleteScriptLogEntry();
return;
}
session.scriptParameters = values;
Also, to answer your question, any script can access this local storage items with "storage.getItem". Check this:
https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorageNow, If I start the script code you send me everything works fine on my computer. But, If I change the script slightly I can see the same error as you. This is changed script:
var defaultValues = storage.getItem("LiPoChargeValues", {
startCurrent: 1.5,
stopCurrent: 0.1,
maxChargeTime: 10,
});
var values = await input({
title: "Start Dlog",
fields: [
{
name: "startCurrent1", // "startCurrent" renamed to "startCurrent1"
displayName: "Charging current",
unit: "current",
validators: [validators.rangeInclusive(0.1, 5)]
},
{
name: "stopCurrent",
displayName: "End ocf charge current",
unit: "current",
validators: [validators.rangeInclusive(0.01, 0.5)]
},
{
name: "maxChargeTime",
displayName: "Max charging time",
unit: "time",
validators: [validators.rangeInclusive(1, 86400000)]
}
]
}, defaultValues);
I changed "startCurrent" to "startCurrent1". The error is because defaultValues doesn't contain the value for "startCurrent1". But if I put "startCurrent1" inside defaultValues, everything is ok again:
var defaultValues = storage.getItem("LiPoChargeValues", {
startCurrent1: 1.5, // now, we have the value for "startCurrent1"
stopCurrent: 0.1,
maxChargeTime: 10,
});
var values = await input({
title: "Start Dlog",
fields: [
{
name: "startCurrent1",
displayName: "Charging current",
unit: "current",
validators: [validators.rangeInclusive(0.1, 5)]
},
{
name: "stopCurrent",
displayName: "End ocf charge current",
unit: "current",
validators: [validators.rangeInclusive(0.01, 0.5)]
},
{
name: "maxChargeTime",
displayName: "Max charging time",
unit: "time",
validators: [validators.rangeInclusive(1, 86400000)]
}
]
}, defaultValues);
Maybe you also changed the fields definition for the input, but forget to change defaultValues?