Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions weather-api-widget/weather.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,6 @@ local function worker(user_args)

local args = user_args or {}

--- Validate required parameters
if args.coordinates == nil or args.api_key == nil then
show_warning(locale.parameter_warning ..
(args.coordinates == nil and '<b>coordinates</b>' or '') ..
(args.api_key == nil and ', <b>api_key</b> ' or ''))
return
end

local coordinates = args.coordinates
local api_key = args.api_key
local font_name = args.font_name or beautiful.font:gsub("%s%d+$", "")
Expand All @@ -195,6 +187,13 @@ local function worker(user_args)

local locale = get_locale(lang)

--- Validate required parameters
if args.coordinates == nil or args.api_key == nil then
show_warning(locale.parameter_warning ..
(args.coordinates == nil and '<b>coordinates</b>' or '') ..
(args.api_key == nil and ', <b>api_key</b> ' or ''))
return
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is addressed in #479

-- Forecast endpoint includes current. I could map show_daily_forecast to days here.
-- Currently overfetching but only showing when opting in.
local weather_api =
Expand Down
20 changes: 12 additions & 8 deletions weather-widget/weather.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,17 @@ local function worker(user_args)
local timeout = args.timeout or 120

local ICONS_DIR = WIDGET_DIR .. '/icons/' .. icon_pack_name .. '/'
local owm_one_cal_api =
('https://api.openweathermap.org/data/2.5/onecall' ..
'?lat=' .. coordinates[1] .. '&lon=' .. coordinates[2] .. '&appid=' .. api_key ..
'&units=' .. units .. '&exclude=minutely' ..
(show_hourly_forecast == false and ',hourly' or '') ..
(show_daily_forecast == false and ',daily' or '') ..
'&lang=' .. LANG)
local owm_one_call_api =
('https://api.openweathermap.org/data/3.0/onecall' ..
'?lat=' .. coordinates[1] ..
'&lon=' .. coordinates[2] ..
'&appid=' .. api_key ..
'&units=' .. units ..
'&exclude=' ..
(show_hourly_forecast == false and 'hourly,' or '') ..
(show_daily_forecast == false and 'daily,' or '') ..
'minutely' ..
'&lang=' .. LANG)

weather_widget = wibox.widget {
{
Expand Down Expand Up @@ -564,7 +568,7 @@ local function worker(user_args)
end)))

watch(
string.format(GET_FORECAST_CMD, owm_one_cal_api),
string.format(GET_FORECAST_CMD, owm_one_call_api),
timeout, -- API limit is 1k req/day; day has 1440 min; every 2 min is good
update_widget, weather_widget
)
Expand Down