Problem with virtual clock / variables at Vera startup

Hello everyone,

I have a problem using the virtual clock plugin.

The situation is the following: I want to have started my coffeemachine 15 minutes before my alarm goes of. This is why I check the current phone alarm using Tasker, and write the alarm time using the virtual clock plugin using tasker on my vera plus.

On the vera, I run the following script:

local WeckerGanz = luup.variable_get("urn:upnp-org:serviceId:VClock1","AlarmTime", 28)
local ErsterDoppelpunkt = WeckerGanz:find(":") 
local ZweiterDoppelpunkt = WeckerGanz:find(":",ErsterDoppelpunkt+1) 
local WeckerStunden = tonumber(WeckerGanz:sub( 0, ErsterDoppelpunkt-1) )
local WeckerMinuten = tonumber(WeckerGanz:sub( ErsterDoppelpunkt+1, ZweiterDoppelpunkt-1) )


hours = os.date('*t',os.time())["hour"]
minutes   = os.date('*t',os.time())["min"]

KaffeestartMinuten = (WeckerMinuten - 15) % 60

if WeckerMinuten < 15 then
	KaffeestartStunden = (WeckerStunden - 1) % 24
end
if WeckerMinuten >= 15 then
	KaffeestartStunden = WeckerStunden
end

if KaffeestartStunden ~= hours 
then
print("Stunden sind falsch!")
return false
end


if KaffeestartMinuten ~= minutes then
print("Minuten sind falsch!")

return false
end

This does the following: In the first part, the data of the virtual clock are seperated in hours and minutes.

the current hours and minutes are also extracted from the os.time.

In the next step, I substract 15 minutes from the minutes of the alarm. If the Alarm- minute is lower then 15, we have to move to the hours before.

In the last step, the os hour and os minutes are compared to the modified alarm hour and minute. If they are not the same, the scene is aborted using “return false”.


The problem is, that if I restart my vera (or if there is an error in lua), my coffeemachine turns on. The scene is triggered every minute.

I do not know whether the problem comes from the plugin or from my comparison of the values. Does anybody have a clue?

Thank you!