New Plugin: SiteSensor

Great job! Now… pull together the most useful data elements, and publish a recipe!

quick question - I use the DarkSky plugin and retreive current cloud cover percentage for the same thing - essentially I have a reactor group called “gloomy” based on that and several other factors (home, time, etc.) and then have another called “sunny” which basically cancels it out, but not until a threshold so it doesn’t just go back and forth all day. Works pretty well - but curious why you’re making what seems to be more complex - and also perhaps the solar radiation is a much better factor for ‘actual brightness’ (I did look into UV index on DarkSky for similar reasons but found it not to be as good for my use case)

I’m just starting to play with Solar Radiation so we’ll see how it works out. I’m adjusting the brightness of a lamp inversely to outside brightness so as it gets brighter outside the lamp dims till turning off at some point. I may at some point set a global variable that any scene could use to determine how bright lights should be when on. Early days and I’m just playing around but it seems that SR will work for me.

Hi @rigpapa, did you ever get around to looking to see if you could add an XML parser into SiteSensor? Most things i do with SiteSensor return JSON, but there is one pesky system that controls my camera recordings (SecuritySpy) that only returns XML at the moment. would love to be able to have camera status on a SiteSensor so i can trigger some actions from it.

EDIT: I may be able to tackle this via the text parsing, but i am unsure of how that works. all the working examples are JSON, so they don’t give me a heads up on what to enter in the “Enter the pattern to match in the response (note: not a regexp)” field. i found a simplified page that returns the values that i am looking for, but i cannot figure how to put the pattern in the field. basically, i am looking to do this:

string.match(response, ":(.*)")

and trying to enter each of the returned values (there should be 3) into the pre-defined value placeholders. if it helps, the page text that gets returned is this:

C:DISARMED
M:ARMED
A:ARMED

2ND EDIT: ok, it looks like the matching is really just looking for a word or words on the response and won’t do what i need it to do… happy to listen to any ideas

@rigpapa, wanted to bubble this up on this list to see if there is any hope for an XML parser in SiteSensor? i know it is probaly low priority, but would be most helpful. if that is not possible, maybe a regex parser so we can parse text into multiple “value expressions”? asking for a friend :wink:

1 Like

@rigpapa sorry for the late reply. You’re not missing anything, I just made a mistake.

But I have another question. I’m running a NAS with video surveillance.
Do you think it’s possible to use site sensor to be triggered when a motion is detected ?

That’s kind of a “how long is a piece of string?” question. It depends on what kind of API your NAS offers. Offhand, it doesn’t sound like the right approach, though, because SiteSensor can only poll–it makes requests on a timed interval, it cannot receive requests. The polling is likely to miss or delay recognition of events as a result.

A more likely solution/approach is something like this, which I use with BlueIris: BlueIris can make an HTTP request when motion is triggered on a camera, and make another request when the motion trigger resets. So I create virtual motion sensors on my Vera, and have BlueIris run the necessary Luup HTTP requests to set and reset the Tripped variable on those sensors. That works fine.

So, figure out if your NAS’ motion sensing/triggering can make an HTTP request. If it can, you’re more than halfway home.

As usual, perfectly clear answer. Thanks for that.
I don’t wanna use a software like blue iris as this solution is made for one or up to 64 cameras. I only have two Ip cameras…
So I will investigate if my NAS is able to send HTTP requests.
Thank you Patrick.

2 Likes

Sorry if this sounds a bit basic but do you have an example of a file with data for a text response? I have Sitesensor probing a file online, just not sure how to format it to get the data out. Cheers

2 Likes

I have some analog sensors (with 0-5Volt outputs) that I want to integrate in Vera. My idea is to connect these sensors to an Arduino (I have one already on the shelve, did some testing in the past) and write the output in Json format.
And then use Site Sensor to grab the measurements of the sensors. Has anyone done this already and help me with this ?
Or can anyone confirm this is possible to do ?

Many thanks in advance !

I do this, although I use ESP8266 NodeMCU’s (Wemos D1 Mini or equiv) for the purpose because they come with WiFi and the total package is cheaper and smaller than Arduino + WiFi. The price point on Amazon is around $6 each, and you can get them for under $2 easily on AliExpress. It’s insane.

1 Like

Hi rigpapa,

Thx for the great Plugin!

I tried with openweather to retrieve the rain forecast value which I found in hourly section of the response. If there are values available (in my example on the 10th position in the array) I receive an error:

08:04:26: SiteSensor: Failed to execute `"if(response.hourly[10].rain,if(response.hourly[10].rain['1h'],response.hourly[10].rain['1h'],0),0)"', { message="Can't coerce table to boolean", ["__source"]="luaxp", type="evaluation" }
08:04:26: SiteSensor: Eval #3: "if(response.hourly[10].rain,if(response.hourly[10].rain['1h'],response.hourly[10].rain['1h'],0),0)"=(nil)nil

JSON response snipped:

  {
     "dt":1591624800,
     "temp":287.15,
     "feels_like":285.17,
     "pressure":1012,
     "humidity":78,
     "dew_point":283.53,
     "clouds":100,
     "wind_speed":2.98,
     "wind_deg":306,
     "weather":[
        {
           "id":500,
           "main":"Rain",
           "description":"light rain",
           "icon":"10d"
        }
     ],
     "rain":{
        "1h":0.28
     }
  },

Thx for you support!

Try changing if(response.hourly[10].rain,... to if(response.hourly[10].rain != null,.... You will likely need to use the latter form everywhere you’ve attempted the former. Remember the expression syntax is not Lua; it happens to look a lot like Lua, but it’s not Lua.

Thx @rigpapa! It worked

1 Like

Haven’t had much luck yet. My oil tank sends readings every week via email which I am able to parse. Zapier then uses this to create a file. I am hoping there is some way Sitesensor can probe the file. Is there an example of what the file should contain? Edit - would be text not json

SiteSensor draws data from JSON responses only. It can only do a binary “contains/doesn’t contain” match against other text responses.

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)