Gcal, subtract time from gcalnextevent

Is it possible to subtract time from variable gcalnextevent, if so, how?

I want to be able to set a departure time in Google Calendar and start my engine block heater in advance based on outdoor temperature.

[quote=“mek, post:1, topic:179573”]Is it possible to subtract time from variable gcalnextevent, if so, how?

I want to be able to set a departure time in Google Calendar and start my engine block heater in advance based on outdoor temperature.[/quote]

I think it would be easier with PLEG.

Inputs

EngineBlockSchedule: (A PLEG Schedule that would start a couple hours before you have to go to work and ends about 15min before you typically leave)
OutdoorTemp: (from Weather underground or from wave thermometer you have)

Conditions

_HeaterOn - EngineBlockSchedule AND (OutdoorTemp < -5)

This is a feature that the gcal plugin is lacking and is in sore need of. Currently the only way to accomplish what you want is to make a separate entry in the calendar for firing up the block heater. It’s a silly hack, I know.

My idea was to use Luup code. I have a working lua code from my Razberry where Im calculating the subtracted time in seconds with the function t=(-0.02temp^2-3.3temp+59)*60 and subtracting from departure time to get engine heater start time.

My problem would have been solved if I was just able to convert gcalnextevent (17/02/14 07:15:00 MV ON) to Unix time.
How hard can it be…? :wink:

This code solved my problem, input is gcalnextevent from GCal and output is unix time.

pattern = "(%d+)/(%d+)/(%d+) (%d+):(%d+):(%d+)"
timeToConvert = luup.variable_get("urn:utz-com:serviceId:GCal1", "gcalnextevent", 31)
runday, runmonth, runyear, runhour, runminute, runseconds = timeToConvert:match(pattern)
convertedTimestamp = os.time({year = runyear+2000, month = runmonth, day = runday, hour = runhour, min = runminute, sec = runseconds})

Nice! This would be a great addition to the gcal plugin.