New Plugin: SiteSensor

Thanks @LibraSun - that’s much easier!

1 Like

Hello Rigpapa,
As usual, excellent work.
Just one noob question.
I’m using this plugin for civil twilight.
If I’m ok with location, I don’t know how to feed the date and tzoffset. See below if I’m not clear

https://api.sunrise-sunset.org/json?lat=65;765987&lng=6.89574&date=**[isodate]**T12:00:00**[tzoffset]**&formatted=0

The plugin will supply those. They are special keywords the plugin understands (you could have left the latitute and longitude ones in place as well). As long as your Vera timezone and location settings are correct, you should be good to go…

Perfectly clear !
But 1 and 2 values never show true or false statut ?

For some reason (which I don’t quite understand and the SiteSensor docs don’t appear to address?), my SiteSensor keeps switching itself to “Unarmed”.

It’s not something I often check, but every time I do think to look at SiteSensor – all it does is pull in weather info from OpenWeatherMap – it shows itself not to be Armed, and so I switch it back to Armed status. Weird!

I can confirm that the recipe I’m using is basic and not failing in any way. Should I be watching for another condition that might cause this issue?

EDIT: Oops, let me check House Mode. Not used to dealing with sensors, and recall that Vera defaults to un-Armed except for ‘Away’, so I may have to assert the ‘Armed’ setting manually.

UPDATE: Yep, that was the cause. Plus, I remembered that SiteSensor lets me uncheck “Only ping when armed” under Settings, which also solves the problem.

Hello guys!
I’m trying to set up the Openweather API, but I’m not getting it!
You’re giving me this shot …


I leave the printout of the configuration!
[DELETED BY MODERATOR]
Pulling on the api in the Browser gives me the information …
What can it be?
I don’t know anything about programming languages!

Thank you all and sorry

Don’t literally put the word “none” in header field. It should be blank/empty.

Also, be careful posting screen shots that contain your application keys and other private data.

Post the contents of the request log (the text, not a screen shot)

I’ve tried both ways, but nothing … :frowning:imagem

Here it is :

16:35:24: SiteSensor: Requesting JSON data
16:35:24: SiteSensor: Set up for HTTPS (“0.8”) request, verify=“none”, protocol=“any”, options=nil
16:35:24: SiteSensor: “GET” “https://api.sunrise-sunset.org/json?lat=43.376850&lng=5.645812&date=2020-04-13T12:00:00-0200&formatted=0”, headers={ }
16:35:25: SiteSensor: Response is 482 bytes in “/tmp/Q_SiteSensor_395.txt”
16:35:25: SiteSensor: Eval #1: “response.results.civil_twilight_begin”=(string)“2020-04-13T04:26:57+00:00”
16:35:25: SiteSensor: Eval #2: “response.results.civil_twilight_end”=(string)“2020-04-13T18:48:27+00:00”
16:35:25: SiteSensor: Eval #3: “strftime("%x %X", time(expr[1]))”=(string)“04/13/20 06:26:57”
16:35:25: SiteSensor: Eval #4: “strftime("%x %X", time(expr[2]))”=(string)“04/13/20 20:48:27”
16:35:25: SiteSensor: Eval trip expression: “time()<time(expr[3]) or time()>=time(expr[4])”=(“boolean”)false

@ledavidou Looks good to me. What am I missing?

@HeldeRodrigues Did you disarm and re-arm the sensor to re-run the query? It does not re-run automatically just because you made a change. You have to force it.

If it still doesn’t work, I recommend you start over by pasting the recipe from the documentation site (which is what I assume you are working from now).

Yes, whenever I make a change I forcefully …

here is my config

=== Ident: HeldeRodrigues version 20104.1454 by HeldeRodrigues; Dont work

I actually meant for you to go get the standard recipe and reapply it to your sensor, not send me what you have. But in any case, your URL is not properly formatted (doesn’t start with http:// or https://). So fix that, but if it’s still not working, just go the the Recipes archive or documentation, get the standard recipe from there, and re-apply it to your sensor.

1 Like

OK
It already works … the http: // was missing

excuse…

This is the code that gives

16:20:19: SiteSensor: Requesting JSON data
16:20:19: SiteSensor: “GET” “http://api.openweathermap.org/data/2.5/forecast?id=8010588&APPID=xxx”, headers={ }
16:20:19: SiteSensor: Response is 14856 bytes in “/tmp/Q_SiteSensor_316.txt”
16:20:19: SiteSensor: Failed to execute "last(response.weather).main"', { location=24, ["__source"]="luaxp", message="Can't dereference through null", type="evaluation" } 16:20:19: SiteSensor: Eval #1: "last(response.weather).main"=(nil)nil 16:20:19: SiteSensor: Eval #2: "response.name"=null 16:20:19: SiteSensor: Failed to execute “response.temp - 273.15”‘, { message=“Can’t coerce null to number”, [“__source”]=“luaxp”, type=“evaluation” }
16:20:19: SiteSensor: Eval #3: “response.temp - 273.15”=(nil)nil
16:20:19: SiteSensor: Failed to execute "response.main.humidity"', { location=15, ["__source"]="luaxp", message="Can't dereference through null", type="evaluation" } 16:20:19: SiteSensor: Eval #4: "response.main.humidity"=(nil)nil 16:20:19: SiteSensor: Failed to execute “round(response.main.pressure * 0.029529988,2)”’, { location=15, [“__source”]=“luaxp”, message=“Can’t dereference through null”, type=“evaluation” }
16:20:19: SiteSensor: Eval #5: “round(response.main.pressure * 0.029529988,2)”=(nil)nil
16:20:19: SiteSensor: Eval trip expression: “response.cod == 200”=(“boolean”)true

You are using a different API call from the recipe. The recipe uses the “weather” API, and you are requesting the “forecast” API, which has a different response format. You have to use expressions that match the response format for the API you are using.

I already solved that!
Now it’s just giving me an error in temperature …
But I used the code to get the temperature in degrees Celcius!

17:23:24: SiteSensor: Requesting JSON data
17:23:24: SiteSensor: “GET” “http://api.openweathermap.org/data/2.5/weather?id=8010588&APPID=xxxx”, headers={ }
17:23:24: SiteSensor: Response is 485 bytes in “/tmp/Q_SiteSensor_316.txt”
17:23:24: SiteSensor: Eval #1: “last(response.weather).main”=(string)“Rain”
17:23:24: SiteSensor: Eval #2: “response.name”=(string)“Póvoa de Varzim Municipality”
17:23:24: SiteSensor: Failed to execute `“response.temp-273.15”', { message=“Can’t coerce null to number”, [“__source”]=“luaxp”, type=“evaluation” }
17:23:24: SiteSensor: Eval #3: “response.temp - 273.15”=(nil)nil
17:23:24: SiteSensor: Eval #4: “response.main.humidity”=(number)81
17:23:24: SiteSensor: Eval #5: “round(response.main.pressure * 0.029529988,2)”=(number)29.74
17:23:24: SiteSensor: Eval trip expression: “response.cod == 200”=(“boolean”)true

Good work! Your temperature expression should refer to response.main.temp not response.temp

1 Like

Everything is fine and in degrees celsius … :slight_smile:
is it possible in vera to get the icons according to the time?
This is…
It is raining the rain icon appears.
The correspondent is cloudy.