Log what's inside a variable  [Solved]

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

Moderator: leecollings

Post Reply
User avatar
Solderbro
Posts: 80
Joined: Tuesday 18 September 2018 15:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Hamburg, Germany
Contact:

Log what's inside a variable

Post 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
Raspi 3B+RTC, SSD 128GB, Aeotec Gen5, Eurotronic SpiritZ, Fibaro FRGBW, Zipato PIR, Everspring AN180, Neo Coolcam Plug, Fibaro FGMS, Neo Coolcam Doorsensor, Popp Z-Weather
User avatar
boum
Posts: 136
Joined: Friday 18 January 2019 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Log what's inside a variable

Post 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
User avatar
Solderbro
Posts: 80
Joined: Tuesday 18 September 2018 15:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Hamburg, Germany
Contact:

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

Post 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
Raspi 3B+RTC, SSD 128GB, Aeotec Gen5, Eurotronic SpiritZ, Fibaro FRGBW, Zipato PIR, Everspring AN180, Neo Coolcam Plug, Fibaro FGMS, Neo Coolcam Doorsensor, Popp Z-Weather
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest