Pjedr wrote: ↑Thursday 30 July 2020 12:49
In the domoticz.utils.round I mis the option to use negative decimals as a way to round on the left side of the indented point.
I like the idea. What is your use cases in domoticz?
When I test the new function with this script
Code: Select all
return
{
on =
{
devices =
{
'roundTrigger',
},
},
logging =
{
level = domoticz.LOG_DEBUG, -
marker = 'round Trigger',
},
execute = function(dz)
dz.log('------------------------')
dz.log('12.23 : round = >> ' .. dz.utils.round(12.23) ..', newRound = >> ' .. dz.utils.nRound(12.23) ,dz.LOG_DEBUG)
dz.log('-12.23 : round = >> ' .. dz.utils.round(-12.23) ..', newRound = >> ' .. dz.utils.nRound(-12,23) ,dz.LOG_DEBUG)
dz.log('------------------------')
dz.log('12.23,1 : round = >> ' .. dz.utils.round(12.23,1) ..', newRound = >> ' .. dz.utils.nRound(12.23,1) ,dz.LOG_DEBUG)
dz.log('-12.23,1 : round = >> ' .. dz.utils.round(-12.23,1) ..', newRound = >> ' .. dz.utils.nRound(-12,23,1) ,dz.LOG_DEBUG)
dz.log('------------------------')
dz.log('12.03,1 : round = >> ' .. dz.utils.round(12.03,1) ..', newRound = >> ' .. dz.utils.nRound(12.03,1) ,dz.LOG_DEBUG)
dz.log('-12.03,1 : round = >> ' .. dz.utils.round(-12.03,1) ..', newRound = >> ' .. dz.utils.nRound(-12,03,1) ,dz.LOG_DEBUG)
dz.log('------------------------')
dz.log('1223.03,-1 : round = >> ' .. dz.utils.round(1223.03,-1) ..', newRound = >> ' .. dz.utils.nRound(1223.03,-1) ,dz.LOG_DEBUG)
dz.log('-1223.03,-1 : round = >> ' .. dz.utils.round(-1223.03,-1) ..', newRound = >> ' .. dz.utils.nRound(-1223,03,-1) ,dz.LOG_DEBUG)
end
}
I get
Code: Select all
2020-07-30 13:44:16.192 Status: dzVents: Info: round Trigger: ------------------------
2020-07-30 13:44:16.192 Status: dzVents: Debug: round Trigger: 12.23 : round = >> 12, newRound = >> 12 OK
2020-07-30 13:44:16.192 Status: dzVents: Debug: round Trigger: -12.23 : round = >> -12, newRound = >> -12 OK
2020-07-30 13:44:16.192 Status: dzVents: Info: round Trigger: ------------------------
2020-07-30 13:44:16.192 Status: dzVents: Debug: round Trigger: 12.23,1 : round = >> 12.2, newRound = >> 12.2 OK
2020-07-30 13:44:16.192 Status: dzVents: Debug: round Trigger: -12.23,1 : round = >> -12.2, newRound = >> -12 NOK
2020-07-30 13:44:16.192 Status: dzVents: Info: round Trigger: ------------------------
2020-07-30 13:44:16.192 Status: dzVents: Debug: round Trigger: 12.03,1 : round = >> 12.0, newRound = >> 12 OK (converted from float to int)
2020-07-30 13:44:16.192 Status: dzVents: Debug: round Trigger: -12.03,1 : round = >> -12.0, newRound = >> -12 OK (converted from float to int)
2020-07-30 13:44:16.192 Status: dzVents: Info: round Trigger: ------------------------
2020-07-30 13:44:16.192 Status: dzVents: Debug: round Trigger: 1223.03,-1 : round = >> 1223, newRound = >> 1220 OK
2020-07-30 13:44:16.192 Status: dzVents: Debug: round Trigger: -1223.03,-1 : round = >> -1223, newRound = >> -1223 NOK
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki