Basically is just building a string and storing it as an attribute. Hollar if you get stuck….
i dont even know where to begin, neither the drives im looking at make much sense
ok ive got this, is it right lines
SimpleDateFormat sdf= new SimpleDateFormat("yyyyMMdd")
for (i=1;i<iCalMap.event.size()+1;i++){
wkStr = iCalMap.event["$i"].start
endStr = wkStr.indexOf("T")
wkStr = wkStr.substring(0,endStr)
today = sdf.format(new Date()).toString()
if (today==wkStr) {
String attrStr = "<table id='eventTable'>"
attrStr += addToAttr("Date","start")
attrStr += addToAttr("Description","summary")
}
attrStr += "</table>"
}
updateAttr("html", attrStr)
runIn(state.upFeq,getdata)
OK this line throwing an error
wkStr = wkStr.substring(0,endStr)
2021-06-05 04:11:38.848 pm errorjava.lang.StringIndexOutOfBoundsException: String index out of range: -1 on line 105 (getdata)
put log on it
-1 says whatever you were doing an indexOf on wasn’t found
soz dont understand, this is event 7-9, imassumin it dose them in order, but usure why logging started at 8
7:[start:20210718T141500Z, end:20210718T144500Z, location:St John's Shopping centre, Preston PR1 1FB, UK, status:CONFIRMED, summary:COVID-19 vaccination appointments],
8:[start:20210502T141000Z, end:20210502T145500Z, location:St John's Shopping centre, Preston PR1 1FB, UK, status:CONFIRMED, summary:COVID-19vaccination appointments],
9:[start:20210430T140000Z, end:20210430T150000Z, status:CONFIRMED, summary:Pick up kids]
Try this
SimpleDateFormat sdf= new SimpleDateFormat("yyyyMMdd")
attrString = "<table>"
for (i=1;i<iCalMap.event.size()+1;i++){
wkStr = iCalMap.event["$i"].start
endStr = wkStr.indexOf("T")
wkStr = wkStr.substring(0,endStr)
today = sdf.format(new Date()).toString()
evt=iCalMap.event["$i"]
if (today==wkStr) {
attrString+="<tr><td>"+evt.start.substring(evt.start.indexOf("T")+1,evt.start.indexOf("T")+3)+":"
attrString+=evt.start.substring(evt.start.indexOf("T")+3,evt.start.indexOf("T")+5)+"</td>"
attrString+="<tr><td>"+evt.end.substring(evt.start.indexOf("T")+1,evt.end.indexOf("T")+3)+":"
attrString+=evt.end.substring(evt.end.indexOf("T")+3,evt.end.indexOf("T")+5)+"</td></tr>"
attrString+="<tr><td colspan='2'>${evt.summary}</td></tr>"
attrString+="<tr><td colspan='2'>${evt.location}</td></tr>"
}
}
attrString+="</table>"
sendEvent(name:"tileAttr",value:attrString)
errorjava.lang.NullPointerException: Cannot get property 'event' on null object on line 101 (getdata
101 is
for (i=1;i<iCalMap.event.size()+1;i++){
Are you in the method where you build the map - it’s saying the map is empty.
yea, i was tydying up and had moved the hasmap back into the try!
2021-06-05 04:31:52.678 pm errorjava.lang.StringIndexOutOfBoundsException: String index out of range: -1 on line 105 (getdata)
wkStr = wkStr.substring(0,endStr)
put debugin on both those lines
what does the line that starts:
endStr =
look like?
If it’s in the date checking then you have an invalid date, may need to put an
if (endStr > 0)
in there
endStr = wkStr.indexOf("T")
log.debug "endStr= $endStr"
wkStr = wkStr.substring(0,endStr)
log.debug "wkStr= $wkStr"
today = sdf.format(new Date()).toString()
what does the "T" do?
The “T” is the delimiter in the datetime string from the calender, i.e. 20210605T113900 - date on one side of the T time on the other side
empty at the end. some entrys dont have time with them
for (i=1;i<iCalMap.event.size()+1;i++){
wkStr = iCalMap.event["$i"].start
endStr = wkStr.indexOf("T")
log.debug "endStr= $endStr"
if (endStr > 0){
wkStr = wkStr.substring(0,endStr)
log.debug "wkStr= $wkStr"
today = sdf.format(new Date()).toString()
evt=iCalMap.event["$i"]
if (today==wkStr) {
attrString+="<tr><td>"+evt.start.substring(evt.start.indexOf("T")+1,evt.start.indexOf("T")+3)+":"
attrString+=evt.start.substring(evt.start.indexOf("T")+3,evt.start.indexOf("T")+5)+"</td>"
attrString+="<tr><td>"+evt.end.substring(evt.start.indexOf("T")+1,evt.end.indexOf("T")+3)+":"
attrString+=evt.end.substring(evt.end.indexOf("T")+3,evt.end.indexOf("T")+5)+"</td></tr>"
attrString+="<tr><td colspan='2'>${evt.summary}</td></tr>"
attrString+="<tr><td colspan='2'>${evt.location}</td></tr>"
}
}
}
attrString+="</table>"
log.debug "attrstring= $attrString"
sendEvent(name:"tileAttr",value:attrString)
found it
was
if (today==wkStr) {
set to
if (today>=wkStr) {
but..
attrString+="<tr><td>"+evt.end.substring(evt.start.indexOf("T")+1,evt.end.indexOf("T")+3)+":"
Empty attrString says that you have no events for today, but the -1 tells me you’re getting some start dates recorded that aren’t valid.
What does evt look like or did you store the end date/time?
it only looks like it returning 1 event and thier is no date, just time
ok i get some of it, alot of my events are all day so thier is no T in the date
I didn’t pull the date out (was assuming it was today and not needed), could add
attrString+="<tr><td colspan='2'>"+wkStr.substring(6,8)+"-"+wkStr.substring(4,6)+"-"+wkStr.substring(0,4)+"</td></tr>"
right after the if to include it.
On the no “T” could always set endStr = 8, but then we need to handle the time in the table .
geeting there
what does this do, do i need the end string?
wkStr = wkStr.substring(0,endStr)