Skip to content

Commit f9c900f

Browse files
committed
dzVents 2.5.0 ( to be used with Lua version 5.3 or newer )
modified: History.txt modified: dzVents/documentation/README.md modified: dzVents/documentation/README.wiki modified: dzVents/documentation/history.md modified: dzVents/runtime/Camera.lua modified: dzVents/runtime/Device.lua modified: dzVents/runtime/Time.lua modified: dzVents/runtime/Utils.lua modified: dzVents/runtime/Variable.lua modified: dzVents/runtime/device-adapters/evohome_device.lua modified: dzVents/runtime/device-adapters/generic_device.lua modified: dzVents/runtime/device-adapters/rgbw_device.lua modified: dzVents/runtime/device-adapters/switch_device.lua modified: dzVents/runtime/integration-tests/README.md modified: dzVents/runtime/integration-tests/scriptTestRename.lua modified: dzVents/runtime/integration-tests/stage2.lua modified: dzVents/runtime/misc/testdzVents.sh modified: dzVents/runtime/tests/README.md modified: dzVents/runtime/tests/testDomoticz.lua modified: main/EventSystem.cpp modified: main/dzVents.cpp
1 parent 4679664 commit f9c900f

21 files changed

+638
-476
lines changed

History.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Version 4.xxxxx (xxx 2019)
2222
- Fixed: notification, Telegram error when odd number of underscores in text
2323
- Fixed: API, allow variabletype to be entered as text or integer in adduservariable and updateuservariable (#3320)
2424
- Updated: OpenZWave version 1.6
25-
- Updated: dzVents (version 2.4.29, See dzVents/documentation/history.md)
25+
- Updated: dzVents (version 2.5.0 for Lua 5.3) See dzVents/documentation/history.md)
2626

2727
Version 4.10717 (May 9th 2019)
2828
- Fixed: dzVents, Allowing no error message for HTTP calls (#3191)

dzVents/documentation/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,8 @@ In 2.x it is no longer needed to make timed json calls to Domoticz to get extra
20712071
On the other hand, you have to make sure that dzVents can access the json without the need for a password because some commands are issued using json calls by dzVents. Make sure that in Domoticz settings under **Local Networks (no username/password)** you add `127.0.0.1` and you're good to go.
20722072

20732073
# History
2074+
##[2.5.0]
2075+
- Prepared for Lua 5.3
20742076

20752077
##[2.4.29]
20762078
- Add error message including affected module when module got corrupted on disk.

dzVents/documentation/README.wiki

Lines changed: 402 additions & 291 deletions
Large diffs are not rendered by default.

dzVents/documentation/history.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[2.5.0]
2+
- Prepared for Lua 5.3
3+
14
[2.4.29]
25
- Add error message including affected module when module got corrupted on disk.
36
- Add setLevel method for switchTypes.

dzVents/runtime/Camera.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ local function Camera(domoticz, data, dummyLogger)
1414

1515
self['name'] = data.name
1616
self['id'] = data.id -- actually, this is the idx
17-
self['idx'] = data.id -- for completeness
17+
self['idx'] = self.id -- for completeness
1818
self['baseType'] = data.baseType
1919

2020
if (_G.TESTMODE) then

dzVents/runtime/Device.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ local function Device(domoticz, data, dummyLogger)
99
local state
1010
local adapterManager = Adapters(dummyLogger)
1111

12-
1312
function self.update(nValue, sValue, protected)
1413
local params = {
1514
idx = self.id,
@@ -27,7 +26,7 @@ local function Device(domoticz, data, dummyLogger)
2726

2827
self['name'] = data.name
2928
self['id'] = data.id -- actually, this is the idx
30-
self['idx'] = data.id -- for completeness
29+
self['idx'] = self.id -- for completeness
3130
self['_data'] = data
3231
self['baseType'] = data.baseType
3332

dzVents/runtime/Time.lua

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,14 @@ local function Time(sDate, isUTC, _testMS)
187187
end
188188

189189
if sDate == nil or sDate == '' then
190-
sDate = makesDate()
190+
sDate = makesDate()
191191
end
192192

193193
local y, mon, d, h, min, s = parseDate(sDate)
194194
if not(y and mon and d and h and min and s) then
195195
sDate = makesDate()
196196
y, mon, d, h, min, s = parseDate(sDate)
197-
utils.log('sDate was invalid. Reset to ' .. sDate , utils.LOG_ERROR)
197+
utils.log('sDate was invalid. Reset to ' .. sDate , utils.LOG_ERROR)
198198
end
199199

200200
-- extract s and ms
@@ -252,10 +252,10 @@ local function Time(sDate, isUTC, _testMS)
252252
now.month==time.month and
253253
now.day==time.day)
254254

255-
self['msAgo'] = msDiff
256-
self['millisecondsAgo'] = msDiff
255+
self['msAgo'] = math.floor(msDiff)
256+
self['millisecondsAgo'] = self.msAgo
257257
self['minutesAgo'] = minDiff
258-
self['secondsAgo'] = secDiff
258+
self['secondsAgo'] = math.floor(secDiff)
259259
self['hoursAgo'] = hourDiff
260260
self['daysAgo'] = dayDiff
261261

@@ -285,12 +285,12 @@ local function Time(sDate, isUTC, _testMS)
285285
return {
286286
mins = minDiff,
287287
hours = hourDiff,
288-
secs = secDiff,
289-
seconds = secDiff,
288+
secs = math.floor(secDiff),
289+
seconds = math.floor(secDiff),
290290
minutes = minDiff,
291291
days = dayDiff,
292-
ms = msDiff,
293-
milliseconds = msDiff,
292+
ms = math.floor(msDiff),
293+
milliseconds = math.floor(msDiff),
294294
compare = cmp -- 0 == equal, -1==(t earlier than self), 1=(t later than self)
295295
}
296296
else

dzVents/runtime/Utils.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local self = {
88
LOG_MODULE_EXEC_INFO = 2,
99
LOG_INFO = 3,
1010
LOG_DEBUG = 4,
11-
DZVERSION = '2.4.29',
11+
DZVERSION = '2.5.0', -- for Lua 5.3
1212
}
1313

1414
function self.rightPad(str, len, char)
@@ -69,7 +69,8 @@ function self.inTable(searchTable, element)
6969
end
7070

7171
function self.round(x, n)
72-
n = math.pow(10, n or 0)
72+
-- n = math.pow(10, n or 0)
73+
n = 10^(n or 0)
7374
x = x * n
7475
if x >= 0 then
7576
x = math.floor(x + 0.5)

dzVents/runtime/Variable.lua

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ local Time = require('Time')
22
local TimedCommand = require('TimedCommand')
33

44
local function Variable(domoticz, data)
5-
65
local self = {
76
['value'] = data.data.value,
87
['name'] = data.name,
@@ -43,11 +42,15 @@ local function Variable(domoticz, data)
4342
self['time'] = Time(time)
4443
end
4544

46-
4745
-- send an update to domoticz
4846
function self.set(value)
49-
if (value == nil) then value = '' end
50-
47+
48+
if self.type == 'integer' then
49+
value = math.floor(value)
50+
elseif value == nil then
51+
value = ''
52+
end
53+
5154
-- return TimedCommand(domoticz, 'Variable:' .. data.name, tostring(value), 'variable')
5255
return TimedCommand(domoticz, 'Variable', {
5356
idx = data.id,
@@ -64,11 +67,15 @@ local function Variable(domoticz, data)
6467
end
6568

6669
function self.rename(newName)
70+
local newValue = domoticz.utils.urlEncode(self.value)
71+
if self.type == 'integer' then
72+
newValue = math.floor(self.value)
73+
end
6774
local url = domoticz.settings['Domoticz url'] .. '/json.htm?type=command&param=updateuservariable' ..
6875
'&idx=' .. data.id ..
6976
'&vname=' .. domoticz.utils.urlEncode(newName) ..
7077
'&vtype=' .. self.type ..
71-
'&vvalue=' .. domoticz.utils.urlEncode(self.value)
78+
'&vvalue=' .. newValue
7279
domoticz.openURL(url)
7380
end
7481

dzVents/runtime/device-adapters/evohome_device.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ return {
4343
"&used=true"
4444
return domoticz.openURL(url)
4545
end
46-
elseif device.deviceSubType == "Relay" then
47-
if device._state == "On" then
48-
device.state = "On"
49-
device.active = true
50-
else
51-
device.state = "Off"
52-
device.active = false
53-
end
46+
elseif device.deviceSubType == "Relay" then
47+
if device._state == "On" then
48+
device.state = "On"
49+
device.active = true
50+
else
51+
device.state = "Off"
52+
device.active = false
53+
end
5454
else
5555
device.state = device.rawData[2]
5656
device.setPoint = tonumber(device.rawData[1] or 0)
@@ -84,8 +84,8 @@ return {
8484
return epoch >= now.dDate and tmISO
8585
end
8686

87-
if type(tm) == 'string' and tm:find(iso8601Pattern) then return inFuture(tm) end -- Something like '2016-04-29T06:32:58Z'
88-
if type(tm) == 'table' and tm.getISO then return inFuture(tm.getISO()) end -- a dzVents time object
87+
if type(tm) == 'string' and tm:find(iso8601Pattern) then return inFuture(tm) end -- Something like '2016-04-29T06:32:58Z'
88+
if type(tm) == 'table' and tm.getISO then return inFuture(tm.getISO()) end -- a dzVents time object
8989
if type(tm) == 'table' and tm.day then return inFuture(os.date(iso8601Format,os.time(tm))) end -- a standard time object
9090
if type(tm) == 'number' and tm > now.dDate then return inFuture(os.date(iso8601Format,tm)) end -- seconds since epoch
9191
if type(tm) == 'number' and tm > 0 and tm < ( 365 * 24 * 60 ) then return inFuture(os.date(iso8601Format,now.dDate + ( tm * 60 ))) end -- seconds since epoch + tm
@@ -99,7 +99,7 @@ return {
9999
local res = type(value) == 'string' and value == mode
100100
if res then return res end
101101
end
102-
return mode == 'Busted' or false
102+
return mode == 'Busted' or false
103103
end
104104

105105
local function binary(num, default)
@@ -108,14 +108,14 @@ return {
108108

109109
if isValid( tostring(mode) ) then -- is it in the list of valid modes ?
110110
local dParm = dParm and checkTimeAndReturnISO(dParm) -- if there is a dParm then check if valid and make a valid ISO date
111-
dParm = ( dParm and '&until=' .. dParm ) or ''
112-
local action = ( action and '&action=' .. binary(action, 1) ) or '&action=1'
111+
dParm = ( dParm and '&until=' .. dParm ) or ''
112+
local action = ( action and '&action=' .. binary(action, 1) ) or '&action=1'
113113
local ooc = ( ooc and '&ooc=' .. binary(ooc, 0) ) or '&ooc=0'
114-
114+
115115
local url = domoticz.settings['Domoticz url'] ..
116116
'/json.htm?type=command&param=switchmodal&idx=' .. device.id ..
117117
"&status=" .. mode ..
118-
dParm ..
118+
dParm ..
119119
action ..
120120
ooc
121121
return domoticz.openURL(url)

0 commit comments

Comments
 (0)