Page 1 of 1

DzVentz time no leading zero's?

Posted: Tuesday 03 April 2018 23:41
by yfands
Version: 3.9174
Build Hash: ac7daa5b
Compile Date: 2018-04-03 12:59:46
dzVents Version: 2.4.2
Raspberry pi 3

Hai,

Today I wrote a little script in DzVents to let me know if there was a postal delivery.
(a mercury switch on an old remote doorbell attached to the postal box)

This works nice In combination with a Domoticz off switch so I can 'reset' the ''Postal' state to 'No'.
So far so good.

Next I wanted to know when the delivery was made so I added:

local Time = require('Time')
local currentTime = Time() -- current time
currentTime = currentTime.rawTime

but when I 'display' the variable currentTime with domoticz.notify, domoticz.email or domoticz.log there are no leading zeros.
for instance:

2018-04-03 23:05:14.178 Notification: Mailbox emptied: 23:5:14 uur clearly you can see on left the logtimestamp with and the log message 23:5:14 without a leading zero.

Is there a solution ?

Regards Frank

Re: DzVentz time no leading zero's?

Posted: Wednesday 04 April 2018 9:27
by yfands
So no fancy solution in Dzventz(?), I reverted back to the old school programming as solution.

local Time = require('Time')
local currentTime = Time() -- current time
local hours = currentTime .hour
local minutes = currentTime .minutes
local postalTime = string.format("%02d:%02d",currentTime .hour,currentTime .minutes)



Regards
Frank

Re: DzVentz time no leading zero's?

Posted: Wednesday 04 April 2018 10:28
by waaren
yfands wrote: Tuesday 03 April 2018 23:41
but when I 'display' the variable currentTime with domoticz.notify, domoticz.email or domoticz.log there are no leading zeros.

Is there a solution ?

Regards Frank
Solution / workaround :

Code: Select all

local Time = require('Time')
local now = Time() -- current time
currentTime = now.rawTime

domoticz.log(tostring(currentTime))

Re: DzVentz time no leading zero's?

Posted: Wednesday 04 April 2018 20:38
by dannybloe
Good catch. I fixed it for dzVents 2.4.4 so rawTime and rawDate have leading zeroes when necessary.

Re: DzVentz time no leading zero's?

Posted: Wednesday 04 April 2018 22:37
by yfands
dannybloe wrote: Wednesday 04 April 2018 20:38 Good catch. I fixed it for dzVents 2.4.4 so rawTime and rawDate have leading zeroes when necessary.
Hai dannybloe,

Ok thanks great, but 'have leading zeroes when necessary', do you mean there is gonne be a switch ? yes or no leading zero's if desired?

Regards
Frank

Re: DzVentz time no leading zero's?

Posted: Thursday 05 April 2018 7:06
by dannybloe
Only when below 10 of course.

Re: DzVentz time no leading zero's?

Posted: Thursday 05 April 2018 9:24
by yfands
dannybloe wrote: Thursday 05 April 2018 7:06 Only when below 10 of course.
:lol: yup thats the other necessity..

Thanks