attempt to call field 'after_min' (a nil value)

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

Moderator: leecollings

Post Reply
DannyElfman
Posts: 16
Joined: Monday 13 October 2014 14:05
Target OS: Linux
Domoticz version: 3.8136
Location: France
Contact:

attempt to call field 'after_min' (a nil value)

Post by DannyElfman »

Hello,

Quick question. I am very new to LUA and dzVents. I have a simple script generating a classic nil value error but I just cannot get why I have this error ...

Basically, when my squeezebox is playing, it switches on a sonoff connected to my subwoofer.

Script :

Code: Select all

return {

      active = true, -- set to false to disable this script

        on = {
        devices = {
            -- scripts is executed if the device that was updated matches with one of these triggers
            368, -- id Squeezebox
        },

    },
  
    execute = function(domoticz, device)
        
        local caisson = domoticz.devices(527) -- sonoff caisson
        local musique = domoticz.devices('Squeezebox')
        
        if (device.state == 'Off') then
            caisson.switchOff()
        elseif (device.state == 'Stopped') then
            caisson.switchOff().after_min(10)
            musique.switchOff().after_min(10)
        else
            caisson.switchOn()
        
        end
    end
}
switchOn works fine.
switchOff too


From the log :

Code: Select all

2017-09-07 08:12:33.083 dzVents: Info: ------ Start internal script: Caisson_Musique: Device: "Squeezebox (Logitech Media Server)", Index: 368
2017-09-07 08:12:33.083 Error: dzVents: Error: An error occured when calling event handler Caisson_Musique
2017-09-07 08:12:33.083 Error: dzVents: Error: ...cz/scripts/dzVents/generated_scripts/Caisson_Musique.lua:40: attempt to call field 'after_min' (a nil value)
2017-09-07 08:12:33.083 dzVents: Info: ------ Finished Caisson_Musique
Any idea would be really appreciated :)
Debian Jessie VM on EsxI on a Gen 8 Proliant + RFXCom + AeonLabs Zwave+ + Fibaro eye + Fibaro Smoke + Fibaro FGS211 Philips Hue + Harmony Hub + Somfy RTS + Oregon Temp sensors + Xiaomi Gateway + Xiaomi sensors + Sonoff basic
elmortero
Posts: 247
Joined: Sunday 29 November 2015 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9639
Location: Spain
Contact:

Re: attempt to call field 'after_min' (a nil value)

Post by elmortero »

Please check http://www.domoticz.com/forum/viewtopic ... 59&t=18674 which has the info you need.
Hint: you are using the old dzVents manual, some things have changed.
Your answer is in the part about migrating to the new version.
DannyElfman
Posts: 16
Joined: Monday 13 October 2014 14:05
Target OS: Linux
Domoticz version: 3.8136
Location: France
Contact:

Re: attempt to call field 'after_min' (a nil value)

Post by DannyElfman »

Well, first thanks for taking the time to answer me.
Then thanks for spotting it out :)

I had printed the doc a month and a half ago cause I find it easier to read ... I forgot the update issue ^^

I have updated my script. I did not checked yet if it is working but I will and get back to you.

For those interested, the issue was indeed in the timed command which has to be updated with :

caisson.switchOff().afterMin(10)
Debian Jessie VM on EsxI on a Gen 8 Proliant + RFXCom + AeonLabs Zwave+ + Fibaro eye + Fibaro Smoke + Fibaro FGS211 Philips Hue + Harmony Hub + Somfy RTS + Oregon Temp sensors + Xiaomi Gateway + Xiaomi sensors + Sonoff basic
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest