New Plugin: SiteSensor

Please post the raw view, so we can see what is actually being returned.

Hi
bellow all the information returned.
Thank you.

{"controller_id":274,"customer_id":370,"user_id":297,"nextpoll":300,"sensors":[{"input":0,"type":3,"mode":0,"rate":0.5,"timer":0,"offtimer":0,"name":"Flow Meter","flow":{"week":"542 litres"},"relays":[{"id":665},{"id":464943},{"id":464944},{"id":464945},{"id":464946},{"id":464947},{"id":464948},{"id":464951}]}],"message":"","obs_rain":"0.0 mm","obs_rain_week":"0.0 mm","obs_maxtemp":"","obs_rain_upgrade":0,"obs_rain_text":"24 Hours","obs_currenttemp":"","watering_time":"68  mins","water_saving":42,"last_contact":"11 hours 5 minutes ago","forecast":[{"temp_hi":"11 C","temp_lo":"8 C","conditions":"Rain","day":"Thursday","pop":100,"humidity":92,"wind":"18 km\/h","icon":"","icon_local":"images\/wug\/rain.gif"},{"temp_hi":"14 C","temp_lo":"8 C","conditions":"Cloudy","day":"Friday","pop":68,"humidity":84,"wind":"15 km\/h","icon":"","icon_local":"images\/wug\/cloudy.gif"},{"temp_hi":"13 C","temp_lo":"5 C","conditions":"Partly Cloudy","day":"Saturday","pop":28,"humidity":83,"wind":"9 km\/h","icon":"","icon_local":"images\/wug\/partly-cloudy.gif"},{"temp_hi":"14 C","temp_lo":"9 C","conditions":"Mostly Cloudy","day":"Sunday","pop":55,"humidity":86,"wind":"10 km\/h","icon":"","icon_local":"images\/wug\/mostly-cloudy.gif"}],"status":"All good!","status_icon":"ok.png","name":"FONTES","relays":[{"relay_id":665,"relay":1,"name":"Jardim Cima (Zone1)","icon":"leaf.png","lastwater":"2 months 10 days ago","time":157680000,"run":"","type":110,"id":"665","nicetime":"Not scheduled"},{"relay_id":464943,"relay":2,"name":"Jardim Cima (Zona2)","icon":"leaf.png","lastwater":"2 months 10 days ago","time":157680000,"run":"","type":110,"id":"464943","nicetime":"Not scheduled"},{"relay_id":464944,"relay":3,"name":"Jardim Cima (Zona3)","icon":"leaf.png","lastwater":"2 months 10 days ago","time":157680000,"run":"","type":110,"id":"464944","nicetime":"Not scheduled"},{"relay_id":464945,"relay":4,"name":"Zardim Cima (Vasos)","icon":"can.png","lastwater":"1 day 10 hours ago","time":50023,"type":1,"run":"9 minutes","run_seconds":540,"nicetime":"Fri, 24th Jan 6:00am"},{"relay_id":464947,"relay":5,"name":"Jardim Baixo (Zona1)","icon":"light.png","lastwater":"2 months 10 days ago","time":157680000,"run":"","type":110,"id":"464947","nicetime":"Not scheduled"},{"relay_id":464948,"relay":6,"name":"Jardim Baixo (Zona2)","icon":"light.png","lastwater":"2 months 10 days ago","time":157680000,"run":"","type":110,"id":"464948","nicetime":"Not scheduled"},{"relay_id":464946,"relay":7,"name":"Jardim Baixo (Vasos)","icon":"can.png","lastwater":"1 day 9 hours ago","time":50563,"type":1,"run":"2 minutes","run_seconds":120,"nicetime":"Fri, 24th Jan 6:09am"},{"relay_id":464951,"relay":8,"name":"Torneiras Externas","icon":"spray.png","lastwater":"1 month 9 days ago","time":157680000,"run":"","type":110,"id":"464951","nicetime":"Not scheduled"}]}

Arrays in SiteSensor (and Lua) are 1-based, not 0-based, and you have to use array notation, not dot notation, to index through an array:

response.sensors[1].flow.week

1 Like

Thank you
Is working perfectly now.
How can i donate?

1 Like

In the footer of the “Settings” tab, the “a small donation” part is linked to my donation page: Donations | toggledbits

Done.
Thank you

1 Like

@rigpapa,

I am using Sitesensor to pull weather data from DarkSky’s API. There appears to be some issue with the API that is affecting another plugin ([Plugin]DarkSky Weather - #157 by Tim88 - General Plugin Discussion - Ezlo Community).

When I query the URL from the browser I get a valid JSON response. Sitesensor is showing “Request returned no data” and my VeraPlus is showing “Can’t detect device” for the SiteSensor device.

Is it normal for Vera to lose connection to the SiteSensor and show it offline when there is no data returned? Any idea why I can get what looks like valid data from the browser but not through the Vera?

When rebooting the Vera it will initially say the SiteSensor is back online, but looking at the SiteSensor I see it shows offline and still has no data in the response.

Looks like something in a Homeseer forum may explain why Vera can’t get a response and the browser can:

From DarkSky:

"Apologies for the trouble here. At 5 PM Eastern Standard Time yesterday (March 4, 2020), we applied a few security updates in line with the recommendations of a recent security audit, then reverted it over the weekend and reapplied it yesterday at 5 PM EST. This has resulted in us ultimately dropping the following SSL protocols and ciphers:

TLS 1.0
TLS 1.1
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
TLS_RSA_WITH_AES_128_GCM_SHA256
TLS_RSA_WITH_AES_128_CBC_SHA256
TLS_RSA_WITH_AES_128_CBC_SHA
TLS_RSA_WITH_AES_256_GCM_SHA384
TLS_RSA_WITH_AES_256_CBC_SHA256
TLS_RSA_WITH_AES_256_CBC_SHA"

If you are on firmware 7.29 or older, or on a Vera Edge with any current released firmware, the LuaSec library may not be able to handle the encryption requirements of many sites as they audit and upgrade.

Users on 7.3x should set SSLProtocol to any in your SiteSensors.

I have been migrating my old Vera3 and PLEGs (UI5) to VeraPlus with Reactor and SiteSensor (UI7). I have been playing with the Dark Sky API and have a question about the Time Machine API and how to use it with SiteSensor. The URL is https://api.darksky.net/forecast/[key]/[latitude],[longitude],[time]. I am interested in finding the rain intensity (accumulation) from yesterday and the day before. So the URL needs to change every day in order to include the proper [time] parameter.

What is the best way to have a dynamic Request URL in SiteSensor? Should I just have a Reactor Activity that fires once a day and updates the Request URL? And if I do this, does the sensor need to be restarted somehow?

I am also thinking that SiteSensor may be overkill for the historical data since I really only need it once a day (before my sprinklers are set to run). Perhaps I should just have a Reactor expression or activity that pulls the information that I need? The data element that I am interested in the Dark Sky JSON response is response.daily.data[1.].precipIntensity*24 so I would need a way to find this data element in Reactor.

There is no dynamic URL currently in SiteSensor, only dynamic query parameters, so having Reactor re-write the URL is the way to go. There’s a SetRequestURL action you can use for this purpose. There is a DoRequest action you can run to force a new query.

In Reactor 3.6, I’ve basically integrated SiteSensor: you can run a GET or POST to a remote API, with variable substitution in the URL, query parameters or POST data, and receive the response into a Reactor expression-less variable that you can then pick apart as you do in SiteSensor. You could install that version from the Github stable branch, if you wish


2 Likes

I’m having an issue with my SiteSensor pulling down data from my Ambient Weather Station via their API. Full disclosure, they’ve been having API issues but I can take the URL from SiteSensor and hit it with a browser no problem (and get current, correct data as a result.)

Here’s where it spends its days, presumably hung:
image

It is set to poll every :60 and timeout at :30.

Any thoughts?

Try setting SSLProtocol:

  • If you are running a Plus or Secure on 7.30 or higher, set it to any
  • Otherwise, set it to tlsv1

Hopefully by polling every “:60” you mean 60 minutes, but given your timeout, I’m thinking it may be seconds. That’s too frequent. The weather report probably doesn’t change much in a minute. But equally important, the overuse of APIs is one of the ways that free APIs get shut down–be a good custodian of the free resource and use it as minimally as is necessary to get the job done. Even if it’s a paid resource, there are often API limits/quotas, and you hitting them also could be a contributor to inconsistent performance.

Ah, this got me a response - albeit a HTTP 500 lol But this may be due to the issues at the vendor side.

I do have the calls set to 60 seconds and have for probably a year or so as this controls my HVAC. I can bump it out to a couple minutes.

image

So this is new: when it calls and gets the HTTP 500 now Vera shows this for the SiteSensor device.
image

That’s normal. If you don’t want it to mark the device failed, just set DeviceErrorOnFailure to 0.

You can also monitor the state of the Failed variable if you want notifications of problems through other mechanisms.

1 Like

EDIT:

I made a brand new sitesensor rather than trying to modify the existing one that I had used for DarkSky. That seems to have sorted it.


@rigpapa I am trying to switch a SiteSensor from DarkSky to the NWS API and I’m having a strange issue that I can’t figure out.

See the logs below
When looking at the response I can’t see any difference between the temperature data windgust data.

You can see it shows temperature as a table, but it doesn’t show that it has a value entry. It thinks temperature.value is also a table. Also for some reason it shows the value of windGust last while it is actually first in the raw data. I’m stumped.

Here are the raw data of just those nodes - see the URL in the log to see the whole response. If you pull the full response, elevation is working properly like windGust and dewpoint is acting weird like temperature.

 "temperature": {
            "value": 13.600000000000023,
            "unitCode": "unit:degC",
            "qualityControl": "qc:V"
        },

and

 "windGust": {
            "value": 9.8000000000000007,
            "unitCode": "unit:m_s-1",
            "qualityControl": "qc:S"
        },

SiteSensor log:

12:18:56: SiteSensor: Requesting JSON data
12:18:56: SiteSensor: Set up for HTTPS request, verify="none", protocol="any", options=nil
12:18:56: SiteSensor: "GET" "https://api.weather.gov/stations/KCGS/observations/latest", headers={  }
12:18:56: SiteSensor: Eval #1: "response.properties.temperature"=("table"){ unitCode="unit:degC", qualityControl="qc:Z" }
12:18:56: SiteSensor: Eval #2: "response.properties.temperature.value"=("table"){ ["__type"]="null" }
12:18:56: SiteSensor: Eval #3: "response.properties.windGust"=("table"){ unitCode="unit:m_s-1", qualityControl="qc:S", value=9.8 }
12:18:56: SiteSensor: Eval #4: "response.properties.windGust.value"=("number")9.8

I vote this thread be promoted to its own SiteSensor heading under Plugins & Plugin Development.

2 Likes

I made this switch of DeviceErrorOnFailure to 0 and this did not change the issue. Still shows as the original screenshot.

That being said, thank you for sparking a thought>idea>change in which I created a duplicate sensor for my downstairs HVAC Master and set it to pull from Dark Sky plugin. I then created a completely new one to monitor SiteSensorAmbientAPI for failure and, if detected, it disables the main HVAC Master for downstairs and enables the back-up using Dark Sky
 essentially a failover/failback situation.

I want to watch this topic carefully for two reasons: I’m using Dark Sky API to run some HA things but also using it to provide weather forecasts for a local LP radio station. I need to make the jump to NWS data.