Page 1 of 1

always one step behind acting onwrong state

Posted: Wednesday 26 September 2018 19:45
by menkepie
Hi,

Got a strange behavior since I created a LUA script. State send to log seems always one step behind. Please see the behavior in this simple test script. Any clue?

Thx M.

log:
018-09-26 19:32:45.728 dzVents: Info: Handling events for: "Dummy schakelaar", value: "On"
2018-09-26 19:32:45.728 dzVents: Info: ------ Start internal script: test: Device: "Dummy schakelaar (Dummy)", Index: 157
2018-09-26 19:32:45.728 dzVents: Info: Hey! I am Open!
2018-09-26 19:32:45.728 dzVents: Info: ------ Finished test

script:

Code: Select all

return {
   on = {
      devices = {
         'Dummy schakelaar'
      }
   },
   execute = function(domoticz, switch)
      if (switch.state == 'On') then
         domoticz.log('Hey! I am Open!')
      else
         domoticz.log('Hey! I am Close!')
      end
   end
}

Re: always one step behind acting onwrong state

Posted: Wednesday 26 September 2018 19:54
by dannybloe
I don't see what's wrong with you log dump here. Looks as expected to me. What did you expect to see here?

Re: always one step behind acting onwrong state

Posted: Wednesday 26 September 2018 20:06
by menkepie
Well...switch On should be 'Hey, I am Close' ...

Re: always one step behind acting onwrong state

Posted: Wednesday 26 September 2018 20:23
by waaren
menkepie wrote: Wednesday 26 September 2018 20:06 Well...switch On should be 'Hey, I am Close' ...
Try this... :D

Code: Select all

return {
   on = {
      devices = {
         'Dummy schakelaar'
      }
   },
   execute = function(domoticz, switch)
      if (switch.state == 'Off') then
         domoticz.log('Hey! I am Open!')
      else
         domoticz.log('Hey! I am Close!')
      end
   end
}

Re: always one step behind acting onwrong state

Posted: Wednesday 26 September 2018 22:21
by menkepie
Omg, lol