New Plugin: SiteSensor

Thanks very much, that’s done the trick!

I did see that variable when poking around and tried a couple of values, but wasn’t quite on the money.

rigpapa,
Is there enough real estate for SiteSensor to return a date+time stamp of the last success?
Currently the Main UI just indicates ‘Last query succeeded!’

@rigpapa, on openLuup somehow now my sensors which none need to be armed to start polling, don’t start querying in a loop. Actually I noticed that they query only upon an armed command of the sensor. I never observed this before and am running the stable branch… Not sure what is causing this.

Edit: Interesting… I found out what was causing it. I had created a test device to test an API and left it in a query failed state/disabled state. Apparently when one sensor query is failed, all sensors stop their querying loops. Deleting that one test device made everything work again.

Well, that’s not right! I’ll look into it ASAP. I’ve been swamped with a non-Vera/household project on a very strict schedule these past few days.

Edit: So wait… are you saying that if you have two SiteSensors, and one takes an error, the other stops querying?

Yes it seems that way…

That’s… odd… because SiteSensors are independent instances–it’s not a parent-child plugin. They don’t have a common scheduler, or share code in memory, as parent-child plugins do. They should be as isolated from each other as they are from other plugins.

Can you give me any more detail on your observations?

Sorry for the late response.
I have about a 17 instances of the site sensors working mostly getting data from Home Assistant but also from other APIs.
I created an 18th one to run some tests when I was tinkering with both bing map and Here maps APIs and left it on my setup on a failed poll state.
I had not noticed that (sorry I have not looked into the details of the site sensor code so I am guessing here) that the luup.call_delay callback loop for the query stopped functioning on all 17 of my other sensors. I am still able to manually query each individual sensors by disarming/arming but they never query again… until I deleted that 18th test sensor which I left in a failed query state. This was on openLuup and I can’t really understand how this could be possible knowing that callbacks should have all been independent of one another.

Ah, openLuup, that helps. I would have been completely focused on Vera Luup while digging for this. There are many things openLuup does differently, and environment is among them, so that’s a good lead, but still not what I would expect under the circumstances. I wonder if oL stalls all devices somehow, though… speculation… need to dig in… won’t be today, tomorrow’s not looking good either; I’ve got new kitchen cabinets going in this week.

No rush… it is an oddity. Which I resolved already by removing the orphan test device. I went nuts just for a minute. I have tweaked the io module of my openluup as well to enable a retry of the io.open by wiping the previous port under certain conditions for another plugin but I don’t think that is when the problem started.

Enjoy the new cabinets!

I’ve seen similar problems in openLuup with network related devices. It seems that if a device has an error/trouble condition re an http call, that the Network functionality degrades somehow. I can see this with Network monitor when a device goes offline. Just one device giving trouble can cause network related issues, especially with luup.io trying to connect to other devices.

This is interesting… I had never observed this before but it is good to know that it exists. When this occurred through, no other plugin appeared to have been affected (and I have a lot of them running on openluup)

Hi Patrick,

Is there a way to enable/disable a site sensor without using the arm/disarm setting. Basically I want the site sensor to run during a specific period of time (to conserve the number of weather api calls), and setting the site sensor to arm/disarm is triggering unwanted notification.

Thanks.

I’ve added a SetEnabled action to the stable branch version on Github. You can invoke that action with a parameter newEnabledValue set to 0 or 1 to change the enabled state of the SiteSensor. When disabled, queries will not run regardless of timing or arming state. Enabling a disabled SiteSensor causes an immediate query.

To install:

  1. Go to the Github stable branch for the project: GitHub - toggledbits/SiteSensor at stable
  2. Click the green “Clone or download” button, choose “Download ZIP”, save the archive somewhere.
  3. Unzip the archive.
  4. Open the Vera uploader at Apps > Develop apps > Luup files
  5. Multi-select and drag, as a group, the unzipped files (not folder) to the “Upload” button in the Vera UI.
  6. Wait for the uploads and reload to finish.

That should do it. There’s no UI at the moment, and no scene trigger, just the action you can invoke from Lua or Reactor. Using Lua:

-- Disable a SiteSensor:
luup.call_action( "urn:toggledbits-com:serviceId:SiteSensor1", "SetEnabled", { newEnabledValue=0 }, sensor_dev_num )

-- Enable a SiteSensor:
luup.call_action( "urn:toggledbits-com:serviceId:SiteSensor1", "SetEnabled", { newEnabledValue=1 }, sensor_dev_num )

Hi Patrick,

I did exactly what you suggested and have the site sensors enabled/disabled by Reactor. It is working great. Now I can disable the arm/disarm toggle and still be able to enable/disable the sensors without trigger the unwanted Vera notifications of arming the sensors.

Thank you for your continued significant contributions to the Vera community.

1 Like

Hi rigpapa,
I successfully used Sitesensor to get the current conditions of my Personal Weather Station from Wunderground. Using your great tips and advice.

But now I have made a seperate Sitesensor to retrieve the 5-day forecast. This is a separate URL. This went well: message “last query succeeded”.
But I don’t manage to get the data. Something goes wrong in the expressions.

The json output I get is:

{"dayOfWeek":["Donderdag","Vrijdag","Zaterdag","Zondag","Maandag","Dinsdag"],"expirationTimeUtc":[1577354928,1577354928,1577354928,1577354928,1577354928,1577354928],"moonPhase":["Nieuwe maan","Jonge maansikkel","Jonge maansikkel","Jonge maansikkel","Jonge maansikkel","Jonge maansikkel"],"moonPhaseCode":["N","WXC","WXC","WXC","WXC","WXC"],"moonPhaseDay":[0,1,2,3,4,5],"moonriseTimeLocal":["2019-12-26T08:52:33+0100","2019-12-27T09:47:09+0100","2019-12-28T10:31:11+0100","2019-12-29T11:04:57+0100","2019-12-30T11:31:43+0100","2019-12-31T11:53:51+0100"],"moonriseTimeUtc":[1577346753,1577436429,1577525471,1577613897,1577701903,1577789631],"moonsetTimeLocal":["2019-12-26T16:49:30+0100","2019-12-27T17:46:47+0100","2019-12-28T18:51:03+0100","2019-12-29T19:58:08+0100","2019-12-30T21:05:58+0100","2019-12-31T22:13:30+0100"],"moonsetTimeUtc":[1577375370,1577465207,1577555463,1577645888,1577736358,1577826810],"narrative":["Bewolkt. Maximaal 6 tot 8C en minimaal 2 tot 4C.","Overwegend helder. Maximaal 5 tot 7C en minimaal -2 tot 0C.","Overwegend bewolkt. Maximaal 3 tot 5C en minimaal -3 tot -1C.","Bewolkt. Maximaal 3 tot 5C en minimaal -1 tot 1C.","Overwegend helder. Maximaal 6 tot 8C en minimaal 2 tot 4C.","Gedeeltelijk bewolkt. Maximaal 7 tot 9C en minimaal 2 tot 4C."],"qpf":[1.62,0.0,0.0,0.0,0.0,0.0],"qpfSnow":[0.0,0.0,0.0,0.0,0.0,0.0],"sunriseTimeLocal":["2019-12-26T08:41:11+0100","2019-12-27T08:41:25+0100","2019-12-28T08:41:36+0100","2019-12-29T08:41:44+0100","2019-12-30T08:41:49+0100","2019-12-31T08:41:50+0100"],"sunriseTimeUtc":[1577346071,1577432485,1577518896,1577605304,1577691709,1577778110],"sunsetTimeLocal":["2019-12-26T16:33:19+0100","2019-12-27T16:34:04+0100","2019-12-28T16:34:53+0100","2019-12-29T16:35:45+0100","2019-12-30T16:36:39+0100","2019-12-31T16:37:37+0100"],"sunsetTimeUtc":[1577374399,1577460844,1577547293,1577633745,1577720199,1577806657],"temperatureMax":[7,6,4,4,7,8],"temperatureMin":[3,-1,-2,0,3,3],"validTimeLocal":["2019-12-26T07:00:00+0100","2019-12-27T07:00:00+0100","2019-12-28T07:00:00+0100","2019-12-29T07:00:00+0100","2019-12-30T07:00:00+0100","2019-12-31T07:00:00+0100"],"validTimeUtc":[1577340000,1577426400,1577512800,1577599200,1577685600,1577772000],"daypart":[{"cloudCover":[92,89,29,49,73,74,77,63,29,47,64,60],"dayOrNight":["D","N","D","N","D","N","D","N","D","N","D","N"],"daypartName":["Vandaag","Vanavond","Morgen","Morgenavond","Zaterdag","Zaterdagnacht","Zondag","Zondagnacht","Maandag","Maandagnacht","Dinsdag","Dinsdagnacht"],"iconCode":[26,11,34,29,28,27,26,29,34,29,30,29],"iconCodeExtend":[2600,1100,3400,2900,2800,2700,2600,2900,3400,2900,3000,2900],"narrative":["Bewolkt. Maximaal 7C. Wind uit het ZO van 10 tot 15 km/u.","Regenbuien. Minimaal 3C. Wind uit het OZO van 10 tot 15 km/u. Kans op regen 60%.","Overwegend helder. Maximaal 6C. Wind uit het ONO van 10 tot 15 km/u.","Gedeeltelijk bewolkt. Hier en daar vorst mogelijk. Minimaal -1C. Wind uit het O van 10 tot 15 km/u.","Overwegend bewolkt. Koel. Maximaal 4C. Wind uit het ZO van 10 tot 15 km/u.","Overwegend bewolkt. Minimaal -2C. Windkracht ZO en wisselend.","Bewolkt. Koel. Maximaal 4C. Windkracht ZZO en wisselend.","Gedeeltelijk bewolkt. Hier en daar vorst mogelijk. Minimaal 0C. Wind uit het ZZW van 10 tot 15 km/u.","Overwegend helder. Maximaal 7C. Wind uit het ZZW van 10 tot 15 km/u.","Gedeeltelijk bewolkt. Minimaal 3C. Wind uit het ZW van 15 tot 25 km/u.","Gedeeltelijk bewolkt. Maximaal 8C. Wind uit het W van 10 tot 15 km/u.","Gedeeltelijk bewolkt. Minimaal 3C. Wind uit het ZZW van 10 tot 15 km/u."],"precipChance":[10,60,10,10,10,10,10,0,0,20,10,20],"precipType":["rain","rain","rain","precip","precip","precip","precip","precip","rain","precip","rain","precip"],"qpf":[0.0,1.62,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"qpfSnow":[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"qualifierCode":[null,null,null,"Q3005","Q701",null,"Q701","Q3005",null,null,null,null],"qualifierPhrase":[null,null,null,"Hier en daar vorst mogelijk.","Koel.",null,"Koel.","Hier en daar vorst mogelijk.",null,null,null,null],"relativeHumidity":[88,91,90,93,88,89,77,69,61,77,87,93],"snowRange":["","","","","","","","","","","",""],"temperature":[7,3,6,-1,4,-2,4,0,7,3,8,3],"temperatureHeatIndex":[7,6,6,3,4,1,4,2,7,5,8,5],"temperatureWindChill":[3,2,0,-3,-4,-4,-5,-2,-3,0,2,1],"thunderCategory":[null,null,null,null,null,null,null,null,null,null,null,null],"thunderIndex":[0,0,0,0,0,0,0,0,0,0,0,0],"uvDescription":["Laag","Laag","Laag","Laag","Laag","Laag","Laag","Laag","Laag","Laag","Laag","Laag"],"uvIndex":[0,0,0,0,0,0,0,0,0,0,0,0],"windDirection":[138,116,73,94,131,142,159,193,212,228,265,206],"windDirectionCardinal":["ZO","OZO","ONO","O","ZO","ZO","ZZO","ZZW","ZZW","ZW","W","ZZW"],"windPhrase":["Wind uit het ZO van 10 tot 15 km/u.","Wind uit het OZO van 10 tot 15 km/u.","Wind uit het ONO van 10 tot 15 km/u.","Wind uit het O van 10 tot 15 km/u.","Wind uit het ZO van 10 tot 15 km/u.","Windkracht ZO en wisselend.","Windkracht ZZO en wisselend.","Wind uit het ZZW van 10 tot 15 km/u.","Wind uit het ZZW van 10 tot 15 km/u.","Wind uit het ZW van 15 tot 25 km/u.","Wind uit het W van 10 tot 15 km/u.","Wind uit het ZZW van 10 tot 15 km/u."],"windSpeed":[11,13,15,11,10,8,8,11,16,17,12,10],"wxPhraseLong":["Bewolkt","Buien","Overwegend zonnig","Gedeeltelijk bewolkt","Overwegend bewolkt","Overwegend bewolkt","Bewolkt","Gedeeltelijk bewolkt","Overwegend zonnig","Gedeeltelijk bewolkt","Gedeeltelijk bewolkt","Gedeeltelijk bewolkt"],"wxPhraseShort":["","","","","","","","","","","",""]}]}

Sorry it is in Dutch language… and something went wrong with the three backticks
What I want to achieve is to get the forecast for the current day, this means the data for the first parameter in the array. With the old Wunderground plugin I had a nice scene telling us the weather forecast via Sonos speaker when we wake up in the morning.
So for example today is Thursday in Dutch “Donderdag”)
Which expression should I use for example to get the “temperatureMax” (= 8 degrees Celsius) ?

I tried this one but this fails:

response.dayOfWeek[Donderdag].metric.temperatureMax

For this report, you would use: response.temperatureMax[1]

The temperatureMax field is an array of six values, in order by day of week starting with the first day of the report. That day of the week is response.dayOfWeek[1] for whenever the report is generated. Every top-level field except dayprt, in fact, is a multi-element array, so you just want the first element in the array for today’s value. daypart is an array with only one element, so, for example, you can access the first element of the array narrative using response.daypart[1].narrative[1]

1 Like

Hi rigpapa, many many thanks for your reply ! Now I understand the logic of the arrays. And it all works. You rock !

1 Like

Hi @rigpapa Im just setting up SS with WU - I got current data working ok but i cant get my second SiteSensor to return data even tho the query is successful. All I get in the logs is:

23:30:11: SiteSensor: Requesting JSON data
23:30:11: SiteSensor: Set up for HTTPS request, verify="none", protocol=nil, options=nil
23:30:11: SiteSensor: "GET" "https://api.weather.com/v3/wx/forecast/daily/5day?geocode=-37.80,145.33&format=json&units=m&language=en-US&apiKey=<MyKey)", headers={  }
23:30:11: SiteSensor: Eval trip expression: "response.cod == 200"=("boolean")false 

According to the API docs I should get a a lot of data:

I figure I’m missing something obvious?

You should have a state variable called RawResponse… can you post that?