Page 1 of 1

Wierd LUA Time behaviour

Posted: Sunday 12 February 2017 14:14
by pikapt
Got a simple Lua script to open my Blinds but the log is showing some weird stuff.
Part of my script:
if(timehour_n == 09 and timemin_n == 30 and IsWeekend()=='True') then
if(bedPosition==0) then
commandArray['Bed Blinds']='Set Level 30'
end
if(livingPosition==0) then
commandArray['Livingroom Blinds']='On'
end
end
and the log of the switch
2017-02-12 10:20:16 On
2017-02-12 10:20:01 Set Level: 30 %
2017-02-12 10:20:01 On
2017-02-12 09:30:08 Set Level: 30 %
2017-02-12 09:30:01 Off
2017-02-12 09:30:01 Set Level: 30 %
2017-02-11 18:36:20 Off
So blinds were closed at 18:36 on the 11/02. At 9:30 (as per script), they were set to 30% but we see 3 lines for this action(1. set to 30%, 2. set to off (previous state), 3. set to 30% (again)). Same happens at 10:20 where it sets to "on", we see 1. On, 2. set to 30% (previous state), 3. set to on.

here is the full script for reference
function IsWeekend()
local dayNow = tonumber(os.date("%w"))
local weekend
if (dayNow == 0) or (dayNow == 6) then weekend = "True"
else weekend = "False"
end
return weekend
end

local timehour = os.date("%H")
local timehour_n = tonumber(timehour)
local timemin = os.date("%M")
local timemin_n = tonumber(timemin)
local bedPosition = tonumber(otherdevices_svalues['Bed Blinds'])
local livingPosition = tonumber(otherdevices_svalues['Livingroom Blinds'])

commandArray = {}

if(timehour_n == 08 and timemin_n == 10 and IsWeekend()=='False') then
if(bedPosition==0) then
commandArray['Bed Blinds']='Set Level 30'
end
if(livingPosition==0) then
commandArray['Livingroom Blinds']='On'
end
end

if(timehour_n == 09 and timemin_n == 00 and IsWeekend()=='False'and bedPosition>0 and bedPosition<95) then
commandArray['Bed Blinds']='On'
end

if(timehour_n == 09 and timemin_n == 30 and IsWeekend()=='True') then
if(bedPosition==0) then
commandArray['Bed Blinds']='Set Level 30'
end
if(livingPosition==0) then
commandArray['Livingroom Blinds']='On'
end
end

if(timehour_n == 10 and timemin_n == 20 and IsWeekend()=='True'and bedPosition>0 and bedPosition<95) then
commandArray['Bed Blinds']='On'
end
return commandArray
Running V3.6635 (latest corbin release)

Re: Wierd LUA Time behaviour

Posted: Sunday 12 February 2017 15:07
by jvdz
Did you mark this script as Time when created in the internal editor, to avoid running it with each device change?

Jos

Re: Wierd LUA Time behaviour

Posted: Sunday 12 February 2017 15:34
by pikapt
yep! triple checked that. Even stranger is that I'm having this behavior almost all switches that are on domoticz..
So I guess it's not related with this specific script..

Re: Wierd LUA Time behaviour

Posted: Wednesday 15 February 2017 10:24
by pikapt
I've seen someone reporting this as well in another topic. I guess it's a bug.. Does anyone have else also has this behavior?
The log that i'm referring to is the log button that every switch have, not the logfile itself..

Can anyone just do a simple test, changing the state of any switch and checking the log of that switch to see if there is one or three calls to it?

Re: Wierd LUA Time behaviour

Posted: Wednesday 15 February 2017 17:04
by jvdz
pikapt wrote: The log that i'm referring to is the log button that every switch have, not the logfile itself..
I believe this is working as designed for ZWAVE devices and the status updates come in a couple of times during the change.
At least that is what I also observe happening from day one for my devices.

Jos

Re: Wierd LUA Time behaviour

Posted: Wednesday 15 February 2017 21:10
by pikapt
Well it's actually happening with xiaomi (zigbee) devices as well.. !