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:
- Go to the Github stable branch for the project: GitHub - toggledbits/SiteSensor at stable
- Click the green âClone or downloadâ button, choose âDownload ZIPâ, save the archive somewhere.
- Unzip the archive.
- Open the Vera uploader at Apps > Develop apps > Luup files
- Multi-select and drag, as a group, the unzipped files (not folder) to the âUploadâ button in the Vera UI.
- 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.
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]
Hi rigpapa, many many thanks for your reply ! Now I understand the logic of the arrays. And it all works. You rock !
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?
Hi Patrick, it contains the following:
{"dayOfWeek":["Thursday","Friday","Saturday","Sunday","Monday","Tuesday"],"expirationTimeUtc":[1578517357,1578517357,1578517357,1578517357,1578517357,1578517357],"moonPhase":["Waxing Gibbous","Full Moon","Full Moon","Waning Gibbous","Waning Gibbous","Waning Gibbous"],"moonPhaseCode":["WXG","F","F","WNG","WNG","WNG"],"moonPhaseDay":[13,14,15,16,17,18],"moonriseTimeLocal":["2020-01-09T19:20:14+1100","2020-01-10T20:21:29+1100","2020-01-11T21:16:50+1100","2020-01-12T22:06:22+1100","2020-01-13T22:49:17+1100","2020-01-14T23:26:27+1100"],"moonriseTimeUtc":[1578558014,1578648089,1578737810,1578827182,1578916157,1579004787],"moonsetTimeLocal":["2020-01-09T04:18:07+1100","2020-01-10T05:08:52+1100","2020-01-11T06:08:32+1100","2020-01-12T07:14:39+1100","2020-01-13T08:25:44+1100","2020-01-14T09:37:16+1100"],"moonsetTimeUtc":[1578503887,1578593332,1578683312,1578773679,1578864344,1578955036],"narrative":["Plenty of sun. Highs 32 to 34C and lows 20 to 22C.","Rain developing during the afternoon. Highs 30 to 32C and lows 11 to 13C.","Clouds giving way to sun . Highs 17 to 19C and lows 10 to 12C.","Times of sun and clouds. Highs 21 to 23C and lows 10 to 12C.","Mainly sunny. Highs 30 to 32C and lows 13 to 15C.","Partly cloudy. Highs 27 to 29C and lows 14 to 16C."],"qpf":[0.0,13.27,0.0,0.0,0.0,0.0],"qpfSnow":[0.0,0.0,0.0,0.0,0.0,0.0],"sunriseTimeLocal":["2020-01-09T06:06:35+1100","2020-01-10T06:07:33+1100","2020-01-11T06:08:32+1100","2020-01-12T06:09:32+1100","2020-01-13T06:10:33+1100","2020-01-14T06:11:35+1100"],"sunriseTimeUtc":[1578510395,1578596853,1578683312,1578769772,1578856233,1578942695],"sunsetTimeLocal":["2020-01-09T20:44:13+1100","2020-01-10T20:44:04+1100","2020-01-11T20:43:54+1100","2020-01-12T20:43:41+1100","2020-01-13T20:43:27+1100","2020-01-14T20:43:10+1100"],"sunsetTimeUtc":[1578563053,1578649444,1578735834,1578822221,1578908607,1578994990],"temperatureMax":[33,31,18,22,31,28],"temperatureMin":[21,12,11,11,14,15],"validTimeLocal":["2020-01-09T07:00:00+1100","2020-01-10T07:00:00+1100","2020-01-11T07:00:00+1100","2020-01-12T07:00:00+1100","2020-01-13T07:00:00+1100","2020-01-14T07:00:00+1100"],"validTimeUtc":[1578513600,1578600000,1578686400,1578772800,1578859200,1578945600],"daypart":[{"cloudCover":[18,51,71,73,59,54,40,5,7,34,54,42],"dayOrNight":["D","N","D","N","D","N","D","N","D","N","D","N"],"daypartName":["Today","Tonight","Tomorrow","Tomorrow night","Saturday","Saturday night","Sunday","Sunday night","Monday","Monday night","Tuesday","Tuesday night"],"iconCode":[34,29,12,12,30,29,30,31,32,33,30,29],"iconCodeExtend":[3400,2900,7303,1200,9003,2900,3000,3100,3200,3300,3000,2900],"narrative":["Partly cloudy. High 33C. Winds SSE at 10 to 15 km/h.","Partly cloudy skies. Low 21C. ESE winds shifting to NNE at 15 to 30 km/h.","Partly cloudy skies during the morning hours will give way to cloudy skies and rain in the afternoon. High 31C. N winds shifting to WSW at 15 to 30 km/h. Chance of rain 100%. Rainfall around 6mm.","Rain early...then remaining cloudy with showers late. Low 12C. Winds WSW at 15 to 25 km/h. Chance of rain 100%. Rainfall around 6mm.","Cloudy early with partial sunshine expected late. Turning cooler. High 18C. Winds SW at 15 to 30 km/h.","Partly cloudy early with increasing clouds overnight. Low 11C. Winds S at 15 to 25 km/h.","Sunshine and clouds mixed. High 22C. Winds SSE at 15 to 25 km/h.","A mostly clear sky. Low 11C. S winds shifting to NE at 15 to 25 km/h.","A mainly sunny sky. High 31C. Winds NNW at 15 to 25 km/h.","Clear skies with a few passing clouds. Low 14C. Winds SSW at 10 to 15 km/h.","Partly cloudy. High 28C. Winds S at 15 to 25 km/h.","Partly cloudy. Low around 15C. Winds S at 10 to 15 km/h."],"precipChance":[0,0,100,100,20,10,10,10,10,10,10,20],"precipType":["rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain"],"qpf":[0.0,0.0,7.68,5.59,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,null,"Q775",null,null,null,null,null,null,null],"qualifierPhrase":[null,null,null,null,"Turning cooler.",null,null,null,null,null,null,null],"relativeHumidity":[58,64,57,93,65,76,62,82,50,75,63,79],"snowRange":["","","","","","","","","","","",""],"temperature":[33,21,31,12,18,11,22,11,31,14,28,15],"temperatureHeatIndex":[32,30,32,15,18,16,21,20,30,28,28,26],"temperatureWindChill":[16,21,15,11,11,11,11,10,12,15,15,16],"thunderCategory":["No thunder","No thunder","No thunder","No thunder","No thunder","No thunder","No thunder","No thunder","No thunder","No thunder","No thunder","No thunder"],"thunderIndex":[0,0,0,0,0,0,0,0,0,0,0,0],"uvDescription":["Extreme","Low","Very High","Low","Very High","Low","Extreme","Low","Extreme","Low","Very High","Low"],"uvIndex":[11,0,8,0,10,0,11,0,11,0,10,0],"windDirection":[153,67,306,240,215,188,168,157,329,213,189,180],"windDirectionCardinal":["SSE","ENE","NW","WSW","SW","S","SSE","SSE","NNW","SSW","S","S"],"windPhrase":["Winds SSE at 10 to 15 km/h.","ESE winds shifting to NNE at 15 to 30 km/h.","N winds shifting to WSW at 15 to 30 km/h.","Winds WSW at 15 to 25 km/h.","Winds SW at 15 to 30 km/h.","Winds S at 15 to 25 km/h.","Winds SSE at 15 to 25 km/h.","S winds shifting to NE at 15 to 25 km/h.","Winds NNW at 15 to 25 km/h.","Winds SSW at 10 to 15 km/h.","Winds S at 15 to 25 km/h.","Winds S at 10 to 15 km/h."],"windSpeed":[14,21,26,18,21,19,18,17,19,13,17,16],"wxPhraseLong":["Mostly Sunny","Partly Cloudy","PM Rain","Rain","AM Clouds/PM Sun","Partly Cloudy","Partly Cloudy","Clear","Sunny","Mostly Clear","Partly Cloudy","Partly Cloudy"],"wxPhraseShort":["M Sunny","P Cloudy","PM Rain","Rain","AM Clouds","P Cloudy","P Cloudy","Clear","Sunny","M Clear","P Cloudy","P Cloudy"]}]}
OK. So right from the get-go, the trip expression is making reference to data that doesnât exist in the response. You need to check all of your expressions.
Ok, Im a total n00b when it comes to JSON etc, how do I use SS to extract data from this return? I dont have any expressions setup because I dont really know what im doing (I used other pplâs examples to get current conditions working).
Now that I see the data, it is the same as @Mai_Pensato was just asking about earlier in this thread, so really, this question has already been answered, but for the sake of detailâŠ
If we run your response through jsonlint.com, it looks like this (much more readable for structure):
{
"dayOfWeek": ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"],
"expirationTimeUtc": [1578517357, 1578517357, 1578517357, 1578517357, 1578517357, 1578517357],
"moonPhase": ["Waxing Gibbous", "Full Moon", "Full Moon", "Waning Gibbous", "Waning Gibbous", "Waning Gibbous"],
"moonPhaseCode": ["WXG", "F", "F", "WNG", "WNG", "WNG"],
"moonPhaseDay": [13, 14, 15, 16, 17, 18],
"moonriseTimeLocal": ["2020-01-09T19:20:14+1100", "2020-01-10T20:21:29+1100", "2020-01-11T21:16:50+1100", "2020-01-12T22:06:22+1100", "2020-01-13T22:49:17+1100", "2020-01-14T23:26:27+1100"],
"moonriseTimeUtc": [1578558014, 1578648089, 1578737810, 1578827182, 1578916157, 1579004787],
"moonsetTimeLocal": ["2020-01-09T04:18:07+1100", "2020-01-10T05:08:52+1100", "2020-01-11T06:08:32+1100", "2020-01-12T07:14:39+1100", "2020-01-13T08:25:44+1100", "2020-01-14T09:37:16+1100"],
"moonsetTimeUtc": [1578503887, 1578593332, 1578683312, 1578773679, 1578864344, 1578955036],
"narrative": ["Plenty of sun. Highs 32 to 34C and lows 20 to 22C.", "Rain developing during the afternoon. Highs 30 to 32C and lows 11 to 13C.", "Clouds giving way to sun . Highs 17 to 19C and lows 10 to 12C.", "Times of sun and clouds. Highs 21 to 23C and lows 10 to 12C.", "Mainly sunny. Highs 30 to 32C and lows 13 to 15C.", "Partly cloudy. Highs 27 to 29C and lows 14 to 16C."],
"qpf": [0.0, 13.27, 0.0, 0.0, 0.0, 0.0],
"qpfSnow": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
"sunriseTimeLocal": ["2020-01-09T06:06:35+1100", "2020-01-10T06:07:33+1100", "2020-01-11T06:08:32+1100", "2020-01-12T06:09:32+1100", "2020-01-13T06:10:33+1100", "2020-01-14T06:11:35+1100"],
"sunriseTimeUtc": [1578510395, 1578596853, 1578683312, 1578769772, 1578856233, 1578942695],
"sunsetTimeLocal": ["2020-01-09T20:44:13+1100", "2020-01-10T20:44:04+1100", "2020-01-11T20:43:54+1100", "2020-01-12T20:43:41+1100", "2020-01-13T20:43:27+1100", "2020-01-14T20:43:10+1100"],
"sunsetTimeUtc": [1578563053, 1578649444, 1578735834, 1578822221, 1578908607, 1578994990],
"temperatureMax": [33, 31, 18, 22, 31, 28],
"temperatureMin": [21, 12, 11, 11, 14, 15],
"validTimeLocal": ["2020-01-09T07:00:00+1100", "2020-01-10T07:00:00+1100", "2020-01-11T07:00:00+1100", "2020-01-12T07:00:00+1100", "2020-01-13T07:00:00+1100", "2020-01-14T07:00:00+1100"],
"validTimeUtc": [1578513600, 1578600000, 1578686400, 1578772800, 1578859200, 1578945600],
"daypart": [{
"cloudCover": [18, 51, 71, 73, 59, 54, 40, 5, 7, 34, 54, 42],
"dayOrNight": ["D", "N", "D", "N", "D", "N", "D", "N", "D", "N", "D", "N"],
"daypartName": ["Today", "Tonight", "Tomorrow", "Tomorrow night", "Saturday", "Saturday night", "Sunday", "Sunday night", "Monday", "Monday night", "Tuesday", "Tuesday night"],
"iconCode": [34, 29, 12, 12, 30, 29, 30, 31, 32, 33, 30, 29],
"iconCodeExtend": [3400, 2900, 7303, 1200, 9003, 2900, 3000, 3100, 3200, 3300, 3000, 2900],
"narrative": ["Partly cloudy. High 33C. Winds SSE at 10 to 15 km/h.", "Partly cloudy skies. Low 21C. ESE winds shifting to NNE at 15 to 30 km/h.", "Partly cloudy skies during the morning hours will give way to cloudy skies and rain in the afternoon. High 31C. N winds shifting to WSW at 15 to 30 km/h. Chance of rain 100%. Rainfall around 6mm.", "Rain early...then remaining cloudy with showers late. Low 12C. Winds WSW at 15 to 25 km/h. Chance of rain 100%. Rainfall around 6mm.", "Cloudy early with partial sunshine expected late. Turning cooler. High 18C. Winds SW at 15 to 30 km/h.", "Partly cloudy early with increasing clouds overnight. Low 11C. Winds S at 15 to 25 km/h.", "Sunshine and clouds mixed. High 22C. Winds SSE at 15 to 25 km/h.", "A mostly clear sky. Low 11C. S winds shifting to NE at 15 to 25 km/h.", "A mainly sunny sky. High 31C. Winds NNW at 15 to 25 km/h.", "Clear skies with a few passing clouds. Low 14C. Winds SSW at 10 to 15 km/h.", "Partly cloudy. High 28C. Winds S at 15 to 25 km/h.", "Partly cloudy. Low around 15C. Winds S at 10 to 15 km/h."],
"precipChance": [0, 0, 100, 100, 20, 10, 10, 10, 10, 10, 10, 20],
"precipType": ["rain", "rain", "rain", "rain", "rain", "rain", "rain", "rain", "rain", "rain", "rain", "rain"],
"qpf": [0.0, 0.0, 7.68, 5.59, 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, null, "Q775", null, null, null, null, null, null, null],
"qualifierPhrase": [null, null, null, null, "Turning cooler.", null, null, null, null, null, null, null],
"relativeHumidity": [58, 64, 57, 93, 65, 76, 62, 82, 50, 75, 63, 79],
"snowRange": ["", "", "", "", "", "", "", "", "", "", "", ""],
"temperature": [33, 21, 31, 12, 18, 11, 22, 11, 31, 14, 28, 15],
"temperatureHeatIndex": [32, 30, 32, 15, 18, 16, 21, 20, 30, 28, 28, 26],
"temperatureWindChill": [16, 21, 15, 11, 11, 11, 11, 10, 12, 15, 15, 16],
"thunderCategory": ["No thunder", "No thunder", "No thunder", "No thunder", "No thunder", "No thunder", "No thunder", "No thunder", "No thunder", "No thunder", "No thunder", "No thunder"],
"thunderIndex": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"uvDescription": ["Extreme", "Low", "Very High", "Low", "Very High", "Low", "Extreme", "Low", "Extreme", "Low", "Very High", "Low"],
"uvIndex": [11, 0, 8, 0, 10, 0, 11, 0, 11, 0, 10, 0],
"windDirection": [153, 67, 306, 240, 215, 188, 168, 157, 329, 213, 189, 180],
"windDirectionCardinal": ["SSE", "ENE", "NW", "WSW", "SW", "S", "SSE", "SSE", "NNW", "SSW", "S", "S"],
"windPhrase": ["Winds SSE at 10 to 15 km/h.", "ESE winds shifting to NNE at 15 to 30 km/h.", "N winds shifting to WSW at 15 to 30 km/h.", "Winds WSW at 15 to 25 km/h.", "Winds SW at 15 to 30 km/h.", "Winds S at 15 to 25 km/h.", "Winds SSE at 15 to 25 km/h.", "S winds shifting to NE at 15 to 25 km/h.", "Winds NNW at 15 to 25 km/h.", "Winds SSW at 10 to 15 km/h.", "Winds S at 15 to 25 km/h.", "Winds S at 10 to 15 km/h."],
"windSpeed": [14, 21, 26, 18, 21, 19, 18, 17, 19, 13, 17, 16],
"wxPhraseLong": ["Mostly Sunny", "Partly Cloudy", "PM Rain", "Rain", "AM Clouds/PM Sun", "Partly Cloudy", "Partly Cloudy", "Clear", "Sunny", "Mostly Clear", "Partly Cloudy", "Partly Cloudy"],
"wxPhraseShort": ["M Sunny", "P Cloudy", "PM Rain", "Rain", "AM Clouds", "P Cloudy", "P Cloudy", "Clear", "Sunny", "M Clear", "P Cloudy", "P Cloudy"]
}]
}
Unfortunately, this isnât the simplest structure to play with as a learning tool⊠pretty much every element is an array. Each element in these arrays corresponds to the data for an upcoming day of the week.
To refer to a data element in the response in SiteSensor, we use expressions using response
as the root of the response tree. So, response.dayOfWeek
refers to the array of weekday names. We use array indexes as we do in Lua, so response.dayOfWeek[1]
gives us the first element in that array, which for this response is âThursdayâ.
If we use the expression response.moonPhase[1]
we get âWaxing Gibbousââthe moon phase for the first day of the response (Thursday, according to the dayOfWeek
index).
The expected temperature min and max for the first day of the report are response.temperatureMin[1]
and response.temperatureMax[1]
respectively.
The daypart
element is structured differently from the rest. Itâs just an array of one element (I hate when they do that)âyou can tell by the presence of the square opening bracket following the âdaypartâ key name. And then it looks like everything within that is an array of current and upcoming periods (see the contents of daypartName
). Assuming the first element of all these is the current weather:
-
response.daypart[1].temperature[1]
is the current temperature; -
response.daypart[1].relativeHumidity[1]
is the current humidity %; -
response.daypart[1].windSpeed[1]
is the current wind speed; -
response.daypart[1].wxPhraseLong[1]
is the text of what it should look like outside the window; - and so onâŠ
In your SiteSensor, response type should obviously be âJSON dataâ. Make the trigger type âURL unreachableâ. For the value expressions, put in the expressions (using the above as a guide) to fetch the data out into simple value variables on the SiteSensor instance. You can also optionally export those to virtual sensor that SiteSensor will create and maintain, so for example, you can pull response.daypart[1].temperature[1]
(the current temperature) and export it to a virtual temperature sensor you can then easily use as a scene trigger, in Reactor, etc.
Thanks Patrick, that was a great explanation and I was able to extract all the info I was after. Iâm mainly after these for automation so I just leave it all in the Value fields and point reactor sensors to those instead of making child sensors.
I can see a lot of Yoda in PatrickâŠ