Page 1 of 1

Unexpected symbol

Posted: Wednesday 10 June 2020 12:00
by havnegata
Anyone can tell me whats wrong here?:

..ticz/scripts/dzVents/generated_scripts/Lys parkering.lua:18: unexpected symbol near '}'

Code: Select all

return {
    on = {
        devices = {'Lux_Fibaro', 'MotionSensor', },
    
},
    execute = function(dz, item)
        local LuxFibaro = dz.devices('Lux_Fibaro')
        local Sensor = dz.devices('MotionSensor')
        local light = dz.devices('Motorvarmer')
        if Sensor.active and LuxFibaro.lux < 1 then
            light.cancelQueuedCommands()
        if dz.time.matchesRule("at 23:01-06:00") then
            light.switchOn().checkFirst()
        elseif Sensor.state == 'Off' or LuxFibaro.lux > 2 then
            light.switchOff().afterMin(3)
        end
    end
}

Re: Unexpected symbol  [Solved]

Posted: Wednesday 10 June 2020 12:14
by waaren
havnegata wrote: Wednesday 10 June 2020 12:00 Anyone can tell me whats wrong here?:

..ticz/scripts/dzVents/generated_scripts/Lys parkering.lua:18: unexpected symbol near '}'
You missed an 'end' after the 'light.cancelQueuedCommands()'

did you meant this?

Code: Select all

return
{
    on =
    {
        devices =
        {
            'Lux_Fibaro',
            'MotionSensor',
        },
    },

    execute = function(dz, item)
        local LuxFibaro = dz.devices('Lux_Fibaro')
        local Sensor = dz.devices('MotionSensor')
        local light = dz.devices('Motorvarmer')

        if Sensor.active and LuxFibaro.lux < 1 then
            light.cancelQueuedCommands()
        end

        if dz.time.matchesRule("at 23:01-06:00") then
            light.switchOn().checkFirst()
        elseif Sensor.state == 'Off' or LuxFibaro.lux > 2 then
            light.switchOff().afterMin(3)
        end
    end
}

Re: Unexpected symbol

Posted: Wednesday 10 June 2020 14:32
by havnegata
Yes, sweet!! Thanks again waaren!