Skip to content

Commit

Permalink
Update IrrigationSchedulerApp.groovy
Browse files Browse the repository at this point in the history
Fixes bug to allow irrigation if no zip code is entered as a preference.
  • Loading branch information
d8adrvn committed Sep 20, 2015
1 parent e8e6b75 commit d706c10
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions IrrigationSchedulerApp.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ definition(
namespace: "d8adrvn/smart_sprinkler",
author: "[email protected] and [email protected]",
description: "Schedule sprinklers to run unless there is rain.",
category: "Green Living",
version: "2.93",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/water_moisture.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/[email protected]"
Expand All @@ -35,7 +34,7 @@ definition(
preferences {
page(name: "schedulePage", title: "Schedule", nextPage: "sprinklerPage", uninstall: true) {
section("App configruation...") {
label title: "Choose an title for App", required: true, defaultValue: "Irrigation Scheduler"
label name: "label", title: "Choose an title for App", required: true, defaultValue: "Irrigation Scheduler"
input "isNotificationEnabled", "boolean", title: "Send Push Notification To Report Status At Irrigation Start", description: "Do You Want To Receive Push Notifications?", defaultValue: "true", required: false
}

Expand Down Expand Up @@ -140,6 +139,8 @@ def scheduling() {

def waterTimeOneStart() {
state.currentTimerIx = 0
log.info (title: $title)
log.info (label: $label)
scheduleCheck()
}
def waterTimeTwoStart() {
Expand Down Expand Up @@ -215,34 +216,35 @@ def daysSince() {
}

def isRainDelay() {
if (zipcode) {
def rainGauge = 0

def rainGauge = 0

if (isYesterdaysRainEnabled.equals("true")) {
rainGauge = rainGauge + wasWetYesterday()
}

if (isTodaysRainEnabled.equals("true")) {
rainGauge = rainGauge + isWet()
}

if (isForecastRainEnabled.equals("true")) {
rainGauge = rainGauge + isStormy()
}

log.info ("Virtual rain gauge reads $rainGauge in")
if (rainGauge > (wetThreshold?.toFloat() ?: 0.5)) {
if (isNotificationEnabled.equals("true")) {
sendPush("Skipping watering today due to precipitation.")
}
for(s in switches) {
if("rainDelayed" in s.supportedCommands.collect { it.name }) {
s.rainDelayed()
log.trace "Watering is rain delayed for $s"
}
if (isYesterdaysRainEnabled.equals("true")) {
rainGauge = rainGauge + wasWetYesterday()
}
return true
}

if (isTodaysRainEnabled.equals("true")) {
rainGauge = rainGauge + isWet()
}

if (isForecastRainEnabled.equals("true")) {
rainGauge = rainGauge + isStormy()
}

log.info ("Virtual rain gauge reads $rainGauge in")
if (rainGauge > (wetThreshold?.toFloat() ?: 0.5)) {
if (isNotificationEnabled.equals("true")) {
sendPush("Skipping watering today due to precipitation.")
}
for(s in switches) {
if("rainDelayed" in s.supportedCommands.collect { it.name }) {
s.rainDelayed()
log.info "Watering is rain delayed for $s"
}
}
return true
}
}
return false
}

Expand Down

0 comments on commit d706c10

Please sign in to comment.