New Plugin: SiteSensor

@rigpapa For me without a doubt a plug-in like DarkSky Weather was excellent …
I use it especially in the summer, to control the blinds because of the sun … They close in the devisions where the sun is strongest so the house doesn’t get too hot!

But I understand that all this is a lot of work.
But again when DarkSky is going to be boring …

It’s the UI7 mechanisms for displaying an icon that are the challenge. If you have a URL for an icon, there’s nowhere in runtime you can put it to make that icon display on the device’s dashboard card. The icons are defined by the static JSON file, and the key word there is static. Hard-coded and decided well before the display is painted. Plugins that switch icons are able to do so because they have to pre-define every possible icon that the device could want to display (a fact that precludes your goal, I think). You can get crafty doing things like specifying in the static JSON that the icon path is a CGI script to serve a dynamic image, but there’s no straightforward way to communicate which image to the script (e.g. no dynamic query parameters on the icon URL), so it’s just kludge upon kludge upon kludge working around the design deficiencies of UI7. And then there’s the matter of changing the static JSON file on standard device types to one with these theoretical custom display capabilities–UI7 is loaded with screwed up tests where it looks at the name of the JSON file instead of consistently using state variables containing configuration or capabilities, the device type, or assigned category+sub to make display or control decisions. And finally, the mobile apps… they have nothing to do with what UI7 does, and invariably after you get something working in the web UI, the first thing you hear is “it’s not displaying in the Android/iOS mobile app”. It’s an elephant circus and over the years they’ve just added mice.

Ideally, the icon URL would just be a device attribute that could be changed, and changes to the icon register immediately in the user interface; but that is light years from how UI7 works, and I suspect since it’s effectively EOL, it will never change.

2 Likes

+1 to this. I recently went down this pathway (with @rigpapa’s wise counsel) and have emerged, bloody and battle-worn, with a whole two custom icons in the UI7 GUI.

1 Like

Just noticed all my sitesensor devices say “Can’t Detect Device”.
These were working before.
I am running Vera Edge, Firmware 1.7.4969 (7.31)
SiteSensor version 1.15

If I create a new device I get the Success message box, but the message is “Delivery Failed”
The new device does get created, but when I go to settings I get the message… “There was an errlr loading configuration data. Vera may be busy; try gain in a moment.” This repeats even after waiting.

Some additional information. I restored a backup with SiteSensor 1.14 and the problem goes away.

Any ideas?

Am I just missing it, but is there a specific sub category in the community other than this thread for SiteSensor? I have a question that might be rather involved, as I’m trying to access a python script on my local server and get the results of it using SiteSensor. Is this possible?

If your Python script answers JSON, or you just need to match a string in the returned data from the script, yes.

Patrick,
Here is what I’m trying to do. I’m trying to use a python script from Github, that some people have developed into use for Home Assistant. The script works fine and returns basically a binary result of Locked or Unlocked. Nothing fancy. You can also send commands to lock or unlock the Kevo lock.

I’ve set up the python on a Pi to test, but I plan on migrating it to my main home server, running Fedora 31.

So, I need SiteSensor to be able to read the state of the lock via python script, and act upon the script. I’d like just to be able to use the slider bar in Vera, like they’ve done in Hone Seer. SiteSensor seems like my best chance of making this work

Of course, I’d like to use Reactor to lock the doors in the end…

If there is a better way you can think of to integrate this into Vera, I’m all for it. I just have zero experience programming in Vera, other than using existing apps.

I’m try to get current weather data from weatherbit.io, specifically solar_rad, solar radiation, to tell me how bright it is outside to reduce inside lighting levels.

Enter the URL to be queried:
https://api.weatherbit.io/v2.0/current?city=Napa,CA&key=MY_API_KEY&units=I

My browser returns this data:
JSON-P({“data”:[{“rh”:17,“pod”:“d”,“lon”:-122.28553,“pres”:1022.6,“timezone”:“America/Los_Angeles”,“ob_time”:“2020-04-14 17:20”,“country_code”:“US”,“clouds”:0,“ts”:1586884800,“solar_rad”:781.5,“state_code”:“CA”,“city_name”:“Napa”,“wind_spd”:6.9,“last_ob_time”:“2020-04-14T17:20:00”,“wind_cdir_full”:“north”,“wind_cdir”:“N”,“slp”:1024.2,“vis”:3.1,“h_angle”:-38.6,“sunset”:“02:45”,“dni”:888.55,“dewpt”:24.7,“snow”:0,“uv”:8.08972,“precip”:0,“wind_dir”:350,“sunrise”:“13:32”,“ghi”:781.49,“dhi”:114.18,“aqi”:61,“lat”:38.29714,“weather”:{“icon”:“c01d”,“code”:“800”,“description”:“Clear sky”},“datetime”:“2020-04-14:17”,“temp”:72.1,“station”:“0154P”,“elev_angle”:49.4,“app_temp”:69.7}],“count”:1});

I have tried response.solar_rad and response.data.solar_rad and nothing seems to work.

Any help wold be appreciated, either fixing the above, a recipe for a site that includes this data or another site that includes local solar radiation,

Thanks,
Tom

JSONP is not JSON, so SiteSensor cannot parse the response. Can this API be configured to give you a pure JSON response?

I am parsing weatherbit.io without any problem. Mine is coming back as a json and my url doesn’t call it out. Maybe look into the settings of the API?



Screen Shot 2020-04-14 at 16.24.42

1 Like

OK, got JSON backbut still not parsing:
JSON({“data”:[{“rh”:25,“pod”:“d”,“lon”:-122.28553,“pres”:1019.4,“timezone”:“America/Los_Angeles”,“ob_time”:“2020-04-14 22:50”,“country_code”:“US”,“clouds”:0,“ts”:1586904600,“solar_rad”:679.6,“state_code”:“CA”,“city_name”:“Napa”,“wind_spd”:13.8,“last_ob_time”:“2020-04-14T22:50:00”,“wind_cdir_full”:“west-southwest”,“wind_cdir”:“WSW”,“slp”:1020.5,“vis”:3.1,“h_angle”:38.6,“sunset”:“02:45”,“dni”:857.44,“dewpt”:40.4,“snow”:0,“uv”:7.09744,“precip”:0,“wind_dir”:240,“sunrise”:“13:32”,“ghi”:679.59,“dhi”:108.03,“aqi”:46,“lat”:38.29714,“weather”:{“icon”:“c01d”,“code”:“800”,“description”:“Clear sky”},“datetime”:“2020-04-14:23”,“temp”:79,“station”:“0154P”,“elev_angle”:42.42,“app_temp”:77.8}],“count”:1});

16:28:43: SiteSensor: Requesting JSON data
16:28:43: SiteSensor: Set up for HTTPS (“0.8”) request, verify=“none”, protocol=“any”, options=nil
16:28:43: SiteSensor: “GET” “https://api.weatherbit.io/v2.0/current?city=Napa,CA&key=MY_API_KEY&units=I&callback=JSON”, headers={ }
16:28:43: SiteSensor: Response is 701 bytes in “/tmp/Q_SiteSensor_193.txt”
16:28:43: SiteSensor: Unable to decode JSON response, “no valid JSON value at line 1, column 1” (dev 193)

No, it’s still JSONP

Got it!

{“data”:[{“rh”:26,“pod”:“d”,“lon”:-122.28553,“pres”:1019,“timezone”:“America/Los_Angeles”,“ob_time”:“2020-04-15 00:20”,“country_code”:“US”,“clouds”:0,“ts”:1586910000,“solar_rad”:496.9,“state_code”:“CA”,“city_name”:“Napa”,“wind_spd”:15,“last_ob_time”:“2020-04-15T00:20:00”,“wind_cdir_full”:“west-southwest”,“wind_cdir”:“WSW”,“slp”:1020.2,“vis”:3.1,“h_angle”:51.4,“sunset”:“02:45”,“dni”:785.87,“dewpt”:36.4,“snow”:0,“uv”:5.47553,“precip”:0,“wind_dir”:250,“sunrise”:“13:32”,“ghi”:496.91,“dhi”:95.15,“aqi”:46,“lat”:38.29714,“weather”:{“icon”:“c01d”,“code”:“800”,“description”:“Clear sky”},“datetime”:“2020-04-15:00”,“temp”:73.4,“station”:“0154P”,“elev_angle”:31.29,“app_temp”:71.7}],“count”:1}

“response.data[1].solar_rad” got me the data I wanted.

Thanks

2 Likes

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.