Hi James,
I looked through all my openhab.log files since the end of August and did not find anything like that.
I am running openhab 2.2.0. Maybe older openhab versions throw this warning?
What do you get when looking into your items using REST API?
The problem is that this is not formatted correctly, there are two ‘T’ segments. The script will do this if there is an exception thrown by ‘datetime.datetime.strptime’ because it will fallback to just jamming the timezone on the end of the events start time. I guess the strptime function can throw but still format the date.
changing the code to this solves the problem:
if 'start' in SingleEvent:
EventStartTime = SingleEvent['start'].get('dateTime', SingleEvent['start'].get('date'))
try:
datetime.datetime.strptime(EventStartTime, '%Y-%m-%dT%H:%M:%S' + S.CalendarTimeZone)
except ValueError:
if "T" not in EventStartTime:
EventStartTime = EventStartTime + 'T00:00:00' + S.CalendarTimeZone
else:
EventStartTime = EventStartTime
if 'end' in SingleEvent:
EventEndTime = SingleEvent['end'].get('dateTime', SingleEvent['end'].get('date'))
try:
datetime.datetime.strptime(EventEndTime, '%Y-%m-%dT%H:%M:%S' + S.CalendarTimeZone)
except ValueError:
if "T" not in EventEndTime:
EventEndTime = EventEndTime + 'T00:00:00' + S.CalendarTimeZone
else:
EventEndTime = EventEndTime
any ideas ? I´ve read the whole documentation of this Google API but i didn´t find anything for the error: Connection aborted.
System is running on a RPI 3 (with Internet Access )
pi@raspberrypi:/etc/openhab2/scripts/CalSyncHAB-master $ python CalSyncHAB.py
Traceback (most recent call last):
File "CalSyncHAB.py", line 126, in <module>
Main()
File "CalSyncHAB.py", line 58, in Main
OpenHABResponse = requests.post(CalendarEventSummaryItemURL, data = '', allow_redirects = True)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 94, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 49, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 457, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 569, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 407, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(111, 'Connection refused'))
I took @FrankR’s example and tried to put my own items in the rule… I’m stuck right at the end…
I’ve got basically the same Setup with items and stuff (a bit of a renaming)…
My rule:
rule "Binder Abfallkalender"
when
Time cron "0 0 1 * * ?" or
System started
then
gCalTrash.members.forEach[ gc |
val eventStart = gCalendar.members.filter[ act | act.name == gc.name+"_StartTime"].head
val eventEnd = gCalendar.members.filter[ act | act.name == gc.name+"_EndTime"].head
val eventDesc = gCalendar.members.filter[ act | act.name == gc.name+"_Description"].head
val eventSum = gCalendar.members.filter[ act | act.name == gc.name+"_Summary"].head
var dtStart = new DateTime((eventStart as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
var dtEnd = new DateTime((eventEnd as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
...
end
I can’t get the right casts for dtStart and dtEnd
2018-02-19 20:21:35.713 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'Binder Abfallkalender': Could not cast Calendar_GoogleTrash_Event1_StartTime (Type=DateTimeItem, State=2018-02-19T00:00:00.000+0100, Label=TrashKal Ev1 Start, Category=calendar, Groups=[gCalendar]) to org.eclipse.smarthome.core.library.types.DateTimeType; line 41, column 31, length 26
this is the exact line with var dtStart...
What’s wrong here?
I tried:
var eventStart
var DateTime eventStart
var eventStart ... as DateTimeItem
var DateTime eventStart ... as DateTimeItem
// also the deprecated
var dtStart = new DateTime((eventStart as DateTimeType).calendar.timeInMillis)
One error seems to be the Python script.
My Max Value is on 5 events!
if I now create an event at 17:00 for 17:15 and read in Openhab.
If I delete the event before 17:15 and read in Openhab, but only 4 events in the future, then the event will not be removed at 17:15 in Openhab!
I think we need a little Function like
if RetrievedEvents < MaxEvents than Clear all Openhab Item’s
I you didn’t Change the Script, in line 54 to 70 all events are purged and then they’re created anew… There shouldn’t be the fitfth element still in openHAB?
Ah - That’s right! I changed the script a bit, I’m running a few tests this week.
remember me to publish my code on the weekend. I took care of purging Event-IDs, which are no more used …
I Kind of hijacked the script by @davorf and did mainly the following works:
add MQTT-Support
made it controllable, to either use MQTT or REST to update OH2 items
added reading for additional Event-Attributes: EventId, EventNotificationTime, EventEmailTime
moved from pruging all items and updating them afterwards to purging those items, which are not used anymore
ad 1) + 2)
you can now chose your weapon of choice for updating: MQTT or REST
ad 3)
I like the idea to have an Event to trigger something directly at the StartTime, but I also have Events, which I use for throwing my Kids out of the house! e.g. they have an appointment for ther sports, I let openHAB say via the room loudspeakers: “Get out to < EVENTNAME>”. For that I’d like to have distinct times and I use Google Calender notification for it.
Email-Notification time for notifying way in advance
normal notification time for notifying a few minutes before
So you can have actions and rules on that tiems.
ad 4)
at the end, the script compares the number of items updated with the MaxEntry in the settings and purges left overs in OH2, if there are ones.
That way you won’t have needless “item changes” within openHAB on every script run.
I’m unsure, if I would make an PR for this on davorf’s github… or if I should just fork it - @davorf, what’s your opinion?
Feel free to make a PR, but please, get the latest version first, since I’ve just merged a pull request before noticing your post. These changes are really good, but there’s a possibility of conflict, so, it would be much easier if you would apply those changes on the latest source. Thank you for your contribution.