Notate high/low, hide low precip %
Only show every other hour horizontally.
This commit is contained in:
20
dark-sky.js
20
dark-sky.js
@@ -52,13 +52,18 @@ const logWeatherJson = (jsonFile, loc) => {
|
|||||||
const hoursList = ['H']
|
const hoursList = ['H']
|
||||||
const tempsList = ['°C']
|
const tempsList = ['°C']
|
||||||
const precipList = ['%P']
|
const precipList = ['%P']
|
||||||
for (let i = 0; i < 9; i++) {
|
for (let i = 0; i < 16; i += 2) {
|
||||||
const hourInfo = weatherInfo['hourly']['data'][i]
|
const hourInfo = weatherInfo['hourly']['data'][i]
|
||||||
const date = new Date(hourInfo['time'] * 1000)
|
const date = new Date(hourInfo['time'] * 1000)
|
||||||
hoursList.push(date.getHours())
|
hoursList.push(date.getHours())
|
||||||
tempsList.push(Math.floor(hourInfo['apparentTemperature']))
|
tempsList.push(Math.floor(hourInfo['apparentTemperature']))
|
||||||
precipList.push(Math.floor(hourInfo['precipProbability']))
|
const precipProbability = Math.floor(hourInfo['precipProbability'])
|
||||||
|
precipList.push((precipProbability < 20) ? '' : precipProbability)
|
||||||
}
|
}
|
||||||
|
const maxTempIndex = tempsList.indexOf(Math.max(...tempsList.slice(1)))
|
||||||
|
const minTempIndex = tempsList.indexOf(Math.min(...tempsList.slice(1)))
|
||||||
|
tempsList[maxTempIndex] = `${tempsList[maxTempIndex]}+`
|
||||||
|
tempsList[minTempIndex] = `${tempsList[minTempIndex]}-`
|
||||||
log(table([hoursList, tempsList, precipList], TABLE_CONFIG));
|
log(table([hoursList, tempsList, precipList], TABLE_CONFIG));
|
||||||
}
|
}
|
||||||
resolve()
|
resolve()
|
||||||
@@ -66,10 +71,15 @@ const logWeatherJson = (jsonFile, loc) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formatTimeUnit = unit => { return ((unit < 10) ? '0' : '') + unit }
|
||||||
|
|
||||||
logTablePromises = [
|
logTablePromises = [
|
||||||
|
logWeatherJson('./toronto.json', 'Toronto'),
|
||||||
logWeatherJson('./markham.json', 'Markham'),
|
logWeatherJson('./markham.json', 'Markham'),
|
||||||
logWeatherJson('./toronto.json', 'Toronto')]
|
]
|
||||||
Promise.all(logTablePromises).then(results => {
|
Promise.all(logTablePromises).then(results => {
|
||||||
const now = new Date()
|
// const now = new Date()
|
||||||
log(`${CREDIT_MSG}\n\nLast updated: ${now.getHours()}:${now.getMinutes()}`)
|
// const lastUpdatedTime = `${formatTimeUnit(now.getHours())}:${formatTimeUnit(now.getMinutes())}`
|
||||||
|
// log(`${CREDIT_MSG}\n\nLast updated: ${lastUpdatedTime}`)
|
||||||
|
log(CREDIT_MSG)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Description=Fetch local weather
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/home/kevin/weather/dark-sky.fish
|
ExecStart=/home/kevin/weather/dark-sky.sh
|
||||||
User=kevin
|
User=kevin
|
||||||
Group=kevin
|
Group=kevin
|
||||||
Environment=PATH=/usr/bin:/usr/local/bin
|
Environment=PATH=/usr/bin:/usr/local/bin
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
Description=Fetch local weather
|
Description=Fetch local weather
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar=6,12,18,00:00
|
# OnCalendar=6,12,18,00:00
|
||||||
|
OnCalendar=*:0
|
||||||
Persistent=true
|
Persistent=true
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|||||||
Reference in New Issue
Block a user