You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a pool heater and I have it on a schedule where it runs at 9am every day and heats the pool to 80.
But, we are in Michigan so if it's a cool day (i.e., forecasted air temperature high of 78 F or less), the family doesn't want to go in the pool and there's no point in heating it in the morning.
So since I recently got nodeJS-poolController up and running on a raspberry pi 5, I wrote a simple bash shell script that runs via cron every day at 855am and checks the forecast from the National Weather Service API and then modifies the 9am schedule to set it to Heater or OFF using the njsPc API.
My day time schedule is schedule id 3, so all I do is change the value of heatSource to 1 (OFF) or 2 (On).
I just wrote this today so we'll see what happens in the morning!
#!/bin/bash
# original
# curl http://localhost:4200/config/options/schedules
# {
# "id": 3,
# "startTimeType": 0,
# "endTimeType": 0,
# "display": 0,
# "startTimeOffset": 0,
# "endTimeOffset": 0,
# "isActive": true,
# "master": 0,
# "scheduleType": 128,
# "circuit": 6,
# "scheduleDays": 127,
# "startTime": 540,
# "endTime": 1260,
# "startDate": "2024-07-11T00:00:00.000-0400",
# "heatSource": 2,
# "heatSetpoint": 80,
# "coolSetpoint": 100
# }
# heatSource = 1 means heating off
# heatSource = 2 means heating on
# Make sure to set id equal to the value of your heater schedule
HEATER_SCHEDULE_NOHEAT="{\"id\":3,\"startTimeType\":0,\"endTimeType\":0,\"display\":0,\"startTimeOffset\":0,\"endTimeOffset\":0,\"isActive\":true,\"master\":0,\"scheduleType\":128,\"circuit\":6,\"scheduleDays\":127,\"startTime\":540,\"endTime\":1260,\"startDate\":\"2024-07-11T00:00:00.000-0400\",\"heatSource\":1,\"heatSetpoint\":80,\"coolSetpoint\":100}"
HEATER_SCHEDULE_HEAT="{\"id\":3,\"startTimeType\":0,\"endTimeType\":0,\"display\":0,\"startTimeOffset\":0,\"endTimeOffset\":0,\"isActive\":true,\"master\":0,\"scheduleType\":128,\"circuit\":6,\"scheduleDays\":127,\"startTime\":540,\"endTime\":1260,\"startDate\":\"2024-07-11T00:00:00.000-0400\",\"heatSource\":2,\"heatSetpoint\":80,\"coolSetpoint\":100}"
# See https://www.weather.gov/documentation/services-web-api#/default/gridpoint_forecast
# Set WFO to your weather forecasting office, and x,y to the forecast grid for your area
curl -s https://api.weather.gov/gridpoints/{wfo}/{x},{y}/forecast > forecast.json
FORECAST_PERIOD_NAME=$(jq .properties.periods[0].name forecast.json)
FORECAST_HIGH_TEMP=$(jq .properties.periods[0].temperature forecast.json)
echo "$(date) Forecast high for ${FORECAST_PERIOD_NAME} is ${FORECAST_HIGH_TEMP}"
if [ ${FORECAST_HIGH_TEMP} -le 78 ]; then
echo "$(date) DISABLING HEATER in schedule 3 due to forecast high < 78F."
curl -sX PUT "http://localhost:4200/config/schedule/" -H "accept: application/json" -H "Content-Type: application/json" -d ${HEATER_SCHEDULE_NOHEAT} | jq
else
echo "$(date) Enabling heater in schedule 3 due to forecast high > 78F."
curl -sX PUT "http://localhost:4200/config/schedule/" -H "accept: application/json" -H "Content-Type: application/json" -d ${HEATER_SCHEDULE_HEAT} | jq
fi
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a pool heater and I have it on a schedule where it runs at 9am every day and heats the pool to 80.
But, we are in Michigan so if it's a cool day (i.e., forecasted air temperature high of 78 F or less), the family doesn't want to go in the pool and there's no point in heating it in the morning.
So since I recently got nodeJS-poolController up and running on a raspberry pi 5, I wrote a simple bash shell script that runs via cron every day at 855am and checks the forecast from the National Weather Service API and then modifies the 9am schedule to set it to Heater or OFF using the njsPc API.
My day time schedule is schedule id 3, so all I do is change the value of heatSource to 1 (OFF) or 2 (On).
I just wrote this today so we'll see what happens in the morning!
Beta Was this translation helpful? Give feedback.
All reactions