Could anyone help me modify the “Scheduled Mode Change” app so it allows one to set a mode change based on a 7-day schedule and specific time?
I modified the code slightly but it seems to ignore the actual set day and triggers everyday at the specified time.
// Automatically generated. Make future change here.
definition(
name: "test",
namespace: "",
author: "V. B",
description: "test",
category: "My Apps",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
preferences {
section("Configuration") {
input "dayOfWeek", "enum",
title: "Which day of the week?",
multiple: false,
metadata: [
values: [
'All Week',
'Monday to Friday',
'Saturday & Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday'
]
]
input "time", "time", title: "At this time"
//input "newMode", "mode", title: "Change to this mode"
}
section("Change to this mode") {
input "newMode", "mode", title: "Mode?"
}
}
def installed() {
initialize()
}
def updated() {
unschedule()
initialize()
}
def initialize() {
schedule(time, changeMode)
}
def changeMode() {
if (location.mode != newMode) {
if (location.modes?.find{it.name == newMode}) {
setLocationMode(newMode)
send "${label} has changed the mode to '${newMode}'"
}
else {
send "${label} tried to change to undefined mode '${newMode}'"
}
}
}
private send(msg) {
sendPush msg
log.debug msg
}
private getLabel() {
app.label ?: "SmartThings"
}