Yes, I red it, but it is hard to understand the code. I think there needs something like:
KalendarOdpady_NextEventStart.state.toString == tomorrow.state.toString. Obviously, it does not work for me
just to leave here the complete solution:
the rule check the text in the calendar KalendarOdpady_NextEventTitle and start date of the event from calendar KalendarOdpady_NextEventStart and then lights up the Xiaomi Hub light depending on the event name next day.
val tomorrow = now.plusDays(1)
rule "kalendar-odpady"
//zasviet svetielko na xiaomi hube podla vyvozu smeti
when
Time cron "0 00 18 1/1 * ? *" //o 18:00
then
val odpadCas = (KalendarOdpady_NextEventStart.state as DateTimeType).zonedDateTime
logInfo("kalendar-odpady", "je ZAJTRA nejaky vyvoz odpadu?")
if (odpadCas.year == tomorrow.year && odpadCas.month == tomorrow.month && odpadCas.dayOfMonth == tomorrow.dayOfMonth) {
sendBroadcastNotification("zajtra sa daco deje", "sewerage", "WARN")
if (KalendarOdpady_NextEventTitle.state == "Papier") {
sendBroadcastNotification("Vyvazaju papier.", "sewerage", "WARN")
XiaomiGW_Color.sendCommand("240,100,100")
XiaomiGW_Brightness.sendCommand(10)
}
if (KalendarOdpady_NextEventTitle.state == "Plasty") {
sendBroadcastNotification("Vyvazaju plasty.", "sewerage", "WARN")
XiaomiGW_Color.sendCommand("60,100,100")
XiaomiGW_Brightness.sendCommand(10)
}
if (KalendarOdpady_NextEventTitle.state == "Komunálny odpad") {
sendBroadcastNotification("Vyvazaju komunálny odpad.", "sewerage", "WARN")
XiaomiGW_Color.sendCommand("0,0,75")
XiaomiGW_Brightness.sendCommand(10)
}
/* if (KalendarOdpady_NextEventTitle.state == "Kovy") {
sendBroadcastNotification("Vyvazaju kovy.", "sewerage", "WARN")
XiaomiGW_Color.sendCommand("0,100,100")
XiaomiGW_Brightness.sendCommand(10)
}
*/
}
end
rule "kalendar-odpady.svetielkoOff"
//zhasni svetielko na xiaomi hube o 21:00
when
Time cron "0 00 21 1/1 * ? *" //o 21:00
then
logInfo("kalendar-odpady", "je ZAJTRA nejaky vyvoz odpadu?")
XiaomiGW_Brightness.sendCommand(0)
end