Wierd LUA Time behaviour

Moderator: leecollings

Post Reply
pikapt
Posts: 37
Joined: Wednesday 25 January 2017 20:54
Target OS: Linux
Domoticz version:
Contact:

Wierd LUA Time behaviour

Post 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)
Last edited by pikapt on Sunday 12 February 2017 22:36, edited 1 time in total.
User avatar
jvdz
Posts: 2266
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Wierd LUA Time behaviour

Post by jvdz »

Did you mark this script as Time when created in the internal editor, to avoid running it with each device change?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
pikapt
Posts: 37
Joined: Wednesday 25 January 2017 20:54
Target OS: Linux
Domoticz version:
Contact:

Re: Wierd LUA Time behaviour

Post 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..
pikapt
Posts: 37
Joined: Wednesday 25 January 2017 20:54
Target OS: Linux
Domoticz version:
Contact:

Re: Wierd LUA Time behaviour

Post 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?
User avatar
jvdz
Posts: 2266
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Wierd LUA Time behaviour

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
pikapt
Posts: 37
Joined: Wednesday 25 January 2017 20:54
Target OS: Linux
Domoticz version:
Contact:

Re: Wierd LUA Time behaviour

Post by pikapt »

Well it's actually happening with xiaomi (zigbee) devices as well.. !
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest