always one step behind acting onwrong state

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
menkepie
Posts: 3
Joined: Wednesday 26 September 2018 19:38
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

always one step behind acting onwrong state

Post 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
}
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: always one step behind acting onwrong state

Post 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?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
menkepie
Posts: 3
Joined: Wednesday 26 September 2018 19:38
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: always one step behind acting onwrong state

Post by menkepie »

Well...switch On should be 'Hey, I am Close' ...
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: always one step behind acting onwrong state

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
menkepie
Posts: 3
Joined: Wednesday 26 September 2018 19:38
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: always one step behind acting onwrong state

Post by menkepie »

Omg, lol
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest