I've been trying out the Ledger, and I've encountered a situation where I want to change only a specific variable, such as tempHighThreshold
, without having to replace the entire set of data keys.
Currently, the workaround involves maintaining a separate cloud ledger for these "static" variables. I believe it would be highly beneficial to have an API that allows for partial updates—essentially the ability to modify individual key-based elements within the instance data instead of having to replace the whole data structure every time.
Here’s an example of my data structure for reference:
{
"instance": {
"data": {
"tempHighThreshold": <tempHighThreshold>,
"tempLowThreshold": <tempLowThreshold>,
"tempAlertInterval": <tempAlertInterval>,
"tempAlertsEnabled": <tempAlertsEnabled>,
"usesFahrenheit": <usesFahrenheit>,
"lastTempAlertTime": <lastTempAlertTime>
}
}
}
I am using Logic to read the temperature data and send a notification through web-hooks if the temperature is outside of the threshold, is enabled, and has not alerted the user within a time interval. The specific issue is lastTempAlertTime is set using the Logic function. When the user updates the settings, the lastTempAlertTime is reset
Update: I have been able to use a function such as
variablesLedger.set({
...variables, // Preserve existing variables
lastStatus: status,
lastStatusTime: now
});
within Logic to preserve variables in the ledger.