Cannot create log entry from dzVents script. Log tab "Status" always empty

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

Moderator: leecollings

Post Reply
User avatar
andrehj
Posts: 45
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by andrehj »

I'm trying to debug a script, but no matter what I do, the tab "Status" in the log (accessed via Setup → Log) always stays empty.
Only the errors in the scripts are shown in the "Error" tab.

These are my log settings in "Setup → Settings → Other:
2024-11-09 20_47_29-Domoticz log settings.png
2024-11-09 20_47_29-Domoticz log settings.png (29.17 KiB) Viewed 1397 times
This is a very simply test script, which should write "Testmessage" in my log, but that does not happen (the script is executed, since the value of the device IdxEnergyMeter changes frequently, and other parts of the script work fine).

Code: Select all

return {
    on = {
          devices = {IdxEnergyMeter}
	},
	logging = {
		level = domoticz.LOG_INFO, -- Can be domoticz.LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG or domoticz.LOG_ERROR
		marker = 'Randapparatuur',
	},
    execute = function(domoticz, device)
            domoticz.log('Testmessage')
    end
}
I've also replaced
level = domoticz.LOG_INFO
by
level = domoticz.LOG_DEBUG

But that didn't change anything either. My status tab stays empty:
2024-11-09 20_59_11-Domoticz Log tab status empty.png
2024-11-09 20_59_11-Domoticz Log tab status empty.png (20.06 KiB) Viewed 1395 times
I'm out of options
How can I write messages and values from dzVents to the log "Status" such that I can debug my scripts? :?:
HvdW
Posts: 532
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by HvdW »

Try:

Code: Select all

return {
    on = {
          devices = {'IdxEnergyMeter'},    -- the name or without '  ' the number of the device
          timer = { 'every 1 minutes'},
	},
	logging = {
		level = domoticz.LOG_INFO, -- Can be domoticz.LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG or domoticz.LOG_ERROR
		marker = 'Randapparatuur',
	},
    execute = function(domoticz, item)
      local text = 'this is a test message'
      domoticz.log('Updated text sensor with: ' .. text, domoticz.LOG_INFO)
            --domoticz.log('Testmessage')
    end
}
and take your time to read the dzVents wiki.
Bugs bug me.
User avatar
andrehj
Posts: 45
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by andrehj »

Thanks @HvdW, I will try your suggestions later today.
I do have one more question and one remark though:
  • Via Setup → Log I have three log tabs: All, Status and Error. How these tabs reflect the four log statuses (LOG_INFO, LOG_STATUS, LOG_ERROR and LOG_DEBUG)?
  • You refer to the dzVents wiki. But that only has a very small section about logging. It describes four log levels (LOG_INFO, LOG_STATUS, LOG_ERROR and LOG_DEBUG). But not how to write to them or why I cannot see all these four levels in my log as accessible via Setup → Log. So it's not very useful.
HvdW
Posts: 532
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by HvdW »

Maybe take some time to really study the dzVents wiki.
domoticz.log van be found 27 times.
You also will find the next simple example.

Code: Select all

    return {
        on = {
            devices = {
            '<exact name of the switch>'
            }
        },
        execute = function(domoticz, switch)
            if (switch.state == 'On') then
                domoticz.log('Hey! I am on!')
            else
                domoticz.log('Hey! I am off!')
            end
        end
    }
The are many examples in the wiki.
Try it and you'll like it.
Bugs bug me.
User avatar
andrehj
Posts: 45
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by andrehj »

Thanks @HvdeW, but you still fail to understand the problems.

1. All of these examples do not work.
I still have only three tabs in Setup → Log, (All, Status and Error), as shown in the picture in my original post.
And my test messages do not show up in any of these tabs.
Only if there is an error in my script, it is shown in the Error and the All tab. That's all that works.
This script

Code: Select all

local IdxEnergyMeter = 288

return {
    on = {
        devices = {IdxEnergyMeter},   -- the name or without '  ' the number of the device
        timer = { 'every 1 minutes'},
	},
	logging = {
		level = domoticz.LOG_DEBUG, -- Can be domoticz.LOG_DEBUG, domoticz.LOG_INFO, domoticz.LOG_STATUS or domoticz.LOG_ERROR
		marker = 'Randapparatuur',
	},
    execute = function(domoticz, device)
		domoticz.log('DEBUG log line!', domoticz.LOG_DEBUG)
		domoticz.log('INFO log line!', domoticz.LOG_INFO)
		domoticz.log('STATUS log line!', domoticz.LOG_STATUS)
		domoticz.log('ERROR log line!', domoticz.LOG_ERROR)
    end
}
Only creates the line
2024-11-10 10:43:16.435 Error: dzVents: Randapparatuur: ERROR log line!
in the Error and All tab.
The other three lines with logging do nothing... :(

2. More log levels than log tabs:
There are four (or five) different log levels:
domoticz.LOG_DEBUG
domoticz.LOG_INFO
domoticz.LOG_STATUS)
domoticz.LOG_ERROR
(and I also found domoticz.LOG_MODULE_EXEC_INFO in one of the script examples....)
But there are only three tabs (All, Status and Error). Where are the Debug and Info tabs?
User avatar
madpatrick
Posts: 645
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by madpatrick »

You could try try

Code: Select all

domoticz.log('FORCE log line!', domoticz.LOG_FORCE
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
User avatar
andrehj
Posts: 45
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by andrehj »

I'm a little further:
I've just changed something in /etc/init.d/domoticz.sh.
From

Code: Select all

DAEMON_ARGS="$DAEMON_ARGS -log /home/pi/domoticz/log/domoticz.log"
DAEMON_ARGS="$DAEMON_ARGS -loglevel  error"
# DAEMON_ARGS="$DAEMON_ARGS -loglevel  normal,status,error"
to

Code: Select all

#DAEMON_ARGS="$DAEMON_ARGS -log /home/pi/domoticz/log/domoticz.log"
#DAEMON_ARGS="$DAEMON_ARGS -loglevel  error"
DAEMON_ARGS="$DAEMON_ARGS -loglevel  normal,status,error"
and executed

Code: Select all

sudo systemctl daemon-reload
sudo service domoticz stop
sudo service domoticz start
Now the line
domoticz.log('Test ERROR log line', domoticz.LOG_ERROR) works in the error tab
and
domoticz.log('Test STATUS log line', domoticz.LOG_STATUS) works in the status tab
and
both show in the all tab.

However, the lines
domoticz.log('Test DEBUG log line', domoticz.LOG_DEBUG)
domoticz.log('Test INFO log line', domoticz.LOG_INFO)
still do nothing.

Should I add something to this line to solve that?
DAEMON_ARGS="$DAEMON_ARGS -loglevel normal,status,error"
User avatar
waltervl
Posts: 5388
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by waltervl »

I get these logging when I use the default logging script that is in Domoticz when you create a new script. I modified the logging level in the script from INFO to DEBUG

Code: Select all

 2024-11-10 11:36:10.707 dzVents: log_script: ------ Start internal script: logging_test: Device: "Test (Dummy)", Index: 107
2024-11-10 11:36:10.707 dzVents: log_script: INFO log line!
2024-11-10 11:36:10.707 Status: dzVents: log_script: STATUS log line!
2024-11-10 11:36:10.707 Error: dzVents: log_script: ERROR log line!
2024-11-10 11:36:10.707 dzVents: Debug: log_script: DEBUG log line!
2024-11-10 11:36:10.707 dzVents: log_script: ------ Finished logging_test 
Script:

Code: Select all

-- This example shows you how to work with various log levels
--
-- The script is triggered by a dummy switch called 'test'
--
-- when no log level is specified, the level is taken from the default application settings (dzVents)
--
-- when you specify LOG_STATUS as minimum log level, no logs will be displayed when using LOG_INFO or LOG_DEBUG
--
-- Order is: LOG_DEBUG, LOG_INFO, LOG_STATUS, LOG_ERROR
--
-- LOG_DEBUG will only be displayed when Domoticz is started with debug logging enabled
--
return {
	on = {
		devices = {
			'test'
		}
	},
	logging = {
		marker = 'log_script',
		level = domoticz.LOG_DEBUG
	},
	execute = function(domoticz, device)
		domoticz.log('INFO log line!', domoticz.LOG_INFO)
		domoticz.log('STATUS log line!', domoticz.LOG_STATUS)
		domoticz.log('ERROR log line!', domoticz.LOG_ERROR)
		domoticz.log('DEBUG log line!', domoticz.LOG_DEBUG)
	end
}
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 5388
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by waltervl »

Additional, in contrary to what is stated in the test script, dzvents debug lines will always be shown based on dzvents log level, not related to the main Domoticz log level at startup of Domoticz.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
andrehj
Posts: 45
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by andrehj »

Thanks @waltervl!
Your script outputs the following lines in the All tab of the error log:

Code: Select all

2024-11-10 11:55:10.986 dzVents: log_script: ------ Start internal script: Log test with dummy switch test: Device: "test (Dummy)", Index: 389
2024-11-10 11:55:10.986 dzVents: log_script: INFO log line!
2024-11-10 11:55:10.986 Status: dzVents: log_script: STATUS log line!
2024-11-10 11:55:10.986 Error: dzVents: log_script: ERROR log line!
2024-11-10 11:55:10.987 dzVents: Debug: log_script: DEBUG log line!
2024-11-10 11:55:10.987 dzVents: log_script: ------ Finished Log test with dummy switch test
So that seams to work. But I still have only three tabs in my error log: All, Status and Error.
Shouldn't there also be a tab Info and Debug?
User avatar
waltervl
Posts: 5388
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by waltervl »

No, that has never changed. In Domoticz log we only have All, Status and Error tabs. Only in ALL the info and debug (type info) logging is shown.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
andrehj
Posts: 45
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by andrehj »

Hm, thanks for the clarification. That makes the Info and Debug messages more or less useless, since the All tab is flooded with output of many devices (especially the "P1 meter" writes way to many messages in this log, why?).
That leaves only the Status and Error logs as useful to debug scripts.

Edit: Fixed the many log messages of P1 meter by changing its settings in Setup → Hardware.
User avatar
HansieNL
Posts: 960
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by HansieNL »

You can use the filter to search for your specific loggings.
If you wanna filter except specification you can use ! in front.
!hallo will show everything except logs with hallo in the text.
Blah blah blah
User avatar
andrehj
Posts: 45
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by andrehj »

Thanks everyone.
Issue is now completely resolved.

The problems were:
1. All my hardware had all logging enabled (Info, Status and Error)

2. Years ago I had seen that my All log was flooded with messages, and this made debugging scripts nearly impossible. I did not know that that was caused by the log level settings for the hardware, and had solved that with these settings in domoticz.sh:

Code: Select all

DAEMON_ARGS="$DAEMON_ARGS -log /home/pi/domoticz/log/domoticz.log"
DAEMON_ARGS="$DAEMON_ARGS -loglevel  error"
# DAEMON_ARGS="$DAEMON_ARGS -loglevel  normal,status,error"
Now I had a log file which only contained the errors.
But the setting DAEMON_ARGS="$DAEMON_ARGS -loglevel error" not just prevents these messages to go to the file log, but also prevents the other log entries (status, debug etc) to show up in the log tab!
That is something that is not documented anywhere in the wiki, and should be clarified.

3. I did not know (and this is also undocumented) that there somehow is a separate tab for the Status and Error log entries, but not for the Debug and Info log entries. I find this very illogical, but maybe there is a good reason for it.
User avatar
waltervl
Posts: 5388
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Cannot create log entry from dzVents script. Log tab "Status" always empty

Post by waltervl »

For point 3 this is related that dzvents has some different logging levels than normal Domoticz. Also if Domoticz internal debug levels are switched on (by startup parameters) then these debug logging will also only be shown in the ALL tab. Status and Error tabs are only filters on the ALL logging.

As someone stated before you can set the unique log marker in your script and filter the log on that unique log marker (in my test script "log_script") so you only see the data of that script.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests