Fatal error: credentials

Just installed this plugin and I’m getting this error

Fatal error: credentials

I did set a calendar using the private xml link. I also tried setting the calendar to public and using the public link. Same issue.

Any idea where I can start troubleshooting?

you need to follow the steps outlined in the very first post of the plugin here - http://forum.micasaverde.com/index.php/topic,26692.0.html scroll down to the end of the first post and there are two attachments, one of which is how to setup an API service account.

I just did this last week. I can say that the guide and the screens the plugin developer references look slightly different now and have a slightly different flow, but if you follow the spirit of the steps you need to take, rather than the literal ‘the screen will say exactly this…’ you should have no trouble.

Thanks!!! That worked to clear the error and now it looks like the plugin is accessing my calendar. However, it isn’t seeing my test event I created. I made one test event about two hours ahead and it just says “No more events today”. I click “check” and it looks like it’s checking the calendar but it just comes back with no more events.

Any ideas?

Wait… OPERATOR ERROR!!

Went back to check it out and realized when I created my test event it created it under my default gmail calendar. Not my automation calendar. Switched the event to the automation calendar and it showed up! Success!

Thanks again!

good news. Also, if you have more than one event in the day, you will have to go to the Advanced → varibales tab and check the gc_jsonEvents and you will see the list of all the day’s events.

I have no idea what you want to do with the plugin, but below I’ve pasted in some lua code that i found on a different forum topic, that will announce your calendar events over Sonos, although it could easily be modified to play over any DLNA device. Maybe you will find it useful. I modified it slightly to include ‘tomorrow’ events, with the inherent limitation of the gcal plugin that it only looks exactly 24 hours ahead. I work around that by running it at 7:05 am and having “reminder” entries all listed on my calendar at 7 am. I’m not a savvy enough coder to figure out if there is someway to make the gcal plugin look further out.

[code]url = require(“socket.url”)
local AV_DEV = 123
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”
local time = os.date(‘%I:%M’)
local todaydate = os.date(‘%Y-%m-%d’)
local tomdate = (os.date(“%Y-%m-%d”,os.time()+246060))
local SONOSZONES=“Kitchen”
local SameVolume=“true”
local TEMP_SID =“urn:upnp-org:serviceId:TemperatureSensor1”
local WUGTempHigh = luup.variable_get(TEMP_SID, “CurrentTemperature”, 6)
local currentCondition = luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”, “Forecast.1.Condition”, 3)
local GS_SID = “urn:srs-com:serviceId:GCalIII”
local jsonEvents = luup.variable_get(GS_SID, “gc_jsonEvents”,236)

–checking to see if there are any events for the day. if not, tell us that there are no events for today.

if ((jsonEvents == “[]”) or (jsonEvents == nil)) then
TodaysEvents=“There are no events for today.”
else
TodaysEvents="Todays events are "
end

–checking to see if there are any events for tomorrow

if ((jsonEvents == “[]”) or (jsonEvents == nil)) then
TomorrowsEvents=“There are no events for tomorrow.”
else
TomorrowsEvents="Tomorrows events are "
end

–unwrapping all the different variables in the device variable.

package.loaded.json = nil
local json = require(“json”)
local eventList =json.decode(jsonEvents)
local numberEvents = table.getn(eventList)
local startevent, startDate, startTime, endevent, endTime, eventname, event

–looping around the dumping the variables into an array

for i = 1,numberEvents do
startevent = eventList[ i ].eventStart
startDate = os.date(“%Y-%m-%d”, startevent)
startTime = os.date(“%H:%M:%S”, startevent)
endevent = eventList[ i ].eventEnd
endTime = os.date(“%H:%M:%S”, endevent)
eventname = eventList[ i ].eventName

–if the event happens today, add it to the TodaysEvents variable. if not, don’t add it.

if (startDate == todaydate) then
TodaysEvents = TodaysEvents … eventname … " . "
luup.log(event)
end

–if the event happens tomorrow at it to the TomorrowsEvents variable

if (startDate == tomdate) then
TomorrowsEvents = TomorrowsEvents … eventname … " . "
luup.log(event)
else
TomorrowsEvents=“There are no events for tomorrow.”
end

end
package.loaded.json = nil

–and then of course sending it all to the sonos device.

luup.call_action(LS_SID, “Say”, {Text = string.format(“Good morning, Guess Family! It is now %s. Here is your daily morning report. Today will be %s with a high of %s degrees. %s. %s. Have a great day.”, time, currentCondition, WUGTempHigh, TodaysEvents, TomorrowsEvents), GroupZones=SONOSZONES, SameVolumeForAll=SameVolume, Volume=50}, AV_DEV)[/code]

Nice! Looks like there’s some stuff I can use in there. My intended use is conditional scene execution based on calendar events. Basically turning the lights and TV’s off and on at certain times based on the kid’s school schedules. So, run this scene every day unless it a school holiday. (Holidays are entered into the calendar as events).

Maybe you can assist as your luup coding level is much higher than mine!

I have a simple scene that turns on a light at 6am, mon - fri. I want it to NOT run if the gcal switch is tripped. This is the lua I am trying to use:

local dID = 68
local allow = true
local status = luup.variable_get(“urn:srs-com:serviceId:GCalIII”,“Tripped”,dID)
return ((status == “0”) == allow)

I’ve tried different variables in the local status filed but I’m not really sure what to put there. What do I need to use to get the status of the gcal switch?

This seems to sort of work.
local dID = 68
local allow = true
local status = luup.variable_get(“urn:micasaverde-com:serviceId:SecuritySensor1”,“Tripped”,dID)
return ((status == “0”) == allow)

I can make the scene run / not run using the 0 value but I can’t get it to work using the 1 value. Also, I noticed the Tripped variable in the app settings doesn’t ever change from 0. Even when there’s an active event. Prob why the code isn’t working when it’s looking for a tripped status of 1.

I don’t know what the issue is. I created a test event on my calendar and i see the tripped status go to 1 and the gcal device icon go green. I had to refresh my browser screen immediately following the event becoming active to see that, but i think that is just a browser/display issue and should have no bearing on the Triggered variable in the lua code.

The author of the gcal plugin seems very responsive and the sub-forum is 30+ pages long. I suspect if you post the issue over there you will get more people looking at it and a faster and more complete response. I’m just barely able to read lua…I copied and pasted that previous code base from a different post and simply added another if/else for the tomorrow logic.

I finally got it to work with that code I posted. After doing some research on long google calendar 3 thread I found that if you don’t have a keyword set the scene can be “active” but not triggered. The icon still looks the same. Only if you have a keyword set is the switch actually triggered. I tried entering a keyword but the triggered variable was still 0. I was just about to post a question on the thread when I decided to try the scene just in case, and it worked!! It looks like it’s getting triggered using the keyword. But the variable never changes from 0. Weird, but it’s working now!

Great news. I actually use the keyword ‘reminder’ and stick that in the event description, so that makes sense that I was seeing mine turn active.

I have yet to make the plugin and event trigger scenes, but your code is helpful when I get to that point.

Good collaboration…nice working with you!

See if this helps your forward notifications.

I added a variable to enable GCal to look forward more than one day. The variable gc_ExtraDays (default 0) adds days to how far GCal looks forward.
But please NOTE – I have not tested this and there could be unintended consequences. For example when GCal reads the calendar it loads all the events for the current day + 24 hrs (or more if you use gc_ExtraDays) and then performs various filtering / sorting. So depending on the number of entries it is possible (but unlikely) that Vera may have memory issues or performance issues.

Try this patched version and let me know how it goes. In your use case gc_ExtraDays = 1 should be enough.

Stuart,

Thanks so much. I will mess around with the updated lua file tonight after the kids are asleep. If I understand the logic correctly, this just allows me to get an extra day of events without having to mess with time and my if/else logic to announce tomorrows events? One thing I’m not clear on is how i can make it say today’s events are “…” and tomorrow’s events are “…” with your variable. See below for my code that i currently have.

Thanks again for doing this without anyone even asking.

if (startDate == tomdate) then TomorrowsEvents = TomorrowsEvents .. eventname .. " . " luup.log(event) else TomorrowsEvents="There are no events for tomorrow." end

[quote=“ctguess, post:13, topic:188560”]Stuart,

Thanks so much. I will mess around with the updated lua file tonight after the kids are asleep. If I understand the logic correctly, this just allows me to get an extra day of events without having to mess with time and my if/else logic to announce tomorrows events? One thing I’m not clear on is how i can make it say today’s events are “…” and tomorrow’s events are “…” with your variable. See below for my code that i currently have.

Thanks again for doing this without anyone even asking.

if (startDate == tomdate) then TomorrowsEvents = TomorrowsEvents .. eventname .. " . " luup.log(event) else TomorrowsEvents="There are no events for tomorrow." end[/quote]

I assume you are getting the event list from gc_jsonEvents or gc_jsonActiveEvents ? In which case I’d read the variable into a lua array and iterate the array looking to see which dates were ‘today’ and which were ‘tomorrow’.
Here’s some code I use for testing

local function getjsonEvents(json) -- this is really some sample code and useful for debugging

  local jsonEvents = luup.variable_get(GCAL_SID, "gc_jsonEvents",lul_device)

  if (jsonEvents == "[]") then -- equivalent of a nul so don't try
    return
  end

  local eventList =json.decode(jsonEvents)
  local numberEvents = table.getn(eventList)
  local startevent, startDate, startTime, endevent, endTime, eventname, event
  
  for i = 1,numberEvents do
    startevent = eventList[i].eventStart
    --startevent = os.date("%Y-%m-%dT%H:%M:%S",startevent)
    startDate = os.date("%Y-%m-%d", startevent)
    startTime = os.date("%H:%M:%S", startevent)
    endevent = eventList[i].eventEnd
    endTime = os.date("%H:%M:%S", endevent)
    eventname = eventList[i].eventName
    event = "On " .. startDate .. " event " .. eventname .. " will start at " .. startTime .. " and end at " .. endTime
    DEBUG(3,"Event " .. i .. ": " .. event)
  end
  return
end

Stuart,

I was finally able to find some time to try out your new variable - ExtraDays - but it does not seem to be working. i have an event for tomorrow, about 30 hours from the current time and when i enter 1 as the value for ExtraDays and run the calendar check, it does not find the event. I tried to do some debugging of the lua file (my ability to do so is very limited…) and if i simply add 41 hours to the endtime variable as in the below, it does find the event, but it makes my script of speaking out today’s events and tomorrows events a bit weird. any ideas?

-- endtime = endtime + (3600*41)

Try this version – I somehow forget that there are 24 hrs in a day ::slight_smile:
So ExtraDays was being treated as ExtraHours (not very helpful).

So the way it should work now is that it will look for all events from the start of ‘today’ (local time) and forward 24hrs (or more if ExtraDays > 0) from the current time. In other words, the window of time that it looks for events gets larger during the day.

So lets say you set ExtraDays = 1.

At 00:00 hrs it will ‘see’ all events for today and tomorrow.
If the plugin checked at 12:00 it will see all events for today, tomorrow and up to 12:00 the day after tomorrow.

Does your script filter out unwanted events ? e.g. only announce events where the end time is > ‘now’ (assuming you don’t want to announce events that have passed) and where the start time is < end of tomorrow ?

Thanks Stuart. I will try this version tonight

this is my script, which was “borrowed” from some other forum post, which appears to largely be borrowed from your testing code. I just added the tomdate variable and added an extra if statement in the for loop that iterates through the events found. that is simply so the speech output can gracefully say “Tomorrow’s events are…” and list them out

[code]url = require(“socket.url”)
local AV_DEV = 123
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”
local time = os.date(‘%I:%M’)
local todaydate = os.date(‘%Y-%m-%d’)
local tomdate = (os.date(“%Y-%m-%d”,os.time()+246060))
local SONOSZONES=“Kitchen”
local SameVolume=“true”
local TEMP_SID =“urn:upnp-org:serviceId:TemperatureSensor1”
local WUGTempHigh = luup.variable_get(TEMP_SID, “CurrentTemperature”, 6)
local currentCondition = luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”, “Forecast.1.Condition”, 3)
local GS_SID = “urn:srs-com:serviceId:GCalIII”
local jsonEvents = luup.variable_get(GS_SID, “gc_jsonEvents”,236)

–checking to see if there are any events for the day. if not, tell us that there are no events for today.

if ((jsonEvents == “[]”) or (jsonEvents == nil)) then
TodaysEvents=“There are no events for today.”
else
TodaysEvents="Todays events are "
end

–checking to see if there are any events for tomorrow

if ((jsonEvents == “[]”) or (jsonEvents == nil)) then
TomorrowsEvents=“There are no events for tomorrow.”
else
TomorrowsEvents="Tomorrows events are "
end

–unwrapping all the different variables in the device variable.

package.loaded.json = nil
local json = require(“json”)
local eventList =json.decode(jsonEvents)
local numberEvents = table.getn(eventList)
local startevent, startDate, startTime, endevent, endTime, eventname, event

–looping around the dumping the variables into an array

for i = 1,numberEvents do
startevent = eventList[ i ].eventStart
startDate = os.date(“%Y-%m-%d”, startevent)
startTime = os.date(“%H:%M:%S”, startevent)
endevent = eventList[ i ].eventEnd
endTime = os.date(“%H:%M:%S”, endevent)
eventname = eventList[ i ].eventName

–if the event happens today, add it to the TodaysEvents variable. if not, don’t add it.

if (startDate == todaydate) then
TodaysEvents = TodaysEvents … eventname … " . "
luup.log(event)
end

–if the event happens tomorrow at it to the TomorrowsEvents variable

if (startDate == tomdate) then
TomorrowsEvents = TomorrowsEvents … eventname … " . "
luup.log(event)
else
TomorrowsEvents=“There are no events for tomorrow.”
end

end
package.loaded.json = nil

–and then of course sending it all to the sonos device.

luup.call_action(LS_SID, “Say”, {Text = string.format(“Good morning, Guess Family! It is now %s. Here is your daily morning report. Today will be %s with a high of %s degrees. %s. %s. Have a great day.”, time, currentCondition, WUGTempHigh, TodaysEvents, TomorrowsEvents), GroupZones=SONOSZONES, SameVolumeForAll=SameVolume, Volume=50}, AV_DEV)[/code]

when I added the extra hours to endtime in the GCAL3.lua file to basically try and do what you’re doing with ExtraDays, it was somehow entering the logic for saying "todays events are " even though there were no events, so the speech output was just a bit weird. I probably somehow messed something somewhere else up when i was hacking around. I will give your updated version a try and report back.

Thanks for all the support!

I’m not 100% sure but from memory
for i = 1,numberEvents do
will iterate once even if numberEvents is < 1