Presence Simulation with Google Calendar Scheduler

Any reservations about the test JAR? I would like to merge the PR and cherry pick onto 1.9.x.

Looks good from my perspective. I also did some tests with string items and various flavors of quoting as above. :ok_hand:

1 Like

Thanks! Merged onto master and 1.9.x branches.

@watou I have a question regarding the Google Calender presence simulationā€¦
I have the presence switch defined, I also have a bunch of entries in my presence calendar - just like the screenshots above. I do not see anything in my events.log regarding presence calendar entries, but they are there.
When I activate the presence simulation switch, I see in events.log it is activated. So far so good. :slight_smile:
But once the time is reached there is silence / nothing happening in openhab (e.g. should activate a light switch).

Do you have thoughts where I should see errors or what needs to be done to correct this?

Bernd

Without knowing more about your specific configuration, itā€™s a little difficult to offer useful advice. But if you look at the code, you might spot something that disagrees with your configuration. You could also enable DEBUG logging for

org.openhab.io.gcal
org.openhab.persistence.gcal

to see more of what they are doing in the log.

Hello, I have just added the ā€œGoogle Calendar Schedulerā€ in OpenHab2 (OpenHabian) version.
I did the instructions to accept the Gmail API etcā€¦ Got an ID and a Secret from the APA as expected.
I get the following error message fron the log in Openhab:
Looked all over the forums but find no similar issue:


10:27:22.931 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] -
Google-Integration: U S E R I N T E R A C T I O N R E Q U I R E D !!

  1. Open URL ā€˜https://www.google.com/deviceā€™
  2. Type provided code XXXX-XXXX
  3. Grant openHAB access to your Google calendar
  4. openHAB will automatically detect the permiossions and complete the authentication process
    NOTE: You will only have 1800 mins before openHAB gives up waiting for the access!!!
    10:27:22.945 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] -

And My Error Report in LOG file.
10:28:26.717 [ERROR] [openhab.io.gcal.auth.GCalGoogleOAuth] - authentication I/O exception: 403 Forbidden
{
ā€œcodeā€ : 403,
ā€œerrorsā€ : [ {
ā€œdomainā€ : ā€œusageLimitsā€,
ā€œmessageā€ : ā€œProject 10140009655 is not found and cannot be used for API calls.ā€,
ā€œreasonā€ : ā€œaccessNotConfiguredā€,
ā€œextendedHelpā€ : ā€œhttps://console.developers.google.comā€
} ],
ā€œmessageā€ : ā€œProject 10140009655 is not found and cannot be used for API calls.ā€
}

My project number starts with the 10140009655 but is much longer then that and contains a dash (-)
here is the full ID with a large chunk removed :slight_smile:
10140009655 -8ji2ā€¦5bnan.apps.googleusercontent.com

Any Idea why I have a refused access ?

Thank you for your help.

This seems to be the Solution, sharing for othersā€¦
After opening ā€œContacts APIā€ and ā€œGoogle+ APIā€ suggested in

11:36:59.665 [ERROR] [openhab.io.gcal.auth.GCalGoogleOAuth] - authentication I/O exception: 403 Forbidden
{
ā€œcodeā€ : 403,
ā€œerrorsā€ : [ {
ā€œdomainā€ : ā€œusageLimitsā€,
ā€œmessageā€ : ā€œAccess Not Configured. Calendar API has not been used in project 10140009655 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/calendar/overview?project=10140009655 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.ā€,
ā€œreasonā€ : ā€œaccessNotConfiguredā€,
ā€œextendedHelpā€ : "https://console.developers.google.com/apis/api/calendar/overview?project=10140009655 "
} ],
ā€œmessageā€ : ā€œAccess Not Configured. Calendar API has not been used in project 10140009655 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/calendar/overview?project=10140009655 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.ā€
}

Hi. I have followed the setup instructions and Iā€™m able to set calendar entries and see their effect on the items. Iā€™m trying to get gcal-persistence to work, but I donā€™t see events being created on my calendar. I have enabled TRACE and I see this

2017-11-11 08:42:21.810 [TRACE] [gcal.internal.GCalPersistenceService: 235] - going to upload 1 calendar entries to Google now ā€¦
2017-11-11 08:42:22.979 [DEBUG] [gcal.internal.GCalPersistenceService: 258] - succesfully created new calendar event (title=ā€˜[PresenceSimulation] SS_S02_Gā€™, date=ā€˜{ā€œdateTimeā€:ā€œ2017-11-25T08:42:20.000-03:00ā€}ā€™, content=ā€˜send SS_S02_G ONā€™) in 1152ms

Any ideas on how to further debug this issue? I have followed the exact setup procedure shown on the wikiā€¦ the only change I introduced (apart from the calendar name) is a different group name to identify what items to persists (gPresenceSim*). Another thing that I have noted is that since I installed gcal and gcal persist after some 30 min of running OH (v2.1) will run out of memory and stop responding. Could this be related?

Thanks!

So it sounds like you are using a different calendar than the default. Dumb question, but are you sure you enabled the calendar to be visible by selecting the calendar name under ā€œMy Calendarsā€ on the left side of the google calendars page?

Not sure about the out of memory issue. Iā€™ve been running these bindings for a long time and have not seen this issue.

Thanks for the quick reply. Yes, I have made it visible and I tried creating an entry manually (which worked) to make sure at least that all the credentials and calendar set up was rightā€¦

Other thoughts?

Thanks

Hmm. Thatā€™s really odd. According to the log, itā€™s definitely creating a calendar entry 2 weeks in the future. Iā€™m not sure what else to suggest.

HI, I have a problem where my content being sent to my calendar is incorrect. My Title is [PresenceSimulation] and the content is G_PresenceSimulation instead of what I would expect of Send switchName ON. Please see below an extract of the log.

2018-01-23 11:01:08.298 [vent.ItemStateChangedEvent] - Switch2 changed from OFF to ON
2018-01-23 11:10:03.613 [DEBUG] [gcal.internal.GCalPersistenceService] - succesfully created new calendar event (title=ā€™[PresenceSimulation] Switch2ā€™, date=ā€™{ā€œdateTimeā€:ā€œ2018-02-06T11:09:54.000Zā€}ā€™, content=ā€˜G_PresenceSimulationā€™) in 520ms

I am not using the default calendar and the created calendar event uploads what it says it is going to. I am using an RF switch that does not report back the state.

Any suggestions on what to try?
Thanks

Seems strange that thereā€™s so much time between your two log entries (~9 minutes).

Could you post your item definitions for the switch and persistence group?

Hi.

The timings are a red herring as I sent 2 bits of information that were done ~9 minutes apart by mistake.

The items are as follows:
G_PresenceSimulation (Type=GroupItem, Members=3, State=NULL, Label=null, Category=null)
PresenceSimulation (Type=SwitchItem, State=NULL, Label=Presence Simulations, Category=usersecret)

Switch1 (Type=SwitchItem, State=NULL, Label=Lounge Lamp, Category=Switch, Groups=[G_PresenceSimulation])
Switch2 (Type=SwitchItem, State=OFF, Label=Hall Lamp, Category=Switch, Groups=[G_PresenceSimulation])

Thanks

Just FYI. Code fences make this a lot easier to read. :slight_smile:

G_PresenceSimulation (Type=GroupItem, Members=3, State=NULL, Label=null, Category=null)
PresenceSimulation (Type=SwitchItem, State=NULL, Label=Presence Simulations, Category=usersecret)

Switch1 (Type=SwitchItem, State=NULL, Label=Lounge Lamp, Category=Switch, Groups=[G_PresenceSimulation])
Switch2 (Type=SwitchItem, State=OFF, Label=Hall Lamp, Category=Switch, Groups=[G_PresenceSimulation])

Hmm, that looks ok. How about the contents of gcal.persist? Are you sure you have a * after the group name? Like this.

Strategies {
    default = everyChange
}

Items {
    G_PresenceSimulation* : strategy = everyChange
}

Hi

Yes I have the * after the Group Name

Strategies {
    default = everyChange
}
Items {
    G_PresenceSimulation* : strategy = everyChange
}

Well, Iā€™m running out of ideas. :frowning:

I have two more things, and both seem like a stretch, but Iā€™ll ask anywayā€¦

  • your group item G_PresenceSimulation says there are 3 members in the group but you only show 2 (Switch1 and Switch2). Is there another item tagged with that group?

  • the code defines the execute script to be send %s %s. But it can be overridden by uncommenting executescript in services/gcal-persistence.cfg Whatā€™s in your gcal-persistence.cfg file?

Hi, yes the third was a test switch I have set up with nothing behind it so I can toggle on and off without actually turning a Light on and off.

the gcal-persistence.cfg could actually be the root of the problem. I have my calendar_name and my offset uncommented but nothing for my executescript as it is commented out
#executescript=G_PresenceSimulation

I have now replaced this with executescript=send %s %s and it works perfectly. The documentation says this is optional and so I assumed that it automatically did the this by default.

Thank you.

It does do send %s %s by default. In fact, my cfg file has it commented out like this.

#executescript=

I was looking into this a little more closely. I think I found a problem.

By any chance, did you at any point have the executescript line uncommented?

In my testing, when I comment out a line after it has been uncommented, I donā€™t see the configuration being updated properly.

So, the scenario I see is this:

  • Uncomment executescript and add something on the rhs of the equals sign, then save the file, like this
executescript=G_PresenceSimulation
  • Then comment out the executescript line and save the file, like this
#executescript=

From what I see, the internal configuration is never updated to remove the previous value of executescript