An archive of community.esquilo.io as of Saturday January 26, 2019.

JSON parse error?

steveb48

Hi All,

When I connect to my pool controller page remotely (not on my wifi) I'm getting a JSON parse error from my ERPC call. This was working and continues to work at home. I've changed no code since it was working remotely. Could this be a nest server issue? I am connecting to the device as my page loads. I disabled and emptied my cache just to be sure.

thanks
Steve

Scott_Shumate

Is there any way you can grab the offending JSON data? For example, in Chrome you can open the developer tools and select the network tab to see the requests and responses. For Firefox, you can do the same with the Firebug plugin.

steveb48

Hi Scott,

I took a look at the network tab in Safari and was seeing signin requests. I think I may be causing this issue.
I have the URL to my HTML bookmarked. The URL is the prefix which is displayed in the nest details, remote section with the path to my HTML appended.

After seeing this problem, I went to nest, it prompted me to log in and then I went to my bookmarked URL. All better!

So how should I be handling an error and logging in?

Thanks,
Steve

patrick

Steve,

I restarted the Nest last night after adding a fix. This caused your session to close. I'm actually looking at alternative authentication mechanisms right now to avoid this in the future.

But for now, I need to figure out a better way to have this pop up on the client. Would you mind sharing your ERPC call?

Thanks.

steveb48

Not as long as you promise not to laugh at my code! Looks like the cut and paste mess up the formatting.

function getStatus() {
erpc("getStatus", null, function(result) {
var item = document.getElementsByName("pool");
if(result.pool == 1)
item[0].checked = true;
else
item[0].checked = false;

    
      item  = document.getElementsByName("spa");
	if(result.spa == 1)
        item[0].checked = true;
     else
         item[0].checked = false;


      item  = document.getElementsByName("poollight");
	if(result.poollights == 1)
        item[0].checked = true;
     else
         item[0].checked = false;


   item  = document.getElementsByName("spalight");
	if(result.spalights == 1)
        item[0].checked = true;
     else
         item[0].checked = false;


      item  = document.getElementsByName("waterfall");
	if(result.waterfall == 1)
        item[0].checked = true;
     else
         item[0].checked = false;
      
      item  = document.getElementsByName("spillway");
	if(result.spillway == 1)
        item[0].checked = true;
     else
         item[0].checked = false;
      
      item  = document.getElementsByName("time");
      if(result.min > 9)
          item[0].innerHTML = "Time: " +result.hrs + ":" + result.min;
	  else
          item[0].innerHTML = "Time: " +result.hrs + ":0" + result.min;

      item  = document.getElementsByName("airtemp");
      item[0].innerHTML = "Air Temp: " + result.airTemp + "°F";

      item  = document.getElementsByName("pooltitle");
      if(result.pool == 1)
   		  if(result.poolDelay == 1)
              item[0].innerHTML = "Pool: " + result.poolTemp + "°F - Pump Delay";
		else
              item[0].innerHTML = "Pool: " + result.poolTemp + "°F";

	  else
           item[0].innerHTML = "Pool: Last " + result.poolTemp + "°F";

      if(poolHeatSrc == 0)
      	item[0].style.color = "white";
	  else
        item[0].style.color = "red";
      
      item  = document.getElementsByName("spatitle");
	  if(result.spa == 1)
          item[0].innerHTML = "Spa: " + result.spaTemp + "°F";
	  else
          item[0].innerHTML = "Spa: Last " + result.spaTemp + "°F";

      if(spaHeatSrc == 0)
      	item[0].style.color = "white";
	  else
        item[0].style.color = "red";

      if(result.pumpHighSpeed == 0){
		item  = document.getElementsByName("low");
			addClass(item[0], "clicked");
          
			item  = document.getElementsByName("high");
			removeClass(item[0], "clicked");
        }
        else{		
			item  = document.getElementsByName("high");
			addClass(item[0], "clicked");

			item  = document.getElementsByName("low");
			removeClass(item[0], "clicked");
        }
    
 GPM = result.GPM;
      RPM = result.RPM;
      watts = result.watts;
      poolSetTemp = result.poolSetTemp;
      poolHeatSrc = result.poolHeatSrc;
      spaSetTemp = result.spaSetTemp;
      spaHeatSrc = result.spaHeatSrc; 
     
      setTimeout(getStatus, 5000);
  },  
     function(text) {
        console.log("error: " + text);
  	  	setTimeout(getStatus, 5000);
     }
  );
}
patrick

I think it is because the authentication failure redirect goes to the nest.esquilo.io domain but is coming from <systemId>.esquilo.io. I'm working on a fix.

You can also disable authentication on the Nest proxy for a given Esquilo by unchecking the "Authentication enabled" check box in the Settings tab on the manager page. Of course, this leaves your system open for access without a login.

steveb48

I'll leave authentication enabled as I know how to get around it. I don't want you guys turning on my waterfalls!

Thanks to both you and Scott for all your help.

Steve

patrick

What fun is that? wink

steveb48

Hi Patrick,

Was this the server change you just made? If so I'm still getting an error if my login has expired.

From Safari:
Go to nest and log out. The same happens if the login has expired but this is faster.
Go to my pool controller URL on the Esquilo.
Safari's web inspector says "Application Cache manifest could not be fetched, because a redirection was attempted"

If I go to nest, login and then go to my URL, all is good.

Should I be doing something different?

thanks
Steve

patrick

I just made the sessions stick around between nest restarts. They should time out in 31 days or if you sign off.

The redirect for an expired session is confusing. I'm working on a fix that just kicks you out to the nest login page, but it is complicated because of the system ID-based subdomains.

steveb48

Hi Patrick,
I just hit this again and had an idea. Warning I'm way out of may area of expertise here!

When I hit this problem, I go to nest.eqsquilo.io, login and then go to my device's url and all is well.

I can detect the JSON parse error so can I just redirect on the client side to nest and just select back?

Thanks,
Steve