Page 1 of 1

Missing logs (Solved)

Posted: Monday 07 December 2020 9:36
by iganin
I have set domoticz.LOG_DEBUG in the script and "error only" in the Domoticz settings.

Code: Select all

return {
    	on =    {
	    	devices =   {
                'Bathroom 2nd Floor PIR',
                'Bathroom 2nd Floor Door Sensor'
    		            },
    	logging    =    {   
                        level       =  domoticz.LOG_DEBUG,   
                        marker      =  'WC' 
                        },
    	        },	
However, I see no logs. Dz version 2020.2
Can someone help me out?

Re: Missing logs

Posted: Monday 07 December 2020 10:01
by waaren
iganin wrote: Monday 07 December 2020 9:36 I have set domoticz.LOG_DEBUG in the script and "error only" in the Domoticz settings. However, I see no logs.
Can you try again after setting the loglevel for dzVents like below?

log settings.png
log settings.png (24.58 KiB) Viewed 1194 times

Re: Missing logs

Posted: Monday 07 December 2020 10:11
by iganin
Now I see all logs from all scripts.
Odd, the one mentioned above shows without the marker

Code: Select all

2020-12-07 10:05:38.757 Status: dzVents: Info: Handling events for: "Bathroom 2nd Floor Door Sensor", value: "Open"
2020-12-07 10:05:38.757 Status: dzVents: Info: ------ Start internal script: Bathroom 2nd Floor Heating Off New: Device: "Bathroom 2nd Floor Door Sensor (Zigbee)", Index: 1050
2020-12-07 10:05:38.759 Status: dzVents: Info: ------ Finished Bathroom 2nd Floor Heating Off New
2020-12-07 10:05:38.759 Status: dzVents: Info: ------ Start internal script: Light 2nd floor WC New: Device: "Bathroom 2nd Floor Door Sensor (Zigbee)", Index: 1050
2020-12-07 10:05:38.759 Status: dzVents: Info: Device Bathroom 2nd Floor Door Sensor was changed
2020-12-07 10:05:38.760 Status: dzVents: Info: Hey! Light to be OFF
2020-12-07 10:05:38.761 Status: dzVents: Info: ------ Finished Light 2nd floor WC New

Re: Missing logs

Posted: Monday 07 December 2020 18:41
by iganin
Maybe i was not clear, the feature to see logs only from the script which has "level = domoticz.LOG_DEBUG" while the rest of scripts work silence

Re: Missing logs

Posted: Monday 07 December 2020 19:14
by waaren
iganin wrote:Maybe i was not clear, the feature to see logs only from the script which has "level = domoticz.LOG_DEBUG" while the rest of scripts work silence
The marker should be in the message. Can you share the complete script?
To prevent all other dzVents scripts from sending something to the log:
You can set the EventSystem and dzVents settings to
log.png
log.png (17.95 KiB) Viewed 1170 times
and set logging = { level = domoticz.LOG_ERROR }, -- in the logging section for all scripts

and use dz.log('your message ', dz.LOG_FORCE ) -- for all messages in the script you do want to investigate

Re: Missing logs

Posted: Monday 07 December 2020 20:04
by iganin
The idea to have an automated light in the bathroom using a door and a PIR sensors.
It's quite challenging, taking into account that someone from the family uses WC without closing the door during night hours or do not close the door when leave the bathroom or temporary leave the bathroom, etc.

Unfortunately, i could find a script example, so I have to made mine.


Of course, having the loges only from this particular script will help me to fine-tune it.



Code: Select all


return {
    	on =    {
	    	devices =   {
                'Bathroom 2nd Floor PIR',
                'Bathroom 2nd Floor Door Sensor'
    		            },
    	logging    =    {   
                        level       =  domoticz.LOG_DEBUG,   
                        marker      =  'WC' 
                        },
    	        },	
	execute = function(domoticz, device)
		domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
   		if (device.name == 'Bathroom 2nd Floor PIR' and device.active)   then
    		    domoticz.devices('Bathroom 2nd Floor Light').switchOn().checkFirst()
    			domoticz.log('Hey! I got Light')
    		elseif (domoticz.devices('Bathroom 2nd Floor PIR').state == 'Off')   then
    		    domoticz.log('Hey! Stay Light On')
    		elseif (domoticz.devices('Bathroom 2nd Floor Door Sensor').state == 'Open' and (domoticz.devices('Bathroom 2nd Floor PIR').state == 'On')) then
    		    domoticz.log('Hey! Light to be OFF')
    		    domoticz.devices('Bathroom 2nd Floor Light').switchOff().afterSec(160)
    		elseif (domoticz.devices('Bathroom 2nd Floor Door Sensor').state == 'Open' and (domoticz.devices('Bathroom 2nd Floor PIR').state == 'Off')) then
    		    domoticz.log('Hey! Light to be OFF')
    		    domoticz.devices('Bathroom 2nd Floor Light').switchOff()
    		else
    			domoticz.log('Not definded!')
 
    		end		
	end
}

Re: Missing logs

Posted: Monday 07 December 2020 20:33
by waaren
iganin wrote: Monday 07 December 2020 20:04 Of course, having the log only from this particular script will help me to fine-tune it.
See my previous post and this script. (you misplaced one of the } )

Code: Select all

return
{
       on =
    {
        devices =
        {
            'Bathroom 2nd Floor PIR',
            'Bathroom 2nd Floor Door Sensor',
        },
    },
    logging =
    {
        level =  domoticz.LOG_ERROR,
        marker = 'WC',
    },

    execute = function(dz, device)
        local PIR = dz.devices('Bathroom 2nd Floor PIR')
        local door = dz.devices('Bathroom 2nd Floor Door Sensor')
        local light = dz.devices('Bathroom 2nd Floor Light')

        dz.log('Device ' .. device.name .. ' was changed to ' .. device.state, dz.LOG_FORCE)
        if device == PIR and device.active then
            light.switchOn().checkFirst()
            dz.log('Hey! I got Light', dz.LOG_FORCE)
        elseif PIR.state == 'Off' then
            dz.log('Hey! Stay Light On', dz.LOG_FORCE)
        elseif door.state == 'Open' and PIR.state == 'On' then
            dz.log('Hey! Light to be OFF', dz.LOG_FORCE)
            light.switchOff().afterSec(160)
        elseif door.state == 'Open' and PIR.state == 'Off' then
            dz.log('Hey! Light to be OFF', dz.LOG_FORCE)
            light.switchOff()
        else
            dz.log('Not definded!', dz.LOG_FORCE)
        end
    end
}

Re: Missing logs

Posted: Monday 07 December 2020 21:51
by iganin
Indeed. My bad. Thanks for the help!!!