Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
synctastic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SOTA
synctastic
Commits
8860c40f
Commit
8860c40f
authored
1 year ago
by
echicken
Browse files
Options
Downloads
Patches
Plain Diff
Weather conditions
parent
d46fa924
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
build/synctastic.js
+5
-1
5 additions, 1 deletion
build/synctastic.js
src/modules/weather.ts
+2
-6
2 additions, 6 deletions
src/modules/weather.ts
with
7 additions
and
7 deletions
build/synctastic.js
+
5
−
1
View file @
8860c40f
...
...
@@ -16858,8 +16858,12 @@
if (weather.current === void 0)
return false;
var wd = openWeatherMap.wind_direction(weather.current.wind_deg);
var conditions = weather.current.weather.map(function(e) {
return e.main;
}).join(", ");
var ws = "Weather for ".concat(weather.lat.toFixed(2), ", ").concat(weather.lon.toFixed(2));
ws += "\r\n".concat(weather.current.weather[0].main, ", ").concat(weather.current.weather[0].description);
if (conditions.length > 0)
ws += "\r\n".concat(conditions);
ws += "\r\n".concat(weather.current.temp, "\xB0C, feels like ").concat(weather.current.feels_like, "\xB0C");
ws += "\r\nUV: ".concat(weather.current.uvi, " ").concat(uvEmoji(weather.current.uvi));
ws += "\r\nHumidity: ".concat(weather.current.humidity, "%");
...
...
This diff is collapsed.
Click to expand it.
src/modules/weather.ts
+
2
−
6
View file @
8860c40f
...
...
@@ -11,11 +11,6 @@ function uvEmoji(uvi: number): string {
return
'
🟣
'
;
}
function
weatherEmoji
(
icon
:
string
):
string
{
// just map their icons to some emojis and check for 'd' vs 'n' to choose sun/moon variants
return
''
;
}
export
default
class
Weather
extends
Module
{
constructor
(
config
:
IModuleConfig
,
devices
:
Device
[])
{
...
...
@@ -33,8 +28,9 @@ export default class Weather extends Module {
const
weather
=
openWeatherMap
.
call_api_v3
({
lat
:
43.7554870
,
lon
:
-
79.4384880
,
exclude
:
[
'
minutely
'
,
'
hourly
'
,
'
daily
'
,
'
alerts
'
],
units
:
'
metric
'
});
if
(
weather
.
current
===
undefined
)
return
false
;
const
wd
=
openWeatherMap
.
wind_direction
(
weather
.
current
.
wind_deg
);
const
conditions
=
weather
.
current
.
weather
.
map
(
e
=>
e
.
main
).
join
(
'
,
'
);
let
ws
=
`Weather for
${
weather
.
lat
.
toFixed
(
2
)}
,
${
weather
.
lon
.
toFixed
(
2
)}
`
;
ws
+=
`\r\n
${
weather
.
current
.
weather
[
0
].
main
}
,
${
weather
.
current
.
weather
[
0
].
descrip
tion
}
`
;
if
(
conditions
.
length
>
0
)
ws
+=
`\r\n
${
condi
tion
s
}
`
;
ws
+=
`\r\n
${
weather
.
current
.
temp
}
°C, feels like
${
weather
.
current
.
feels_like
}
°C`
;
ws
+=
`\r\nUV:
${
weather
.
current
.
uvi
}
${
uvEmoji
(
weather
.
current
.
uvi
)}
`
;
ws
+=
`\r\nHumidity:
${
weather
.
current
.
humidity
}
%`
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment