[Plugin]DarkSky Weather

Hi zed,
The best I could find is where they get their data from https://darksky.net/dev/docs/sources.

Cheers Rene

Seems like you have left out what the %s stands for in the string. Please compare it to the example I’m using:

url = require("socket.url")

local AV_DEV = 219
local LS_SID = "urn:micasaverde-com:serviceId:Sonos1"
local time = os.date('%I: %M')
local TEMP_SID ="urn:upnp-micasaverde-com:serviceId:Weather1"
local OwTempTodayHigh= luup.variable_get(TEMP_SID, "TodayHighTemp", 548)
local OwTempTodayLow= luup.variable_get(TEMP_SID, "TodayLowTemp", 548)
local currentCondition= luup.variable_get(TEMP_SID, "TodayConditions", 548)
local OwTempTomorrowHigh= luup.variable_get(TEMP_SID, "TomorrowHighTemp", 548)
local OwTempTomorrowLow= luup.variable_get(TEMP_SID, "TomorrowLowTemp", 548)
local tomorrowCondition = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1", 
"TomorrowConditions", 548)



luup.call_action(LS_SID, "Say", {Text = string.format("God morgon! Idag blir det %s med en högsta 
temperatur pÄ %s grader och en lÀgsta temperatur pÄ %s grader.   I morgon blir det %s med en 
högsta temperatur pÄ %s grader och en lÀgsta temperatur pÄ %s", currentCondition, 
OwTempTodayHigh, OwTempTodayLow, tomorrowCondition, OwTempTomorrowHigh, 
OwTempTomorrowLow) ,Volume=35}, AV_DEV)

Hi Rene
With the Weather Underground and Say the Weather apps I was able to program a scene that would give the weather and next day weather TTS every morning. With your Dark Sky app I was hoping to do the same. I dont see the parent device in my list of options after setting the trigger time when creating the scene. I saw much of the code below used in a scene via lua but it is not working. I can see the parent and child devices installed as devices and givng weather data but none in my scene list choices
 Does my requested entire scene need to be run via lua code? I have not seen any other tts scene examples using Dark Sky
 Thanks for your work on Dark Sky! I hope I can use it!

Thanks for looking over my attempt.
I see differences in the codes but sorry to say I really dont understand it yet

I have many lua scenes working by just using & tweaking suggested forum lua strings.
Can I simply insert my DarkSky device # and Sonos1 device # into your example when creating a scheduled scene to fire at 10:30am?

So if I plug in my

yes, please try.

Excuse my ignorance but is your example code able to run on my english language set up Vera
?

The code will work but it will sound like some englishman reading a Swedish text :smiley:
If you hear something including the temperature readings just change the text according to your own wishes.

The point is that the %s in the text will be replaced with the following variables

currentCondition, OwTempTodayHigh, OwTempTodayLow, tomorrowCondition, OwTempTomorrowHigh, OwTempTomorrowLow

Which are read from DarkSky Weather plugin device variables.

I am sorry to say the code is not working.
I changed device numbers to 298 for my Sonos and 620 for the parent Dark Sky. I assume we dont add child device numbers for each weather element possibility

Do I need to add anything this line?

url = require(“socket.url”)

Even tried just the string in Sonos TTS but it did not read it.
All my other Sonos TTS scenes are running fine

I appreciate your help!
If anyone has successfully run a sceduled daily weather announcement using Dark Sky please share your method!

Lets make it a bit more simple, removed all but one weather variable now to simplify the code, prepared it with your device numbers so it should be just copy paste the whole thing.
Go to Apps → Develop apps → Test luup code (lua) paste the code and “GO” You should get “Code sent successfully.” and hear something being spoken.

url = require("socket.url")

local AV_DEV = 298
local LS_SID = "urn:micasaverde-com:serviceId:Sonos1"
local TEMP_SID ="urn:upnp-micasaverde-com:serviceId:Weather1"
local OwTempTodayHigh= luup.variable_get(TEMP_SID, "TodayHighTemp", 620)

luup.call_action(LS_SID, "Say", {Text = string.format("Todays high temperature will be %s", OwTempTodayHigh) ,Volume=35}, AV_DEV)

Hello,
How do I get the units CÂș and Km/h?
Auto, System international, Imperial, Canadian or British?
Thank you

it’s “System International” for metric units.

System International puts me ÂșC and m/s

Hi,

have a look at the units section of Dark Sky API: Log In

Cheers Rene

Hi Tiago,

Scroll up just a little. There you see that units=ca will give you km/h.

Cheers Rene

KISS is a good thing with luup code for me.
:smiley:
Using your example that worked I have sucessfully expanded the code to include Today High & Low Temps announcement via Sonos!
Here it is:
url = require(“socket.url”)
local AV_DEV = 298
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”
local TEMP_SID =“urn:upnp-micasaverde-com:serviceId:Weather1”
local OwTempTodayHigh= luup.variable_get(TEMP_SID, “TodayHighTemp”, 620)
local OwTempTodayLow= luup.variable_get(TEMP_SID, “TodayLowTemp”, 620)

luup.call_action(LS_SID, “Say”, {Text = string.format("Todays high temperature will be %s Todays low temperature will be %s " , OwTempTodayHigh , OwTempTodayLow ) ,Volume=35}, AV_DEV)

But:
I can not expand the code to include the current temp or tomorrows high, low forcast

Test Lua keeps coming back try again

:frowning:
I feel good about adding the Low temp but can’t make the rest of the code work!
I’ve tried many times working from your suggested code.
Is it something to do with upper case on “currentCondition” ?
local currentCondition= luup.variable_get(TEMP_SID, “TodayConditions”, 620)
Thanks for your patience!
Wilbur

Hi Wilbur,

Make sure you have normal double quotes in you code. When I copied your code (that works) it had the wrong quotes. Replace them all and try again. Remember not to copy from word or so, but use a plain editor. I’d recommend notepad++.

Cheers Rene

Can you expand the lua code in english to include
tomorrowCondition, OwTempTomorrowHigh, OwTempTomorrowLow?
I cant get the code to work with them.

luup.call_action(LS_SID, "Say", {Text = string.format("God morgon! Idag blir det %s med en högsta 
temperatur pÄ %s grader och en lÀgsta temperatur pÄ %s grader.   I morgon blir det %s med en 
högsta temperatur pÄ %s grader och en lÀgsta temperatur pÄ %s", currentCondition, 
OwTempTodayHigh, OwTempTodayLow, tomorrowCondition, OwTempTomorrowHigh, 
OwTempTomorrowLow) ,Volume=35}, AV_DEV)

Thanks Rene I see the difference and have corrected the discrepancy.
Can you privide me additional code to include
tomorrowCondition, OwTempTomorrowHigh, OwTempTomorrowLow?
I cant get the code to work with them.

Hi Lakewood,

Just add lines like

local OwTempTomorrowLow= luup.variable_get(TEMP_SID, “TomorrowMinTemp”, 620)

You can check the wiki for all availble variables.

Cheers Rene