DzVentz time no leading zero's?

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

Moderator: leecollings

Post Reply
yfands
Posts: 67
Joined: Monday 04 July 2016 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version: latest B
Location: Netherlands
Contact:

DzVentz time no leading zero's?

Post 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
yfands
Posts: 67
Joined: Monday 04 July 2016 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version: latest B
Location: Netherlands
Contact:

Re: DzVentz time no leading zero's?

Post 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
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: DzVentz time no leading zero's?

Post 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))
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: DzVentz time no leading zero's?

Post by dannybloe »

Good catch. I fixed it for dzVents 2.4.4 so rawTime and rawDate have leading zeroes when necessary.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
yfands
Posts: 67
Joined: Monday 04 July 2016 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version: latest B
Location: Netherlands
Contact:

Re: DzVentz time no leading zero's?

Post 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
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: DzVentz time no leading zero's?

Post by dannybloe »

Only when below 10 of course.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
yfands
Posts: 67
Joined: Monday 04 July 2016 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version: latest B
Location: Netherlands
Contact:

Re: DzVentz time no leading zero's?

Post by yfands »

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

Thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest