Page 1 of 1

Rolluik script allways returns "Nill" error.  [Solved]

Posted: Friday 24 May 2024 11:31
by Loekie63
HI everybody,
I am a total noob at programming dzVents so I am reading for days now and created a script for moving my "Rolluik"to a certain percentage at a certain time on certain days of the week with a check if it isn't allready there. But when i run de code I get an error "attempt to index a nil value (global 'Domoticz')" any help would be greatly appreciated.

Code: Select all

return
{
    on = 
     {
        timer = 
        { 
            'at 11:17 on sat,sun' ,
        },
     },
 
     logging =
     {
         level = Domoticz.LOG_DEBUG,
         marker = 'Rolluik voor',
     },
 
     data =
     {
         currentState =
         {
             initial = '',
         },
     },

    execute = function(dz)
        local rolluik = dz.devices('Rolluik Raam Voor')
        
        local level = rolluik.level
        
        dz.log('Device ' .. rolluik.name .. '; level is '.. level .. '%' , dz.LOG_DEBUG)
        
        if rolluik.level < 61 then
           rolluik.setLevel(61)    
        end
    end
}

Re: Rolluik script allways returns "Nill" error.

Posted: Friday 24 May 2024 11:56
by reewoude
Maybe it's because: level = Domoticz.LOG_DEBUG, (13)

the rest of the script is in dz.etc




Martin

Re: Rolluik script allways returns "Nill" error.

Posted: Friday 24 May 2024 13:28
by Loekie63
Thx Martin
Shurely a Noob beginners error. I changed everything to reflect only "domoticz" functions and now it works like a charm.
Just for info:
I started to create this script in dzVents as in blockly (the rest of my scripts are in Blockly) you cannot do this.(Error attempt to compare string with number)
The initial problem was. In the weekend the Rolluik opens later. I handled that with timers on the device but.....
When the wife gets up early and opens the Rolluik not equal to 61% before 08:00 it will move to 61% as set by the device timer at 08:00.
I searchd for a way to check the position before moving in Blockly but that did not succeed.
So for everyone who wants to set his rolluik and check the % before moving please feel free to use my first dzVents script i ever created "with the help of Martin". (don't forget to change al dz functions to domoticz funfctions.