there's a way with dzevents to get that information?
Thanx in advance
Fabrizio
Moderator: leecollings
Not directly but a relative simple method, using persistent data, to achieve thisacaonweb wrote: Tuesday 04 June 2019 13:57 I've noticed that next to the temperature sensor panel, there is an arrow that indicate probably the temperature is rising up or down
there's a way with dzVents to get that information?
Code: Select all
local sensors = {433, 530, 591, 842, 1639} -- lest of temperature sensors that you want to watch for trend
return
{
on = { devices = sensors },
logging = {level = domoticz.LOG_ERROR, marker = 'Temperature ' },
data = { sensors = { initial = {}}},
execute = function(dz,item)
lastMeasuredTemperature = dz.data.sensors[item.id]
newTemperature = dz.utils.round(item.temperature,2)
local function message(trend)
dz.log ('trend for ' .. item.name .. ' is ' .. (trend or 'stable'),dz.LOG_FORCE)
end
if not lastMeasuredTemperature then message()
elseif lastMeasuredTemperature == newTemperature then message()
elseif lastMeasuredTemperature < newTemperature then message('up')
else message('down')
end
dz.data.sensors[item.id] = newTemperature
end
}The Lua engine in domoticz is driving the IO with the persistent data and from what I see it's doing that quite efficient. I never noticed any delay in the dzVents scripts as a result of using persistent data. One thing to be be aware of is the wearing of the SD card over time.acaonweb wrote: Friday 07 June 2019 9:22 i'm just worried about use persistent data for the rpi3's perfomance![]()
Sure. Have a look at this topic of the dzVents wikiacaonweb wrote: Friday 07 June 2019 9:46 Another question:
it's possible to have functions available for every scripts? A sort of "libraries of common functions"?
im really newbie.. how do that?waaren wrote: Friday 07 June 2019 9:55The Lua engine in domoticz is driving the IO with the persistent data and from what I see it's doing that quite efficient. I never noticed any delay in the dzVents scripts as a result of using persistent data. One thing to be be aware of is the wearing of the SD card over time.acaonweb wrote: Friday 07 June 2019 9:22 i'm just worried about use persistent data for the rpi3's perfomance![]()
Always ensure you have a recent clone of the card and also make frequent backups of your database and external scripts / data.
One of the reasons why I do my IO to my NAS using berryboot![]()
Do if i write a script called global_data with the internal script editor, i can put functions in the same way ad a local function calling them with .helpers?waaren wrote: Friday 07 June 2019 9:57Sure. Have a look at this topic of the dzVents wikiacaonweb wrote: Friday 07 June 2019 9:46 Another question:
it's possible to have functions available for every scripts? A sort of "libraries of common functions"?
Yes. if you have a function in the helpers section of global_data.lua you call it with dz.helpers.<name of function>acaonweb wrote: Friday 07 June 2019 10:15Do if i write a script called global_data with the internal script editor, i can put functions in the same way ad a local function calling them with .helpers?waaren wrote: Friday 07 June 2019 9:57Sure. Have a look at this topic of the dzVents wikiacaonweb wrote: Friday 07 June 2019 9:46 Another question:
it's possible to have functions available for every scripts? A sort of "libraries of common functions"?
Code: Select all
-- global_data.lua
return
{
data =
{
hostname = { initial = "notset" },
},
helpers =
{
hostname = function(dz)
if dz.globalData.hostname ~= "notset" then return dz.globalData.hostname end
local fileHandle = assert(io.popen("hostname", 'r'))
local commandOutput = assert(fileHandle:read('*a'))
fileHandle:close()
dz.globalData.hostname = commandOutput
return commandOutput
end,
myYouless = function(dz)
return dz.devices('Youless').powerYield
end,
},
}Code: Select all
dz.log(dz.helpers.hostname(dz))Users browsing this forum: No registered users and 1 guest