diff --git a/ical b/ical index a0cc3ba..7f549c8 100644 --- a/ical +++ b/ical @@ -22,7 +22,7 @@ import java.text.SimpleDateFormat import java.util.TimeZone preferences { - input("icalink", "string", title: "ical link") + input("icalink", "string", title: "ical link(s), seperate with a ;") input("updatefeq", "number", title: "Polling Rate (minuites)\nDefault:60", default:60) input("shLoc", "bool", title: "Show location info?", default:false) input("maxEvt", "number", title: "max number of events to show, if you regualy see 'please select an atribute' on dashboad, reduce this number\nDefault:10", default:10) @@ -116,35 +116,53 @@ void getdata(){ } + Date today = new Date() + String todaydate = new SimpleDateFormat("dd-MM-yy").format(today) + log.debug "${today} & ${todaydate}" + //need to re forcast dates prio to sorting -/* + log.debug "${iCalMap.event.size()}" + iCalMap.event = iCalMap.event.values()sort{ a, b -> a.start <=> b.start} //sort the data + log.debug "sorted ${iCalMap.event.size()}" + iCalMap.event = iCalMap.event.unique() + log.debug "filltered ${iCalMap.event.size()}" + /* iCalMap.event.each{ + if (it.start == null) it.start = it.end // not used that i know off + if (it.end == null) it.end = it.start //used some envents didnt have a end date + (t,d,z) = timeHelp(it.start) + fullstart = z + + (t,d,z) = timeHelp(it.end) + fullend = z +/* if (it.repeatFreq){ - (t,d,z) = timeHelp(it.start) - it.start = z - if (it.repeatFreq.contains("DAILY"){ //RRULE:FREQ=DAILY;WKST=TU // SEQUENCE:1 - it.start = it.start + it.repeatNum-1 //add dd to time string + + if (it.repeatFreq.contains("DAILY")&& !it.repeatFreq.contains("INTERVAL") && it.repeatNum < 0){ //RRULE:FREQ=DAILY;WKST=TU // SEQUENCE:1 + log.debug "${fullstart} and ${it.repeatNum} and ${it.repeatFreq} and ${it.repeatNum}" + fullstart = fullstart + (it.repeatNum-1).days //add dd to time string } - else if (it.repeatFreq.contains("WEEKLY") { //RRULE:FREQ=WEEKLY;WKST=MO;UNTIL=20210519T000000Z;INTERVAL=1;BYDAY=TU - it.start = it.start + (it.repeatNum-1*7)* //intervall from the string it.repeatFreq.find("INTERVAL=")+1charcter //add dd to time string + /* + else if (it.repeatFreq.contains("WEEKLY")) { //RRULE:FREQ=WEEKLY;WKST=MO;UNTIL=20210519T000000Z;INTERVAL=1;BYDAY=TU + log.debug "${it.start} and ${it.repeatNum-1*7} and ${it.repeatFreq}" + it.start = it.start + (it.repeatNum-1*7).days //intervall from the string it.repeatFreq.find("INTERVAL=")+1charcter //add dd to time string } - else if (it.repeatFreq.contains("monthly") { // no data yet - it.start = it.start + (it.repeatNum-1) //add MM to time string + else if (it.repeatFreq.contains("monthly")) { // no data yet + it.start = it.start + (it.repeatNum-1).month //add MM to time string } - else if (it.repeatFreq.contains("yearly") { // no data yet - it.start = it.start + (it.repeatNum-1) //add yyyy to time string + else if (it.repeatFreq.contains("yearly")) { // no data yet + it.start = it.start + (it.repeatNum-1).year //add yyyy to time string } - } - -*/ + } - iCalMap.event = iCalMap.event.values()sort{ a, b -> a.start <=> b.start} //sort the data - - Date today = new Date() - log.debug "${today}" - String todaydate = new SimpleDateFormat("dd-MM-yy").format(today) - log.debug "${today} & ${todaydate}" + } +*/ +// iCalMap.event = iCalMap.event.values()sort{ a, b -> a.start <=> b.start} //sort the data +// log.debug iCalMap.event.size() +// iCalMap.event = iCalMap.event.unique() +// log.debug "fileter sorted again ${iCalMap.event.size()}" + Integer MaxCount = 0 @@ -164,35 +182,41 @@ void getdata(){ fullend = z timeend = t - if (today<=fullstart || today<=fullend) { //and not canciled? - + if (today<=fullstart || today<=fullend) { //and not canciled? MaxCount = MaxCount +1 //today or date - if (today>=fullstart && today<=fullend || todaydate==datestart) attrString+=""+"TODAY"+" " //today events - else attrString+=""+datestart+" " //start date - - + if (today>=fullstart && today<=fullend || todaydate==datestart){ //today events + attrString+=""+"TODAY"+" " + } + else if (fullstart-today < 7) { //in 7 days + String days = fullstart-today + String dayordays + if (days == "1") dayordays = "day" + else dayordays = "days" + attrString+=""+"In "+days+" "+dayordays+" " //start date + } + else { // > 7 days + attrString+=""+datestart+" " //start date + } // all day or times - if(it.start.indexOf("T") == -1) {attrString+="All Day"} //all day event - else { //time event - attrString+=timestart+" to " //start time - attrString+=timeend+"" //end time - } - -//description and location + if(it.start.indexOf("T") == -1) {attrString+="All Day"} //all day event + else attrString+=timestart+" to "+timeend+"" //time event +//description attrString+="${it.summary}" //description +//location if(it.location != null) attrString+="${it.location.replace('\\','')}" //location - } } } + attrString+="" //log.debug"end" if(attrString.length() >= 1024) log.warn "To many Char. please reduce max number of events or turn off location = ${attrString.length()}" sendEvent(name:"tileAttr",value:attrString) sendEvent(name: "CharCount", value: "${attrString.length()} out of 1024 alowed") + log.info "done get" runIn(state.updatefeq,getdata) }