I am using a base pattern with a lot of variables, which I am changing via WS commands on a streamdeck keypad.
The sketch is changing in line with the commands, and I understand we are advised not to use WS commands and the web editor at the same time. but is there any way to make those WS updates ‘save’ to the cached sketch? After a reboot, or if I go into the editor mode later on, the sketch still holds the values from the original sketch, and the ‘edit ‘ mode is empty until I load a sketch, even though there is a cached sketch showing…
The best way to do this is controls, but unfortunately can cause some animation stutter.
Ui controls can be persisted. The ui itself uses these, while you slide a slider it streams the data over without persisting it, then once the value stops changing for a while, sends it again with save:true to persist it.
Next time the pattern loads, all the old values are loaded in to it before the first frame of animation.
But the save can cause a small stutter in animation. If you save super frequently it will be choppy, and causes flash wear if you do it in loop or on every value change.
It’s implemented on the client side, it uses a debounce function and resends the last controls with save:true. Doesn’t exist on the websocket server side unfortunately. No saveLater option.
Pattern code is tricky because the chip can’t compile source. You would need to extract the compiler from the page and be able to run JavaScript, and it has a less user-friendly binary interface. However, @zranger1 ‘s python client library does all of that! Still, this is heavier than controls and the same persistence thing is worse if you want to persist a whole updated pattern.