Page 1 of 1
Temperature sensor
Posted: Tuesday 04 June 2019 13:57
by acaonweb
Hi, i've noticed for the first time (my fault

) that next to the temperature sensor panel, there is an arrow that indicate probably the temperature is rising up or down

- Cattura.PNG (10.12 KiB) Viewed 3691 times
there's a way with dzevents to get that information?
Thanx in advance
Fabrizio
Re: Temperature sensor
Posted: Tuesday 04 June 2019 14:53
by waaren
acaonweb 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?
Not directly but a relative simple method, using persistent data, to achieve this
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
}
Re: Temperature sensor
Posted: Friday 07 June 2019 9:22
by acaonweb
thanx, your script are so useful because they make me learn lua and dzevents so good.
i hoped to get this data directly, but the script is very simple... i'm just worried about use persistent data for the rpi3's perfomance

Re: Temperature sensor
Posted: Friday 07 June 2019 9:46
by acaonweb
Another question:
it's possible to have functions available for every scripts? A sort of "libraries of common functions"?
Re: Temperature sensor
Posted: Friday 07 June 2019 9:55
by waaren
acaonweb wrote: Friday 07 June 2019 9:22
i'm just worried about use persistent data for the rpi3's perfomance
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.
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

Re: Temperature sensor
Posted: Friday 07 June 2019 9:57
by waaren
acaonweb 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"?
Sure. Have a look at
this topic of the dzVents wiki
Re: Temperature sensor
Posted: Friday 07 June 2019 10:09
by acaonweb
waaren wrote: Friday 07 June 2019 9:55
acaonweb wrote: Friday 07 June 2019 9:22
i'm just worried about use persistent data for the rpi3's perfomance
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.
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
im really newbie.. how do that?
Re: Temperature sensor
Posted: Friday 07 June 2019 10:15
by acaonweb
waaren wrote: Friday 07 June 2019 9:57
acaonweb 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"?
Sure. Have a look at
this topic of the dzVents wiki
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?
Re: Temperature sensor [Solved]
Posted: Friday 07 June 2019 10:36
by waaren
acaonweb wrote: Friday 07 June 2019 10:09
waaren wrote: Friday 07 June 2019 9:55
acaonweb wrote: Friday 07 June 2019 9:22
i'm just worried about use persistent data for the rpi3's perfomance
One of the reasons why I do my IO to my NAS using berryboot
im really newbie.. how do that?
https://www.berryterminal.com/doku.php/ ... sing_iscsi
Re: Temperature sensor
Posted: Friday 07 June 2019 10:50
by waaren
acaonweb wrote: Friday 07 June 2019 10:15
waaren wrote: Friday 07 June 2019 9:57
acaonweb 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"?
Sure. Have a look at
this topic of the dzVents wiki
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?
Yes. if you have a function in the helpers section of global_data.lua you call it with dz.helpers.<name of function>
If the function needs anything from the domoticz object you will have to pass a pointer to the domoticz object to it.
example global_data.lua
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,
},
}
example call to helper function hostname