Skip to content

Commit 8bb4f5a

Browse files
authored
Weatherbit.io, etc. update (#20)
* Added support for Weatherbit.io forecasts. * Added hourly probability of precipitation, triggered by tap/click on hourly icons or temperatures. * Weatherbit.io can now be used in place of, or in addition to, the Google geocoding API to translate GPS latitude/longitude into place names. * Fixed bug with pop-up weather details for Weather Underground forecast. * Prevented onscreen keyboard from covering alert dialogs. * Make sure when running in kiosk mode that clicking on a weather service logo doesn't lead to the main display being blocked. * Added automatic phase-out of Dark Sky API in December 2021. * Various small tweaks and bug fixes.
1 parent 7375c8b commit 8bb4f5a

42 files changed

Lines changed: 1308 additions & 658 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
2,
4949
{
5050
"ArrayExpression": "first",
51+
"FunctionDeclaration": { "parameters": "off" },
5152
"ignoredNodes": [
5253
"IfStatement > :expression *",
5354
"WhileStatement > :expression *"

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "server/src/aw-clock-private"]
2+
path = server/src/aw-clock-private
3+
url = https://github.com/kshetline/aw-clock-private.git

.sasslintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"rules": {
3+
"force-attribute-nesting": 0,
34
"force-element-nesting": 0,
45
"force-pseudo-nesting": 0,
56
"hex-notation": [
@@ -9,6 +10,12 @@
910
}
1011
],
1112
"leading-zero": 0,
13+
"nesting-depth": [
14+
1,
15+
{
16+
"max-depth": 4
17+
}
18+
],
1219
"no-color-keywords": 0,
1320
"no-color-literals": 0,
1421
"no-duplicate-properties": [
@@ -20,6 +27,7 @@
2027
"no-ids": 0,
2128
"no-important": 0,
2229
"no-vendor-prefixes": 0,
30+
"no-qualifying-elements": 0,
2331
"no-trailing-zero": 0,
2432
"one-declaration-per-line": 0,
2533
"property-sort-order": 0,

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 2.5.0
2+
3+
* Add support for Weatherbit.io forecasts.
4+
* Add hourly probability of precipitation, triggered by tap/click on hourly icons or temperatures.
5+
* Weatherbit.io can now be used in place of, or in addition to, the Google geocoding API to translate GPS latitude/longitude into place names.
6+
* Fixed bug with pop-up weather details for Weather Underground forecast.
7+
* Prevented onscreen keyboard from covering alert dialogs.
8+
* Make sure when running in kiosk mode that clicking on a weather service logo doesn't lead to the main display being blocked.
9+
* Added automatic phase-out of Dark Sky API in December 2021.
10+
111
## 2.4.0
212

313
* Touchscreen support. This includes:
@@ -11,7 +21,7 @@
1121
* Notifications for software updates.
1222
* Optional onscreen administrative functions, provided through the Settings dialog. These include:
1323
* Reboot
14-
* Shutdown
24+
* Shutdown
1525
* Quit browser
1626
* Initiate software update.
1727
* User customizable background and clock face colors.
@@ -113,7 +123,7 @@
113123

114124
* Updated README.md.
115125

116-
##1.0.1
126+
## 1.0.1
117127

118128
* Fix gear.svg image so it's compatible with IE. Add MIT license to individual files.
119129

README.md

Lines changed: 46 additions & 21 deletions
Large diffs are not rendered by default.

build.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ fi
1616

1717
echo "Checking installation pre-requisites..."
1818

19-
if [ ! `which node` ]; then
19+
if [ ! "$(command -v node)" ]; then
2020
version=0
2121
else
22-
version=`node --version`
22+
version=$(node --version)
2323
pattern='v?([0-9]+)'
2424
[[ $version =~ $pattern ]]
2525
version="${BASH_REMATCH[1]}"
@@ -45,4 +45,5 @@ if [ ! -f ".first-time-install" ]; then
4545
fi
4646

4747
echo "Starting main installer..."
48+
# shellcheck disable=SC2048,SC2086 # this should become separate items with spaces in between, not one quoted thing
4849
npm run build -- --bash $*

build.ts

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ function stepDone(): void {
281281
}
282282

283283
async function isInstalled(command: string): Promise<boolean> {
284-
return !!(await monitorProcess(spawn('which', [command]), null, ErrorMode.ANY_ERROR)).trim();
284+
return !!(await monitorProcess(spawn('command', ['-v', command], { shell: true }), null, ErrorMode.ANY_ERROR))?.trim();
285285
}
286286

287287
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -480,19 +480,34 @@ function ntpValidate(s: string): boolean {
480480
return false;
481481
}
482482

483+
const NO_MORE_DARK_SKY = (Date.now() > Date.parse('2021-11-30'));
484+
485+
if (NO_MORE_DARK_SKY && process.env.AWC_PREFERRED_WS === 'darksky')
486+
process.env.AWC_PREFERRED_WS = 'wunderground';
487+
483488
function wsValidate(s: string): boolean | string {
484-
if (/^w/i.test(s))
489+
if (/^w[-b]*$/i.test(s))
485490
return 'wunderground';
486-
else if (/^d/i.test(s))
491+
else if (/b/i.test(s))
492+
return 'weatherbit';
493+
else if (!NO_MORE_DARK_SKY && /^d/i.test(s))
487494
return 'darksky';
488495

489-
console.log(chalk.redBright('Weather service must be either (w)underground or (d)arksky'));
496+
if (NO_MORE_DARK_SKY)
497+
console.log(chalk.redBright('Weather service must be either (w)underground, weather(b)it, or (d)arksky'));
498+
else
499+
console.log(chalk.redBright('Weather service must be either (w)underground, or weather(b)it'));
500+
490501
return false;
491502
}
492503

493504
function wsAfter(s: string): void {
494-
if (/^w/i.test(s)) {
495-
console.log(chalk.paleBlue(' Weather Underground chosen, but Dark Sky can be used'));
505+
if (/^w[-b]*$/i.test(s)) {
506+
console.log(chalk.paleBlue(` Weather Underground chosen, but Weatherbit.io${NO_MORE_DARK_SKY ? '' : 'or Dark Sky'} can be used`));
507+
console.log(chalk.paleBlue(' as fallback weather services.'));
508+
}
509+
else if (/b/i.test(s)) {
510+
console.log(chalk.paleBlue(' Weatherbit.io chosen, but Weather Underground will be used'));
496511
console.log(chalk.paleBlue(' as a fallback weather service.'));
497512
}
498513
else if (/^d/i.test(s)) {
@@ -563,19 +578,31 @@ const finalOptions = '(l/r/n/)'.replace(finalAction.toLowerCase(), finalAction);
563578

564579
const questions = [
565580
{ prompt: 'Perform initial update/upgrade?', ask: true, yn: true, deflt: doUpdateUpgrade ? 'Y' : 'N', validate: upgradeValidate },
566-
{ name: 'AWC_PORT', prompt: 'HTTP server port', ask: true, validate: portValidate },
581+
{ name: 'AWC_PORT', prompt: 'HTTP server port.', ask: true, validate: portValidate },
567582
{ prompt: 'Allow user to reboot, shutdown, update, etc.?', ask: true, yn: true, deflt: doAdmin ? 'Y' : 'N', validate: adminValidate },
568583
{ name: 'AWC_NTP_SERVER', prompt: 'time server', ask: true, validate: ntpValidate },
569584
{
570585
name: 'AWC_GOOGLE_API_KEY',
571-
prompt: 'Google Geocoding API key (optional, for city names from GPS coordinates)' +
586+
prompt: 'Optional Google geocoding API key (for city names from\n GPS coordinates).' +
572587
(settings.AWC_GOOGLE_API_KEY ? '\n Enter - (dash) to remove old API key' : ''),
573588
ask: true
574589
},
575-
{ name: 'AWC_PREFERRED_WS', prompt: 'preferred weather service, (w)underground or (d)arksky)', ask: true, validate: wsValidate, after: wsAfter },
590+
{ // #5
591+
name: 'AWC_PREFERRED_WS',
592+
prompt: 'preferred weather service, (w)underground, weather(b)it,\n or (d)arksky).',
593+
ask: true,
594+
validate: wsValidate,
595+
after: wsAfter
596+
},
576597
{
598+
name: 'AWC_WEATHERBIT_API_KEY',
599+
prompt: 'Optional Weatherbit.io (via RapidAPI) key, for\n weather and geocoding.' +
600+
(settings.AWC_WEATHERBIT_API_KEY ? '\n Enter - (dash) to remove old API key' : ''),
601+
ask: true
602+
},
603+
{ // #7
577604
name: 'AWC_DARK_SKY_API_KEY',
578-
prompt: 'Dark Sky API key (uses "wunderground" if left blank)' +
605+
prompt: 'Optional Dark Sky weather API key.' +
579606
(settings.AWC_DARK_SKY_API_KEY ? '\n Enter - (dash) to remove old API key' : ''),
580607
ask: true
581608
},
@@ -586,6 +613,11 @@ const questions = [
586613
{ prompt: `When finished, (l)aunch A/W clock, (r)eboot, or (n)o action ${finalOptions}?`, ask: true, deflt: finalAction, validate: finalActionValidate }
587614
];
588615

616+
if (NO_MORE_DARK_SKY) {
617+
questions[5].prompt = 'preferred weather service, (w)underground, or weather(b)it';
618+
questions.splice(7, 1);
619+
}
620+
589621
async function promptForConfiguration(): Promise<void> {
590622
console.log(chalk.cyan('- Configuration -'));
591623

img/awc_screenshot.png

-87.1 KB
Loading

0 commit comments

Comments
 (0)