Page 1 of 1

Log what's inside a variable

Posted: Thursday 03 October 2019 22:38
by Solderbro
This normally should be simple, for debugging i like to see what's inside a variable.

Here the variable "Heizmodus" in domoticz is filled with "Heizen" from another script by outer temp, while the if statement NEVER occurs true an id never get the loglines at the end.

Code: Select all

                local heizpause = domoticz.variables("Heizmodus").state
                local t = domoticz.time
                local spirit = domoticz.devices('Stube HZG Thermostat')
                local spirith = domoticz.devices('Stube HZG Heizpunkt')
                local spirite = domoticz.devices('Stube HZG Ecopunkt')

                if heizpause == 'Heizen' then
                    print('Modus Stube setzen')
                    domoticz.log('Hey! I am on!')
So the simple question, so the next user get a result from google: How to print a variable into the log?

Solderbro

Re: Log what's inside a variable

Posted: Thursday 03 October 2019 23:24
by boum
Hello,
To print a variable, just use domoticz.log(tostring(variable)) or you can concatenate using the .. operator the value to have a more meaningful output:

Code: Select all

domoticz.log('Hey! my value is ' .. variable .. '!')
In you case, you take the wrong element of the user variable object to get the value. You should use:

Code: Select all

local heizpause = domoticz.variables("Heizmodus").value
See https://www.domoticz.com/wiki/DzVents:_ ... riables.29

Re: Log what's inside a variable  [Solved]

Posted: Friday 04 October 2019 11:11
by Solderbro
Yes that's it, now it is clean at hand why the heating scripts failed. Has become cold here, only 4° at night and 10°C at day.

Thanks, solved and can be closed:-)

Solderbro