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

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

Moderator: leecollings

Post Reply
Loekie63
Posts: 12
Joined: Thursday 28 January 2021 9:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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
}
User avatar
reewoude
Posts: 2
Joined: Sunday 26 February 2023 22:25
Target OS: Linux
Domoticz version: Beta
Location: Limburg
Contact:

Re: Rolluik script allways returns "Nill" error.

Post by reewoude »

Maybe it's because: level = Domoticz.LOG_DEBUG, (13)

the rest of the script is in dz.etc




Martin
Last edited by reewoude on Friday 24 May 2024 11:58, edited 1 time in total.
BunsenLabs Linux
HP-T620
Loekie63
Posts: 12
Joined: Thursday 28 January 2021 9:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Rolluik script allways returns "Nill" error.

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest