Logging for a single script that runs every minute
Moderator: leecollings
-
- Posts: 67
- Joined: Saturday 17 June 2017 12:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Logging for a single script that runs every minute
Hi,
I have a script that is running every minute but is only really being executed once a day, this scripts needs to put something in the log but since it runs every minute it fills my log every minute with basic dzVents text. Here is what I tried / tested.
Domoticz settings : dzVents logging on 'Silent'
script settings option 1 : no logging enabled in script > result nothing in logging although in execution there is a domoticz.log line being executed
script settings option 2 : enable logging in scripts > result every minute log is written that script was started and finished, but there was no execution
2017-07-08 16:14:00.191 dzVents: Info: Sunset :: ------ Start internal script: dz-sunset:, trigger: every minute
2017-07-08 16:14:00.191 dzVents: Info: Sunset :: ------ Finished dz-sunset
Any suggestions how I can get the logging only being written when the execute part of the script is run and not logging every minute.
Thanks,
Ivo
I have a script that is running every minute but is only really being executed once a day, this scripts needs to put something in the log but since it runs every minute it fills my log every minute with basic dzVents text. Here is what I tried / tested.
Domoticz settings : dzVents logging on 'Silent'
script settings option 1 : no logging enabled in script > result nothing in logging although in execution there is a domoticz.log line being executed
script settings option 2 : enable logging in scripts > result every minute log is written that script was started and finished, but there was no execution
2017-07-08 16:14:00.191 dzVents: Info: Sunset :: ------ Start internal script: dz-sunset:, trigger: every minute
2017-07-08 16:14:00.191 dzVents: Info: Sunset :: ------ Finished dz-sunset
Any suggestions how I can get the logging only being written when the execute part of the script is run and not logging every minute.
Thanks,
Ivo
- K3rryBlue
- Posts: 77
- Joined: Tuesday 07 February 2017 22:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.10xx
- Location: Netherlands
- Contact:
Re: Logging for a single script that runs every minute
Add something like this to your LUA. Change the hour value to the hour you want to execute.
Please use search as this is available in many topics.
Please use search as this is available in many topics.
Code: Select all
time = os.date("*t")
if time.hour==13 and time.min<=01 then
//place your code
end
Domoticz V4.10717, RPi2 -> Linux raspberrypi 4.4.47-v7+ , RFXCOM - RFXtrx433 USB 433.92MHz ,RAZBERRY2 and OpenZWave USB Version: 1.4-2363-g1f10253-dirty
-
- Posts: 67
- Joined: Saturday 17 June 2017 12:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Logging for a single script that runs every minute
Sorry I am using dzVents and not lua, for example I want some lights to turn on 40 minutes before sunset. This forces me to use the timer to be set to every minute as the sunset changes every day and thus the moment this script needs to be executed.
This is basic of the script, no problem having it run every minute but only want my log to be written when it is really being executed and that is when the if statement is true
This is basic of the script, no problem having it run every minute but only want my log to be written when it is really being executed and that is when the if statement is true
- Spoiler: show
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Logging for a single script that runs every minute
Do I understand correctly that when log level is set to silent you indeed don't see anything in the logs (as intended)? Just wanna be sure there's not a bug there.
So, there are a couple of things you can do. You can create an active function or a timer function. I'd say a timer is more appropriate:
That should work (famous last words).
Lemme know if it does (or doesn't). It should now only do logging if the execute function is executed. Otherwise it should be silent.
Danny
So, there are a couple of things you can do. You can create an active function or a timer function. I'd say a timer is more appropriate:
Code: Select all
return {
active = true,
on = {
timer = {
function(d)
local myMin = d.time.min + d.time.hour *60
local myRest = d.time.sunsetInMinutes - myMin
return (myRest == 40)
end
},
},
execute = function(domoticz)
...
end
}
Lemme know if it does (or doesn't). It should now only do logging if the execute function is executed. Otherwise it should be silent.
Danny
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 67
- Joined: Saturday 17 June 2017 12:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Logging for a single script that runs every minute
Thanks Danny this is a great solution and an extra feature of the already nice dzVents solutions.Didn't look at it from that perspective. My scripts size decreased significantly when moving from lua to dzvents. So far I am happy user as almost all my scripts have moved over.
btw. when log level is set to silent I don't get anything in the logs, that is working fine.
Cheers,
Ivo
Oh yes, I tested it just now and it worked
btw. when log level is set to silent I don't get anything in the logs, that is working fine.
Cheers,
Ivo
Oh yes, I tested it just now and it worked
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Logging for a single script that runs every minute
Hey Snuiter (always want to say that sometime).
dzVents 2.2.0 now has a xxx minutes before sunset time rule (and after, and the same for sunrise). See the docs.
It's in Domoticz beta v3.8143 or higher.
Less code to maintain. Maybe you can try it.
dzVents 2.2.0 now has a xxx minutes before sunset time rule (and after, and the same for sunrise). See the docs.
It's in Domoticz beta v3.8143 or higher.
Less code to maintain. Maybe you can try it.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 67
- Joined: Saturday 17 June 2017 12:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Logging for a single script that runs every minute
Hi Danny,
thanks I already read it in your comments searching for 2.2.0 testers. Will test is once available.
Thanks for mentioning!
thanks I already read it in your comments searching for 2.2.0 testers. Will test is once available.
Thanks for mentioning!
- madpatrick
- Posts: 670
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Logging for a single script that runs every minute
Hi,
The question about reducing the logging reflects my question only my script (thanks to Waaren) is triggered by a PIR sensor
So every time you walk in the room, this gives a few lines in the log.
At the end of the day the log file growes and growes.....
This is a part of the script.
Is it possible to enable the script on a device and the switch "Alarm mode" ?
or disable the loglines (and not block all logging....)
This is what i;ve tried, but does not work
The question about reducing the logging reflects my question only my script (thanks to Waaren) is triggered by a PIR sensor
So every time you walk in the room, this gives a few lines in the log.
At the end of the day the log file growes and growes.....
Code: Select all
2020-10-28 19:50:12.741 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 31 (0x1f)
2020-10-28 19:50:12.771 Status: dzVents: Info: Handling events for: "PIR Sensor", value: "Off"
2020-10-28 19:50:12.834 Status: dzVents: Info: Handling events for: "PIR Sensor", value: "On"
Code: Select all
return
{
active = true,
on =
{
devices =
{
'Sensor - Achterdeur', -- deurcontact in de woonkamer
'Sensor - Garagedeur', -- deurcontact in de garage
'PIR Sensor', -- PIR Sensor
'Alarm mode',
},
},
logging =
{
level = domoticz.LOG_ERROR,
marker = scriptVar,
},
or disable the loglines (and not block all logging....)
This is what i;ve tried, but does not work
Code: Select all
devices =
{
Achterdeur, -- deurcontact in de woonkamer
Garagedeur, -- deurcontact in de garage
PIR, -- PIR Sensor
}
and
{
alarmMode == 'on',
}
,
},
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Logging for a single script that runs every minute
If you want to minimize your dzVents logging then set the dzVents logging in setup settings other to 'Errors only"madpatrick wrote: ↑Wednesday 28 October 2020 20:05 So every time you walk in the room, this gives a few lines in the log.
At the end of the day the log file growes and growes.....
and use below type of logging in your scripts
The domoticz loglevel can be set in /etc/init.d/domoticz.sh
You will find quite some examples on how to do that in this forum.
Code: Select all
local scriptVar = 'log issue'
return
{
active = true,
on =
{
devices =
{
'Sensor - Achterdeur', -- deurcontact in de woonkamer
'Sensor - Garagedeur', -- deurcontact in de garage
'PIR Sensor', -- PIR Sensor
'Alarm mode',
},
},
logging =
{
level = domoticz.LOG_ERROR,
marker = scriptVar,
},
execute = function(dz, item)
dz.log('You should now only see this line',dz.LOG_FORCE)
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: No registered users and 1 guest