New Plugin: SiteSensor

Got it! Could you direct me to basic json file I could use as a template perhaps?

Here’s a strict definition, if you’re accustomed to reading such things: JSON

This may be less specific, but more clear: Working with JSON - Learn web development | MDN

And: JSON Syntax

1 Like

Many thanks rigpapa

1 Like

Would there be a problem hosting a file on google drive? It’s only 4 lines ~ 1k and have this log …

19:24:47: SiteSensor: Requesting JSON data
19:24:47: SiteSensor: Set up for HTTPS (“0.6”) request, verify=“none”, protocol=“any”, options=nil
19:24:47: SiteSensor: “GET” “https://drive.google.com/file/d/1cmD61r8Jx15kZ89JnxN98n8yRdoktQdR/view?usp=sharing”, headers={ }
19:24:48: SiteSensor: WARNING: Response was truncated to limit of 65536 bytes; 70717 total bytes received in “/tmp/Q_SiteSensor_45.txt”
19:24:48: SiteSensor: WARNING: the response from this site is quite large! (65536 bytes)
19:24:48: SiteSensor: Unable to decode JSON response, “no valid JSON value at line 1, column 1” (dev 45)

The data you are fetching from Google Drive is larger than the default maximum. That’s a safety to prevent a rogue response from the server from consuming too much memory on the Vera and crashing it. You can set the MaxResponseSize state variable on your SiteSensor to something larger to let the full response come through. The message indicates that the response is trying to return 70717 bytes, so I would set something a bit larger in case the file grows, like 80000? 90000? Don’t get carried away.

Thanks! was not getting anything useful so changed tack … don’t know if this is of use to anyone …

Email to Sitesensor via google drive ~ Oil tank reports level via sms and email comes through once a week. Forward email to Email Parser by Zapier to extract data. Created json file in google drive and set sharing to public view. Zapier replaces json file with same name and updated data.

In the latest iteration (v3) of the Google Drive API, there is no way for anyone to access the contents of a public JSON file without authentication.
An API key is required (JavaScript 快速入门  |  Google Drive  |  Google for Developers) and then one can use the following endpoint:

googleapis.com/drive/v3/files/?alt=media&key= (this is wrong - keeps reformatting)

Untitled

1 Like

Using SiteSensor and api.ipify.org to get external IP. Is it possible to store timestamp of last error to a state variable? Perhaps using a some sort of variation of LastTrip & status.timestamp?

@rigpapa, any ideas?

What kind of query are you doing?

Ok, here’s an interesting one.

I’m looking to find a way to tell if a device is turn on or on standby - in both cases the device is accessible via its web interface, showing the same user interface - the only main difference will be that it will just show you a button saying ‘off’ when it’s on standby and on when it’s ‘on’ .

You can use a string match type query (as opposed to JSON query – there’s a control to let you choose one or the other), and then provide a string that matches all or part of the HTML that forms the button. The issue you may run into is that if the button is populated/controlled via jQuery or simply DOM manipulation, the source HTML never contains the correct state, the correct state is forced to the button by the browser running JavaScript (something SiteSensor doesn’t do). You’re just going to need to experiment with this one…

Hey @rigpapa !

Thanks, yes, that’s exactly what I’ve found, I tried to see the source html via Lua, but I couldnt get that to work (I could see the page but not the code), so in the end I just viewed the source via another means (during both states) and you’re right nothing looked like it changes.

I have this ‘SiteSucker’ app on my ipad which can scan the device and download any associated files and I can see a number of .js files on there. which I believe just confirms what you’ve said

FYI - The device in question is a media switcher, that can take multiple sources / upscale etc. onto a screen. So, if not sitesensor - then I’m struggling to think of ant other way to know if it’s on or on standby…

Look for AJAX calls. 90% of the time they’re not protected at all or are easily guessable (a fixed cookie, a fixed auth string, etc).

Best thing to do, if it’s a normal web page, is to fiddle with Chrome Dev Tools (press f12 when browsing and go to network tab).

I’ve successfully integrated a lot of things this way.

Thanks @therealdb

Interesting idea, although I don’t really know where to start, but I’m up for giving it a go.

By any chance could you share some code examples you have that do it, that way I could see what works, what I would need to look for etc .?

It really depends on the device. I’ve also reverse engineered a couple of mobile apps as well. Just use something to log your traffic. If it’s a web app, it’s very easy via dev tools.

I’m doing a very basic query, “https://api.ipify.org/?format=json”, and storing IP address with a value expression (“response.ip”). And it would be nice to log a time when this query failed

Hi @therealdb - is there anything that you can share in Lua that checks the traffic ?

You’ll need something like this Chrome DevTools - Chrome Developers

OK. Install the stable branch release from Github, here: GitHub - toggledbits/SiteSensor at stable

It adds two new variables:

  • LastFail - the timestamp of the last failed query
  • FailedSince - the timestamp for the first failed query in a series of failed queries (blank when queries are successful)
1 Like

Just for fun, for those of you using OctoPrint with your 3D printers, there’s now a simple status recipe (printing, error, bed temp, extruder temp) in the SiteSensor Recipes Github Repo.

3 Likes