New Plugin: SiteSensor

If you just want to pull the icon image that corresponds to a the ‘icon’ code returned by OWM in response.weather.icon, compose the URL as follows:

http://openweathermap.org/img/w/ICON_CODE_HERE.png

For example:

http://openweathermap.org/img/w/01d.png

for ‘Sunny Day’.

See OpenWeatherMap / Weather Icons integration · GitHub for another working method, which can assign a given icon (from this collection) based on your OWM response.

Thank you for your help…
excuse my ignorance, but where do I put my code?
I don’t understand anything about programming and I try to do things with your help!

You haven’t stated where you intend for the custom icon image to appear.

  • Inside an email notification? (e.g. Reactor > Notify > SMTP)
  • In the Vera UI? (I don’t know if this is possible)
  • On a custom panel? (e.g. ImperiHome)
  • Within a web page you are building?
  • etc.

My goal is in Vera UI …
I wanted with SiteSensor to replace DarkSky Weather …
And then create scenes according to the weather …

For example…
I currently have
If between x and y hours there is sun the blinds close … if there is rain they stay open …

1 Like

You could assign

response.weather.id

to one of your SiteSensor expressions, and use that number accordingly.

See this list of weather conditions associated with each value of id.

However, I don’t believe there is any mechanism in place to force SiteSensor’s (or any of its child devices’) icon image to change in the VERA UI – as DarkSky’s did – even if you know the correct URL (as mentioned above). Sorry!

► Could this be a Feature Request, @rigpapa? ◄

Without going down the road of doing a purpose-built plugin for OpenWeatherMap (which I’m willing to do, BTW), the real challenge here, I think, is bridging the gap between the icon code and the icon image in a meaningful way that also works generally, not just for OWM. It’s not something I think would have a lot of value in SiteSensor. My time would be better spent on an OWM plugin.

2 Likes

Agreed, if taking the “niche appeal” viewpoint, but could see the relative simplicity of adding, say, an IconURL variable to each SiteSensor device. That would give users wanting to modify the icon(s) dynamically an express target for doing so?

Solves a general use case with minimal coding.

@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.

https://community.getvera.com/t/new-plugin-sitesensor/197026/295

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