Page 1 of 1

Playing with dzVent and Table

Posted: Monday 14 November 2022 15:48
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

Re: Playing with dzVent and Table

Posted: Monday 14 November 2022 16:25
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 )

Re: Playing with dzVent and Table

Posted: Monday 14 November 2022 16:47
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()