Piston Will Not Load: State cannot be greater than 100000.0 characters


#1

1) Give a description of the problem
I recently completed a somewhat complicated piston which worked for a few weeks and then stopped firing. Trying to investigate, I went to the webcore dashboard but the piston would not load. I found other posts with similar issues and found the likely culprit; an error stating that "State cannot be greater than 1000000.0 characters:

I have attempted to duplicate the piston with the backup code but it is created empty.

I suspect I am writing the result of a REST call to a variable (and maybe other places) and this is causing the variable “overload”.

Any suggestions would be appreciated.

2) What is the expected behavior?
Piston to load and fire

3) What is happening/not happening?
Piston is not firing, ST shows activity with the device, piston will not load

**4) Post a Green Snapshot of the piston![image|45x37]E)
Not possible

**5) Attach any logs (From [ST IDE](https://graph-na02-
physicalgraph.exception.StateCharacterLimitExceededException: State cannot be greater than 100000.0 characters @line 1032 (api_intf_dashboard_piston_get)


#2

Please go to ide.smartthings.com then click My Locations > smartapps. Find the piston that is failing and click to see the app state. It is usually easy to see what is taking up the most memory whether logs, stats, or variables. Report back when you find what seems to be filling up the state and we’ll go from there.


#3

Just checked - let me know if you need more detail. It looks like “piston” and “stats” have quite a bit but the most appears to be in “vars”. I parsed the JSON and it looks like a variable called instructionArray (contains route information between home and work) is the longest with 99,300 characters.


#4

With the help from ipaterson and other forum topics I was able to figure it out. I used the following code from the Webcore dashboard to reset the variables:

~function(name){
    dataService.setVariable('instructionArray', {}, $('td:contains("' + name + '")').scope().piston.id)
}('Front Door Motion and Directions');

For those interested, I was only using the 0th index of the array so updated the logic to only capture that index and ignore the rest.