/* ============================================================================= Hubitat Elevation Application Sprinkler Scheduler (parent application) Sprinkler Schedule Manager Inspiration: Lighting Schedules https://github.com/matt-hammond-001/hubitat-code Inspiration: github example from Hubitat of lightsUsage.groovy This fork: Sprinkler Schedules https://github.com/csteele-PD/Hubitat-public/tree/master/SprinklerSchedule ----------------------------------------------------------------------------- This code is licensed as follows: Portions: Copyright (c) 2022 Hubitat, Inc. All Rights Reserved Bruce Ravenel BSD 3-Clause License Copyright (c) 2023, C Steele Copyright (c) 2020, Matt Hammond All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- * * * * csteele: v1.0.10 cosmetic remove Horz Rule * csteele: v1.0.9 clean up unused methods: componentInitialize() * refactored logging into using closures. * csteele: v1.0.8 initialize state.month2month on child creation. * csteele: v1.0.7 editMonths() defaultValue pre-fill corrected. * csteele: v1.0.6 Added multiple Rain Sensors and be integrated. * csteele: v1.0.5 Don't tell the children about rain or temperature devices that don't exist. * csteele: v1.0.4 Added child switch option * Make collection of rainDeviceOutdoor attributes to remove duplicates * csteele: v1.0.3 Initial Release (end Beta) * csteele: v1.0.2 Add Over Temp and Rain Detection to be used as a Conditional * csteele: v1.0.1 Send month2month and dayGroup to child Apps * csteele: v1.0.0 Inspired by Matt Hammond's Lighting Schedules * Converted to capability.valve from switch * */ public static String version() { return "v1.0.10" } definition( name: "Sprinkler Schedule Manager", namespace: "csteele", author: "C Steele", description: "Controls switches to a timing schedule", importUrl: "https://raw.githubusercontent.com/csteele-PD/Hubitat-public/refs/heads/master/SprinklerSchedule/SprinklerSchedule_parent.groovy", documentationLink: "https://www.hubitatcommunity.com/QuikRef/sprinklerScheduleManagerInfo/index.html", singleInstance: true, iconUrl: "", iconX2Url: "", ) preferences { page(name: "mainPage") page(name: "advancedPage") } def mainPage() { dynamicPage(name: "mainPage", title: "", install: true, uninstall: true, submitOnChange: true) { displayHeader() state.appInstalled = app.getInstallationState() if (state.appInstalled != 'COMPLETE') return installCheck() section() { app (name: "sprinklerTimetable", appName: "Sprinkler Valve Timetable", namespace: "csteele", title: "Create New Sprinkler VALVE Schedule", multiple: true) } section() { app (name: "sprinklerTimetable", appName: "Sprinkler Switch Timetable", namespace: "csteele", title: "Create New Sprinkler SWITCH Schedule", multiple: true) } section() { input "advancedOption", "bool", title: "Display Options that become common to all Sprinkler Timetables.", required: false, defaultValue: false, submitOnChange: true input name: "quickref", type: "hidden", title:"Quick Reference ${version()}" } if (advancedOption) { section(menuHeader("Advanced Options Page")) { advDescription = 'Valve Timing by Month, Master Groups, Temperature and Rain Devices' href "advancedPage", title: "Advanced Options", required: false, description: advDescription, state: "complete" } // Send the current Maps to each Child, exactly like an Update-from-Done would do. childSetStates() } } } /* ----------------------------------------------------------------------------- Advanced Page handlers ----------------------------------------------------------------------------- */ def advancedPage() { def subTitle = getFormat("title", "Sprinkler Schedules") dynamicPage(name: "advancedPage", title: subTitle, uninstall: false, install: false) { displaySubHeader() section(menuHeader("Master: Adjust valve timing by Month")) { paragraph displayMonths() // display Monthly percentages editMonths() } section(menuHeader("Master: Select Days into Groups")) { paragraph "Groups defined here will appear as un-editable groups in every Timetable (child). " paragraph displayDayGroups() // display day-of-week groups } section(menuHeader("Master: Select Temperature Device")) { paragraph "Choose a temperature device and set the maximum value. Timetables can be conditional on the temperature exceeding the maximum." selectTemperatureDevice() // are there days that are very hot ? } section(menuHeader("Master: Select Rain detection Device")) { paragraph "Choose a Water Sensor device that will supply rain data. Timetables can be conditional on the rain values." selectRainDevice() // are there days that are wet enough ? } } } String displayMonths() { // display Monthly percentages if (state.month2month == null) state.month2month = ["1":"100", "2":"100", "3":"100", "4":"100", "5":"100", "6":"100", "7":"100", "8":"100", "9":"100", "10":"100", "11":"100", "12":"100"] String str = "Assume that Valve Duration (as set in the Child) is 100% and adjust that timing by these percentages, monthly. Valve Duration is reduced to the percentage defined for the month in which it runs. (20 seconds is the valve's minimum duration.) " str += "Example: If a Valve is set to be 15 minutes, and the current month has a value of 30%, the valve will run for 5 minutes each day of the month its scheduled to run.
" str += "
| Jan | " + "Feb | " + "Mar | " + "Apr | " + "May | " + "Jun | " + "Jul | " + "Aug | " + "Sep | " + "Oct | " + "Nov | " + "Dec | " + "
|---|---|---|---|---|---|---|---|---|---|---|---|
| $mCol | " } str += "
| Day Group | " + "Mon | " + "Tue | " + "Wed | " + "Thu | " + "Fri | " + "Sat | " + "Sun | " + "" + " |
|---|---|---|---|---|---|---|---|---|
| $k | " for (int r = 1; r < 8; r++) { String dayBoxN = buttonLink("w$k$r", O, "#49a37d", "") String dayBoxY = buttonLink("w$k$r", X, "#49a37d", "") str += (dg."$r") ? "$dayBoxY | " : "$dayBoxN | " } String remDayGroupBtn = buttonLink("rem$k", "", "#49a37d", "") str += "$remDayGroupBtn | " strRows = "|||||
| $addDayGroupBtn | <- Add new Day Group | " str += "|||||||
${myText}
" } def displayHeader() { section (getFormat("title", "Sprinkler Schedules")) { paragraph "