They are state variables. They are not part of the response, or a manufactured/fake response generated on error. You need to read them as you would any other state variable.
OK. Show me what you have working, and what you have tried that doesn’t work.
Ok, got it
@rigpapa
I really like Sitesensor! I use it to get weather data and forecast of my PWS that is connected to Wunderground.
Now I used recipe to transfer 3 Sitesensors (with 8 sensors each) to another Vera controller. This went fine and fast ( saved me a lot of time). But I noticed one bug: in all 3 cases sensor nr 8 was not transferred. So I had to copy paste these manually into the new ones. Not a big deal but still good to report it.
Can you send me your recipe?
How should I do this?
Knowing the next trash collection date can be handy. In Helsinki area the waste management authority has API service from where this information can be fetched. Intructions can be found here: HSY eRaportin tilastorajapinta. You will need to create own “list ID” for API query based on customer info found from your invoice.
The next collection date can be taken from response by:
response.statisticsDetails[1].wasteCustomerDetails.collectionPoints[1].containers[1].nextCollectionDate
and it is formatted as dd.mm.yy.
I then use this date in Reactor to calculate how many days until next collection:
datediff(date(sub(getstate( "Site Sensor", "urn:toggledbits-com:serviceId:SiteSensor1", "Value1" ),7,8)+2000,sub(getstate( "Site Sensor", "urn:toggledbits-com:serviceId:SiteSensor1", "Value1" ),4,5),sub(getstate( "Site Sensor", "urn:toggledbits-com:serviceId:SiteSensor1", "Value1" ),1,2)), time())/86400
Works, but maybe not so elegant. Is there better way? Or could sitesensor itself do the conversion?
Here is the Sitesensor recipe:
=== Ident: HSY Trash Collection Date version 20353.1523 by Vpow; Fetches next trash collection date in format dd.mm.yy. === BEGIN SITESENSOR RECIPE === ewogICAgIm5hbWUiOiAiSFNZIFRyYXNoIENvbGxlY3Rpb24gRGF0ZSIsCiAgICAiYXV0aG9yIjog IlZwb3ciLAogICAgImRlc2NyaXB0aW9uIjogIkZldGNoZXMgbmV4dCB0cmFzaCBjb2xsZWN0aW9u IGRhdGUgaW4gZm9ybWF0IGRkLm1tLnl5LiIsCiAgICAiY29uZmlnIjogewogICAgICAgICJSZXF1 ZXN0VVJMIjogImh0dHBzOi8vcmFwb3J0aXQuaHN5LmZpOjg0NDMvcmVwb3J0L3Jlc3QvdjEvZGV0 YWlscy93YXN0ZS9ZT1VSTElTVElEL2ZpIiwKICAgICAgICAiSGVhZGVycyI6ICJDb250ZW50LXR5 cGU6IGFwcGxpY2F0aW9uL2pzb247Y2hhcnNldD1VVEYtOHxYLUFQSS1LRVk6IEhTWVRFU1Q1MV85 Tk9Pek92NzdwRDRNaHgyS2dvbDg2TkZTZGw5cnBPUEdOemxRMEE3IiwKICAgICAgICAiSW50ZXJ2 YWwiOiAiMzYwMCIsCiAgICAgICAgIlRpbWVvdXQiOiAiMzAiLAogICAgICAgICJRdWVyeUFybWVk IjogIjEiLAogICAgICAgICJSZXNwb25zZVR5cGUiOiAianNvbiIsCiAgICAgICAgIlRyaWdnZXIi OiAiZXJyIiwKICAgICAgICAiTnVtRXhwIjogIjgiLAogICAgICAgICJGYWlsTWFzdGVyT25FeHBy ZXNzaW9uRXJyb3IiOiAiMSIsCiAgICAgICAgIkZhaWxDaGlsZE9uRXhwcmVzc2lvbkVycm9yIjog IjEiLAogICAgICAgICJCbGFua0NoaWxkT25FeHByZXNzaW9uRXJyb3IiOiAiMCIsCiAgICAgICAg IkV4cHIxIjogInJlc3BvbnNlLnN0YXRpc3RpY3NEZXRhaWxzWzFdLndhc3RlQ3VzdG9tZXJEZXRh aWxzLmNvbGxlY3Rpb25Qb2ludHNbMV0uY29udGFpbmVyc1sxXS5uZXh0Q29sbGVjdGlvbkRhdGUi CiAgICB9LAogICAgInNvdXJjZSI6ICIyMDA5NSIsCiAgICAidmVyc2lvbiI6ICIyMDM1My4xNTIz Igp9 === END SITESENSOR RECIPE ===
LuaXP can accept a date string directly and will attempt conversion. It will try to guess the order of the date parts by using the locale’s default date formatting settings (i.e. if your locale formats August 2 2001 as 2/8/2001, then LuaXP will try D/M/Y order first).
The way to test this is to do strftime( "%x" )
and see what the output is. If it’s D/M/Y, the same order as your query produces, then we can just change the “.” in your response data to “-” or “/” and pass it directly to LuaXP’s time()
function for parsing:
time( replace( response.statisticsDetails[1].wasteCustomerDetails.collectionPoints[1].containers[1].nextCollectionDate, "%.", "-" ) )
This just uses replace()
to replace the dots with dashes, which LuaXP’s date parser will accept. Note that the dot is escaped with “%” because it’s a special character in Lua patterns (means match any character if not escaped by “%”).
Tried this and here is the result ([1] is the original string response and [2] is converted by time():
But if that timestamp is converted to date it gives 29th Dec, not 30th as it should be.
The reason is that time() handles times in UTC while my location is in EET zone. The difference is 2 or 3 hours depending whether daylight savings is applied. So to get the conversion working the max. offset must be accounted:
time( replace( response.statisticsDetails[1].wasteCustomerDetails.collectionPoints[1].containers[1].nextCollectionDate, "%.", "-" ) +" +3:00:00")
If you are only using the date part, you can either offset it explicitly by adding 10800 to offset the three hours, or you can give the time zone offset to time()
by adding " 00:00:00+0300" to the result string. Either way, the time may be wrong for part of the year, but since you are only using the date, it should be correct in and out of DST.
Hi I’m trying to set this awesome plugin up with my Ambient Weather station but keep running into HTTP server error 500. I’ve scoured the forums and tried changing the SSL protocol to any. I’m using UI7 and installed via AltUI GitHub repo. Below is the log from the variables section, I’m not sure what I’m doing wrong, any help would be appreciated. Thank you!
08:08:42: SiteSensor: Requesting JSON data
08:08:42: SiteSensor: Set up for HTTPS (“0.8”) request, verify=“none”, protocol=“any”, options=nil
08:08:42: SiteSensor: “GET” “https://api.ambientweather.net/v1/devices?apiKey=XXX&applicationKey=XXX&limit=1”, headers={ }
08:08:42: SiteSensor: Request returned no data, status 500
I also want to add when I visit the ambient weather url from my browser it works and shows the JSON data.
SSLProtocol: any
SSLOptions: all
I just gave that a try and getting the same 500 error
10:54:06: SiteSensor: Requesting JSON data
10:54:06: SiteSensor: Set up for HTTPS (“0.8”) request, verify=“none”, protocol=“any”, options={ [“1”]=“all” }
10:54:06: SiteSensor: “GET” “https://api.ambientweather.net/v1/devices?apiKey=xxxxx&applicationKey=xxxxx&limit=1”, headers={ }
10:54:06: SiteSensor: Request returned no data, status 500
First try setting SSLProtocol
to tlsv1_2
.
If that doesn’t work, set UseCurl
to 1.
UseCurl set to 1 worked. Thank you!
In your docs you say you can run multiple instances? The instructions describe how to do this on vera. How do I get a second instance on ALTui?
Querying More than One Site
You can probe as many different sites as you want. Each SiteSensor plugin device will only query one site, but you can create additional instances of SiteSensor by going to “Apps > My apps” in the Vera dashboard, clicking the “Details” button for SiteSensor, and then clicking the “Create another” button.
How to make Sitesensor to do request only on certain time point?
I used Reactor to trigger action on certain time and tried putting DoRequest there. Sitesensor makes the request only if it is armed. But if it is armed, it will make request also on given interval, which is not wanted.
Do I have to put arm then immediately disarm to Reactor action? Or can the interval in sitesensor be disabled somehow?
WIth testing I got following results:
*Setting Reactor activity to arm and then immediately disarm sitesensor does not work.
*Setting Reactor activity to arm, delay 10s and then disarm sitesensor works.
*Setting sitesensor initially to armed state and setting sitesensor request interval longer than request interval coming from Reactor activity using DoRequest works. DoRequest seems to reset sitesensor interval timer and thats why this works.
So it can be done!
Proposal for Sitesensor development: if request interval is set to 0, then sensor just stays in armed state and makes requests only if someone calls DoRequest.
Is it possible to use SiteSensor to inspect the content of a TXT file in a cloud store, e.g. Dropbox, Google Drive etc?