Moderator: leecollings
dlube
Posts: 29 Joined: Tuesday 31 March 2020 19:29
Target OS: -
Domoticz version:
Location: France
Post
by dlube » Monday 01 June 2020 15:28
Hi
If someone can help me
I did this
Code: Select all
local Time = require('Time')
local localTime = Time()
print(localTime.utcTime.hour)
and I got this
Code: Select all
2020-06-01 15:24:01.179 Error: dzVents: Error: (3.0.2) ...e/pi/domoticz/scripts/dzVents/generated_scripts/Test.lua:12: attempt to index a nil value (field 'utcTime')
What is wrong in my code?
Raspbian Buster on Raspberry pi 3 B+ Domoticz Version: 2023.2 (build 15474)
Toulon7559
Posts: 843 Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:
Post
by Toulon7559 » Monday 01 June 2020 15:52
Another way to get for a lua-script the components of the utc-timestring.
Timestring (at the end of the script-segment) is a compilation of components as required for
some uploads:
therefore insertion of character 20 as required for complete year-identification, and of separators %20 and %3A.
Code: Select all
-- Line xx, Get Time-related data in UTC
utc_dtime = os.date("!%m-%d-%y %H:%M:%S",os.time())
month = string.sub(utc_dtime, 1, 2)
day = string.sub(utc_dtime, 4, 5)
year = "20" .. string.sub(utc_dtime, 7, 8)
hour = string.sub(utc_dtime, 10, 11); hour_n = tonumber(hour)
minutes = string.sub(utc_dtime, 13, 14); minutes_n = tonumber(minutes)
seconds = string.sub(utc_dtime, 16, 17)
timestring = year .. "-" .. month .. "-" .. day .. "%20" .. hour .. "%3A" .. minutes .. "%3A" .. seconds
Last edited by
Toulon7559 on Tuesday 09 June 2020 22:44, edited 2 times in total.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A+ +RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
waaren
Posts: 6028 Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:
Post
by waaren » Monday 01 June 2020 16:00
dlube wrote: ↑ Monday 01 June 2020 15:28
If someone can help me
Does this help ?
Code: Select all
local utc = os.date("!*t")
print('UTC hour is ' .. utc.hour)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki
dlube
Posts: 29 Joined: Tuesday 31 March 2020 19:29
Target OS: -
Domoticz version:
Location: France
Post
by dlube » Monday 01 June 2020 17:26
I knew this way.
Thank you
However I would like to use the dzVents
It seams that the utcTime property of the Time object does not exist.
Is it a bug or not?
Raspbian Buster on Raspberry pi 3 B+ Domoticz Version: 2023.2 (build 15474)
waaren
Posts: 6028 Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:
Post
by waaren » Monday 01 June 2020 17:43
dlube wrote: ↑ Monday 01 June 2020 17:26
It seams that the utcTime property of the Time object does not exist.
Is it a bug or not?
No it is magic..
The tables utcSystemTime and utcTime only exist in dzVents time objects where isUTC is true .
Below example
Code: Select all
return
{
on =
{
devices =
{
'timeTrigger', -- or any other device
},
},
execute = function(dz)
isUTC = true
utcTime = dz.time.makeTime(dz.time.raw,isUTC)
dz.utils.dumpTable(utcTime)
end
}
give
Code: Select all
2020-06-01 17:35:53.728 Status: dzVents: > dayAbbrOfWeek: mon
2020-06-01 17:35:53.728 Status: dzVents: > utcSystemTime:
2020-06-01 17:35:53.728 Status: dzVents: > month: 6
2020-06-01 17:35:53.728 Status: dzVents: > sec: 53
2020-06-01 17:35:53.728 Status: dzVents: > year: 2020
2020-06-01 17:35:53.728 Status: dzVents: > yday: 153
2020-06-01 17:35:53.728 Status: dzVents: > wday: 2
2020-06-01 17:35:53.728 Status: dzVents: > min: 35
2020-06-01 17:35:53.728 Status: dzVents: > isdst: false
2020-06-01 17:35:53.728 Status: dzVents: > day: 1
2020-06-01 17:35:53.728 Status: dzVents: > hour: 15
2020-06-01 17:35:53.728 Status: dzVents: > dDate: 1591025753
2020-06-01 17:35:53.728 Status: dzVents: > time: 19:35
2020-06-01 17:35:53.728 Status: dzVents: > min: 35
2020-06-01 17:35:53.728 Status: dzVents: > milliSeconds: 685
2020-06-01 17:35:53.728 Status: dzVents: > ruleIsBeforeSunrise()
2020-06-01 17:35:53.728 Status: dzVents: > ruleIsOnDay()
2020-06-01 17:35:53.728 Status: dzVents: > addHours()
2020-06-01 17:35:53.729 Status: dzVents: > ruleIsAtDayTime()
2020-06-01 17:35:53.729 Status: dzVents: > addSeconds()
2020-06-01 17:35:53.729 Status: dzVents: > current:
2020-06-01 17:35:53.729 Status: dzVents: > month: 6
2020-06-01 17:35:53.729 Status: dzVents: > sec: 53
2020-06-01 17:35:53.729 Status: dzVents: > year: 2020
2020-06-01 17:35:53.729 Status: dzVents: > yday: 153
2020-06-01 17:35:53.729 Status: dzVents: > wday: 2
2020-06-01 17:35:53.729 Status: dzVents: > min: 35
2020-06-01 17:35:53.729 Status: dzVents: > isdst: true
2020-06-01 17:35:53.729 Status: dzVents: > day: 1
2020-06-01 17:35:53.729 Status: dzVents: > hour: 17
2020-06-01 17:35:53.729 Status: dzVents: > ruleIsAtSunset()
2020-06-01 17:35:53.729 Status: dzVents: > raw: 2020-6-1 17:35:53.685
2020-06-01 17:35:53.729 Status: dzVents: > ruleIsInWeek()
2020-06-01 17:35:53.729 Status: dzVents: > ruleIsAtCivilTwilightEnd()
2020-06-01 17:35:53.729 Status: dzVents: > hour: 19
2020-06-01 17:35:53.729 Status: dzVents: > dayName: Monday
2020-06-01 17:35:53.729 Status: dzVents: > ruleIsAfterCivilTwilightStart()
2020-06-01 17:35:53.729 Status: dzVents: > ruleMatchesBetweenRange()
2020-06-01 17:35:53.729 Status: dzVents: > isUTC: true
2020-06-01 17:35:53.729 Status: dzVents: > isToday: true
2020-06-01 17:35:53.729 Status: dzVents: > secondsSinceMidnight: 70553
2020-06-01 17:35:53.729 Status: dzVents: > compare()
2020-06-01 17:35:53.729 Status: dzVents: > ruleMatchesTime()
2020-06-01 17:35:53.729 Status: dzVents: > getISO()
2020-06-01 17:35:53.729 Status: dzVents: > sec: 53
2020-06-01 17:35:53.729 Status: dzVents: > rawTime: 19:35:53
2020-06-01 17:35:53.729 Status: dzVents: > monthName: June
2020-06-01 17:35:53.729 Status: dzVents: > addDays()
2020-06-01 17:35:53.729 Status: dzVents: > yday: 153
2020-06-01 17:35:53.729 Status: dzVents: > milliseconds: 685
2020-06-01 17:35:53.729 Status: dzVents: > wday: 2
2020-06-01 17:35:53.729 Status: dzVents: > minutesSinceMidnight: 1175
2020-06-01 17:35:53.729 Status: dzVents: > minutes: 35
2020-06-01 17:35:53.729 Status: dzVents: > ruleIsAtSunrise()
2020-06-01 17:35:53.729 Status: dzVents: > ruleIsBeforeCivilTwilightEnd()
2020-06-01 17:35:53.729 Status: dzVents: > secondsAgo: -7200
2020-06-01 17:35:53.729 Status: dzVents: > rawDateTime: 2020-06-01 19:35:53
2020-06-01 17:35:53.729 Status: dzVents: > hoursAgo: -2
2020-06-01 17:35:53.729 Status: dzVents: > utcTime:
2020-06-01 17:35:53.729 Status: dzVents: > month: 6
2020-06-01 17:35:53.729 Status: dzVents: > sec: 53
2020-06-01 17:35:53.729 Status: dzVents: > seconds: 53
2020-06-01 17:35:53.729 Status: dzVents: > year: 2020
2020-06-01 17:35:53.729 Status: dzVents: > yday: 153
2020-06-01 17:35:53.730 Status: dzVents: > wday: 2
2020-06-01 17:35:53.730 Status: dzVents: > minutes: 35
2020-06-01 17:35:53.730 Status: dzVents: > min: 35
2020-06-01 17:35:53.730 Status: dzVents: > isdst: true
2020-06-01 17:35:53.730 Status: dzVents: > day: 1
2020-06-01 17:35:53.730 Status: dzVents: > hour: 17
2020-06-01 17:35:53.730 Status: dzVents: > matchesRule()
2020-06-01 17:35:53.730 Status: dzVents: > ruleIsAtCivilNightTime()
2020-06-01 17:35:53.730 Status: dzVents: > day: 1
2020-06-01 17:35:53.730 Status: dzVents: > ruleMatchesHourSpecification()
2020-06-01 17:35:53.730 Status: dzVents: > ruleIsAtNight()
2020-06-01 17:35:53.730 Status: dzVents: > ruleMatchesMinuteSpecification()
2020-06-01 17:35:53.730 Status: dzVents: > month: 6
2020-06-01 17:35:53.730 Status: dzVents: > seconds: 53
2020-06-01 17:35:53.730 Status: dzVents: > ruleIsAtCivilTwilightStart()
2020-06-01 17:35:53.730 Status: dzVents: > daysAgo: 0
2020-06-01 17:35:53.730 Status: dzVents: > ruleIsBeforeSunset()
2020-06-01 17:35:53.730 Status: dzVents: > msAgo: -7200000
2020-06-01 17:35:53.730 Status: dzVents: > ruleIsBeforeCivilTwilightStart()
2020-06-01 17:35:53.730 Status: dzVents: > utils:
2020-06-01 17:35:53.730 Status: dzVents: > fromBase64()
2020-06-01 17:35:53.730 Status: dzVents: > urlDecode()
2020-06-01 17:35:53.730 Status: dzVents: > isXML()
2020-06-01 17:35:53.730 Status: dzVents: > stringToSeconds()
2020-06-01 17:35:53.730 Status: dzVents: > toXML()
2020-06-01 17:35:53.730 Status: dzVents: > LOG_ERROR: 1
2020-06-01 17:35:53.730 Status: dzVents: > osExecute()
2020-06-01 17:35:53.730 Status: dzVents: > rgbToHSB()
2020-06-01 17:35:53.730 Status: dzVents: > LOG_FORCE: 0.5
2020-06-01 17:35:53.730 Status: dzVents: > LOG_INFO: 3
2020-06-01 17:35:53.730 Status: dzVents: > sceneExists()
2020-06-01 17:35:53.730 Status: dzVents: > setLogMarker()
2020-06-01 17:35:53.730 Status: dzVents: > DZVERSION: 3.0.8
2020-06-01 17:35:53.730 Status: dzVents: > round()
2020-06-01 17:35:53.730 Status: dzVents: > numDecimals()
2020-06-01 17:35:53.730 Status: dzVents: > hsbToRGB()
2020-06-01 17:35:53.730 Status: dzVents: > dumpSelection()
2020-06-01 17:35:53.730 Status: dzVents: > deviceExists()
2020-06-01 17:35:53.730 Status: dzVents: > fromXML()
2020-06-01 17:35:53.730 Status: dzVents: > stringSplit()
2020-06-01 17:35:53.730 Status: dzVents: > isJSON()
2020-06-01 17:35:53.730 Status: dzVents: > fromJSON()
2020-06-01 17:35:53.730 Status: dzVents: > variableExists()
2020-06-01 17:35:53.730 Status: dzVents: > leadingZeros()
2020-06-01 17:35:53.730 Status: dzVents: > toJSON()
2020-06-01 17:35:53.730 Status: dzVents: > centerPad()
2020-06-01 17:35:53.730 Status: dzVents: > urlEncode()
2020-06-01 17:35:53.730 Status: dzVents: > toCelsius()
2020-06-01 17:35:53.730 Status: dzVents: > hardwareExists()
2020-06-01 17:35:53.730 Status: dzVents: > print()
2020-06-01 17:35:53.730 Status: dzVents: > groupExists()
2020-06-01 17:35:53.731 Status: dzVents: > dumpTable()
2020-06-01 17:35:53.731 Status: dzVents: > rightPad()
2020-06-01 17:35:53.731 Status: dzVents: > log()
2020-06-01 17:35:53.731 Status: dzVents: > LOG_DEBUG: 4
2020-06-01 17:35:53.731 Status: dzVents: > toBase64()
2020-06-01 17:35:53.731 Status: dzVents: > cameraExists()
2020-06-01 17:35:53.731 Status: dzVents: > LOG_MODULE_EXEC_INFO: 2
2020-06-01 17:35:53.731 Status: dzVents: > inTable()
2020-06-01 17:35:53.731 Status: dzVents: > leftPad()
2020-06-01 17:35:53.731 Status: dzVents: > fileExists()
2020-06-01 17:35:53.731 Status: dzVents: > ruleIsAfterSunset()
2020-06-01 17:35:53.731 Status: dzVents: > isdst: true
2020-06-01 17:35:53.731 Status: dzVents: > rawDate: 2020-06-01
2020-06-01 17:35:53.731 Status: dzVents: > year: 2020
2020-06-01 17:35:53.731 Status: dzVents: > millisecondsAgo: -7200000
2020-06-01 17:35:53.731 Status: dzVents: > ruleIsOnDate()
2020-06-01 17:35:53.731 Status: dzVents: > monthAbbrName: jun
2020-06-01 17:35:53.731 Status: dzVents: > week: 23
2020-06-01 17:35:53.731 Status: dzVents: > ruleIsAtCivilDayTime()
2020-06-01 17:35:53.731 Status: dzVents: > ruleIsAfterSunrise()
2020-06-01 17:35:53.731 Status: dzVents: > ruleIsAfterCivilTwilightEnd()
2020-06-01 17:35:53.731 Status: dzVents: > minutesAgo: -120
2020-06-01 17:35:53.731 Status: dzVents: > ruleMatchesTimeRange()
2020-06-01 17:35:53.731 Status: dzVents: > makeTime()
2020-06-01 17:35:53.731 Status: dzVents: > addMinutes()
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki
waaren
Posts: 6028 Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:
Post
by waaren » Monday 01 June 2020 17:44
dlube wrote: ↑ Monday 01 June 2020 17:26
However I would like to use the dzVents
The example is dzVents (which is 100% Lua)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki
dlube
Posts: 29 Joined: Tuesday 31 March 2020 19:29
Target OS: -
Domoticz version:
Location: France
Post
by dlube » Monday 01 June 2020 18:30
I thought that the property gave you the UTC time from the local time.
As you know that it is an UTC time I do not understand the aim of this property.
Hour, minutes,etc... are already available in the time property hour, minutes, etc
It should be a good function to get the UTC time from the local
Thank you all
Raspbian Buster on Raspberry pi 3 B+ Domoticz Version: 2023.2 (build 15474)
Users browsing this forum: No registered users and 1 guest