Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Runs every 1 days
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { getFlowLevel } from "https://esm.town/v/judson/MinnehahaFlowLevel";
import { email } from "https://esm.town/v/std/email?v=9";
export async function flowLevels(interval: Interval) {
const data = await getFlowLevel();
let goodConditions = false;
if (
// Conditions from https://minnehahacreek.org/explore/watershed-places/paddle-minnehaha-creek/
data.graysBayDamCurrentValue.value >= 75 && data.graysBayDamCurrentValue.value <= 150
&& data.hiawathaCurrentValue.value >= 75 && data.hiawathaCurrentValue.value <= 150
) {
goodConditions = true;
}
if (!interval.lastRunAt) {
email({
text: `You will now get updates if Minnehaha Creek has good conditions for paddling.`,
subject: `Minnehaha Creek alerts set up!`,
});
}
if (goodConditions) {
email({
text: `Gray's Bay CFS: ${data.graysBayDamCurrentValue.value}, Hiawatha: ${data.hiawathaCurrentValue.value}`,
subject: `Minnehaha Creek Flow levels are good`,
});
}
}
August 1, 2024