Where did I omit a comma or something else  [Solved]

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

Moderator: leecollings

Post Reply
HvdW
Posts: 664
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Where did I omit a comma or something else

Post by HvdW »

Here is a script that should run but it doesn't.
Yesterday when I was composing it, it functioned.
I changed something somewhere and it doesn't run.
No error in the Domoticz log plus no sign of execution of the script.
Help appreciated.

Code: Select all

-- Auto laden uitschakelen

local AUTO_LADEN = 'Auto laden' -- switch device
local VERBRUIK = 'Power' -- P1 reading
local LOGGING = true
return

{
    on = 
    {
        timer = 
        {
            'every minute'
        },
    },
   logging =   
    {
         level = LOGGING and domoticz.LOG_ERROR,
    },

    execute = function(dz)

        -- collect all input data
        local auto_switch_state = dz.devices(AUTO_LADEN).state           
        local power_usage = dz.devices(VERBRUIK).usage 
 
        -- info only on log level = LOG_DEBUG
        dz.log('Auto Laden      : ' .. auto_switch_state, dz.LOG_DEBUG)
        dz.log('Gebruik         : ' .. power_usage, dz.LOG_DEBUG)

        if (auto_switch_state == 'On') then
            if (dz.devices(VERBRUIK).usage > 10000) then
              dz.devices(AUTO_LADEN).switchOff() 
            end
        end
    end
} 

-- einde Auto laden uitschakelen
Using Domoticz version 2022.1
Bugs bug me.
plugge

Re: Where did I omit a comma or something else  [Solved]

Post by plugge »

Code: Select all

level = LOGGING and domoticz.LOG_ERROR,
Hm, I've never seen this as an option in the documentation.
It evaluates to true, not the domoticz.LOG_ERROR code.

$0.02
HvdW
Posts: 664
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Where did I omit a comma or something else

Post by HvdW »

Found it.
Logging should be:

Code: Select all

   logging =   
    {
         level = domoticz.LOG_DEBUG and domoticz.LOG_ERROR,
    },
Bugs bug me.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest