Playing with dzVent and Table

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

Moderator: leecollings

Post Reply
pipiche
Posts: 2027
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:

Playing with dzVent and Table

Post by pipiche »

I thought moving from python3 to dzVent table would be easy, but looks not

Here after is the script I'm trying to build

Code: Select all

local SCRIPT_NAME = 'testing'

return {

     on = {
            timer = { 'every 1 minutes' }
        },

    logging =
    {
        level = domoticz.LOG_INFO,
        marker = SCRIPT_NAME,
    },

   execute = function(dz, item)

        local thermostats = {
                   ["Salon"] = 'BT Salon ThermoSetpoint',
                   ["SM1"] = 'BT SM1 ThermoSetpoint',
                   ["SM2"] = 'BT SM2 ThermoSetpoint'
          }

         for key, value in ipairs(thermostats) do
            dz.log( 'key: ' .. key .. ' value: ' .. value )
        end
    end
}

and here after the output like nothing found in the for loop
Nov 14 15:19:00 pi3 domoticz[19041]: 2022-11-14 15:19:00.760 Status: dzVents: Info: testing: ------ Start external script: Testing-script.lua:, trigger: "every 1 minutes"
Nov 14 15:19:00 pi3 domoticz[19041]: 2022-11-14 15:19:00.761 Status: dzVents: Info: testing: ------ Finished Testing-script.lua
willemd
Posts: 741
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: Playing with dzVent and Table

Post by willemd »

Probably you need to change

Code: Select all

dz.log( 'key: ' .. key .. ' value: ' .. value )
into

Code: Select all

dz.log( 'key: ' .. key .. ' value: ' .. value,dz.LOG_INFO )
pipiche
Posts: 2027
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:

Re: Playing with dzVent and Table

Post by pipiche »

Thanks, but that was not the issue. The issue was related to the iterator used, and I should be using pairs() instead of ipairs()
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest