I’m trying to create some simple scene, triggered by temperature sensor from Netatmo station, but run only during certain time of day (like: if temperature drops below 0 degrees, then turn on electric heater, but only between 10:00 and 13:00. (another topic is that heater should be turned on also if at 10:00 temperature is already below 0 degrees)
I created a scene triggered by chosen temperature sensor from Netatmo. Then I added a code which I’ve found on this forum, modifying it to desired hours:
local pStart = “22:30” – Start of time period
local pEnd = “06:15” – End of time period
local allow = true – true runs scene during period, false blocks it
local hS, mS = string.match(pStart,“(%d+)%:(%d+)”)
local mStart = (hS * 60) + mS
local hE, mE = string.match(pEnd,“(%d+)%:(%d+)”)
local mEnd = (hE * 60) + mE
local tNow = os.date(“*t”)
local mNow = (tNow.hour * 60) + tNow.min
if mEnd >= mStart then
return (((mNow >= mStart) and (mNow <= mEnd)) == allow)
else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)
end
The scene turns on smartplug with a heater attached to it.
So far it was good, when real temperature was below desired one the scene was triggered but only within desired timeframe.
But then I changed temp. condition to be below real reading (should give me false as a result and scene shouldn’t run) and… the plug was still turning on.
After several tries, since I have only few items attached to the central unit I decided to make reset of the central unit, re-installing all devices and setting the scenes again from scratch.|
And now… srurprise - after enering the same code which was working before, I am getting an error “Error in Lua for scenes and events”.
I don’t understand it, what I am doing wrong?
How to set this scene to be properly working?
Another topic is a functionality which is implemented in current release of UI7 - setting a trigger I can restrict it to certain times and weekdays. How does it work? This is the AND or OR condition?
I tried to set this up, but also with poor results. I am not really sure if the time restriction is really working (seem to have no matter for the rule to be triggered)
I’ve searched through the forum but also with no success. I am quite lame in coding and totally newbie to Vera, so it may be that I don’t know the proper keywords
May I ask you for some kind of step by step walktrough to understand how to work it out properly?