There is no direct option to do, because there aren’t any Widgets to set time via Sitemap. Create some Items (start_hour, start_minute, stop_hour, stop_minute…) to set hours and minutes, then create a rule to calculate the command to send to the shelly. There are tons of rules here to do this.
But some general thoughts about: Do you need to set exact minute and hour? Maybe ten minute steps would be sufficient. Or maybe it would even suffice to set time in a more simple way, e.g. “time 1”, “time 2” and “time 3” (chose from a list of possible values).
Another option would be to use a calendar.
Or don’t do it by time at all, but by sun, rain, humidity and temperature (and weather forecast).
For “normal” watering it is sufficient to have a rule for a scheduled time, thats right. I only asked because it would be more individual if i can set the start-time within the app directly.
I think i will implement then switches for start-times (hard coded within the rule), but it would be very nice if we have a extra field (or calendar) to set custom time schedules in future.
The rule checks if the program was already run today (item bew_timer_triggered)
The rule calculate out of the choosen hour and minutes and the actual time if the time passed to activate the program
the rule checks the rule checks if i want to run the program today and have a look if the “bew_timer_day” value is ON (how i calculate if the item is switched ON or OFF you can see above in the other rules)
the program start and checks for each watering-system, if i switched it ON and how long i want to have it ON.
//Regeln für zeitgesteuerte Wochenbewässerung
rule "Bew_leitungen_zeitgest"
when
//Item test_switch received command
Time cron "0 0/5 * * * *"
then
val String stunde = now.getHour().toString()
val String minute = now.getMinute().toString()
if (Integer::parseInt(minute) < 10) {
minute = "0" + minute
}
//logInfo("Gardena", "Bewässerungsprogramm: Minuten " + minute)
var akt_stdmin = stunde + minute
val stdmin_itm = bew_zeit_std.state.toString + bew_zeit_min.state.toString
val Number akt_stdmin_n = Integer::parseInt(akt_stdmin)
val Number stdmin_itm_n = Integer::parseInt(stdmin_itm)
//pruefen ob nicht schon einmal gelaufen heute
if(bew_timer_triggered.state == OFF) {
logInfo("Gardena", "Bewässerungsprogramm: Gate 1 erreicht.")
//logInfo("Gardena", "Bewässerungsprogramm: Uhr aktuell: " + akt_stdmin + " | Timer: " + stdmin_itm)
//logInfo("Gardena", "Bewässerungsprogramm: Uhr aktuell: " + akt_stdmin_n + " | Timer: " + stdmin_itm_n)
//pruefen ob Uhrzeit ueberschritten wurde
if( akt_stdmin_n > stdmin_itm_n ) {
logInfo("Gardena", "Bewässerungsprogramm: Gate 2 erreicht.")
//pruefen ob richtiger Wochentag
if(bew_timer_day.state == ON) {
logInfo("Gardena", "Bewässerungsprogramm: Gate 3 erreicht.")
bew_timer_triggered.sendCommand(ON)
logInfo("Gardena", "Starte Bewässerungsprogramm.")
if(bew_leitung1.state == ON) {
var dauer_str = bew_dauer_zeit_1.state.toString
var Long dauer1 = Long.parseLong(dauer_str)
var dauer_sek1 = dauer1 * 1000 * 60
//logInfo("Gardena", "Sekunden: " + dauer_sek1)
Shelly_uni_ch1.sendCommand(ON)
//sendBroadcastNotification("Gardena: Leitung 1 geöffnet.")
createTimer(now.plusMinutes(dauer1), [|
Shelly_uni_ch1.sendCommand(OFF)
//sendBroadcastNotification("Gardena: Leitung 1 geschlossen.")
])
Thread::sleep(dauer_sek1)
}
if(bew_leitung2.state == ON) {
var dauer_str = bew_dauer_zeit_2.state.toString
var Long dauer2 = Long.parseLong(dauer_str)
var dauer_sek2 = dauer1 * 1000 * 60
Shelly_uni_ch2.sendCommand(ON)
//sendBroadcastNotification("Gardena: Leitung 2 geöffnet.")
createTimer(now.plusMinutes(dauer2), [|
Shelly_uni_ch2.sendCommand(OFF)
//sendBroadcastNotification("Gardena: Leitung 2 geschlossen.")
])
Thread::sleep(dauer_sek2)
}
if(bew_leitung3.state == ON) {
var dauer_str = bew_dauer_zeit_3.state.toString
var Long dauer3 = Long.parseLong(dauer_str)
var dauer_sek3 = dauer1 * 1000 * 60
Shelly_uni_ch3.sendCommand(ON)
//sendBroadcastNotification("Gardena: Leitung 3 geöffnet.")
createTimer(now.plusMinutes(dauer3), [|
Shelly_uni_ch3.sendCommand(OFF)
//sendBroadcastNotification("Gardena: Leitung 3 geschlossen.")
])
Thread::sleep(dauer_sek3)
}
if(bew_leitung4.state == ON) {
var dauer_str = bew_dauer_zeit_4.state.toString
var Long dauer4 = Long.parseLong(dauer_str)
var dauer_sek4 = dauer1 * 1000 * 60
Shelly_uni_ch4.sendCommand(ON)
//sendBroadcastNotification("Gardena: Leitung 4 geöffnet.")
createTimer(now.plusMinutes(dauer4), [|
Shelly_uni_ch4.sendCommand(OFF)
//sendBroadcastNotification("Gardena: Leitung 4 geschlossen.")
])
Thread::sleep(dauer_sek4)
}
if(bew_leitung5.state == ON) {
var dauer_str = bew_dauer_zeit_5.state.toString
var Long dauer5 = Long.parseLong(dauer_str)
var dauer_sek5 = dauer1 * 1000 * 60
Shelly_uni_ch5.sendCommand(ON)
//sendBroadcastNotification("Gardena: Leitung 5 geöffnet.")
createTimer(now.plusMinutes(dauer5), [|
Shelly_uni_ch5.sendCommand(OFF)
//sendBroadcastNotification("Gardena: Leitung 5 geschlossen.")
])
Thread::sleep(dauer_sek5)
}
if(bew_leitung6.state == ON) {
var dauer_str = bew_dauer_zeit_6.state.toString
var Long dauer6 = Long.parseLong(dauer_str)
var dauer_sek6 = dauer1 * 1000 * 60
Shelly_uni_ch6.sendCommand(ON)
//sendBroadcastNotification("Gardena: Leitung 6 geöffnet.")
createTimer(now.plusMinutes(dauer6), [|
Shelly_uni_ch6.sendCommand(OFF)
//sendBroadcastNotification("Gardena: Leitung 6 geschlossen.")
])
Thread::sleep(dauer_sek6)
}
logInfo("Gardena", "Bewässerungsprogramm beendet.")
}
}
}
end