Code: Select all
return {
active = true,
on =
{
timer = {'at 07:00-23:00'},
devices = {'KNMI Wind'},
},
logging = {
level = domoticz.LOG_DEBUG,
marker = 'buitentemperatuur gemiddeld',
},
data = {
temperatures = { history = true, maxHours = 24 },
},
execute = function(domoticz, sensor)
-- add new data
domoticz.data.temperatures.add(sensor.temperature)
-- average
local average = domoticz.data.temperatures.avg()
domoticz.log('average temperature ' .. average, domoticz.LOG_INFO)
domoticz.devices('Gem buitentemp').updateTemperature(average)
-- domoticz.log('average temperature ' .. average, domoticz.LOG_INFO)
-- maximum value in the past 24 hours:
local max = domoticz.data.temperatures.maxSince('24:00:00')
domoticz.devices('Max buitentemp').updateTemperature(max)
-- domoticz.log('maximum temperature ' .. max, domoticz.LOG_INFO)
-- minimum value in the past 24 hours:
local min = domoticz.data.temperatures.minSince('24:00:00')
domoticz.devices('Min buitentemp').updateTemperature(min)
-- domoticz.log('minimum temperature ' .. max, domoticz.LOG_INFO)
end
}
I'd like the script to execute between 7 in the morning and 23 in the evening.
So I added this:
Code: Select all
timer = {'at 07:00-23:00'},Code: Select all
return {
active = true,
on =
{
timer = {'at 07:00-23:00'},
devices = {'KNMI Wind'},
},
Code: Select all
2023-12-22 22:37:00.203 Status: dzVents: Info: buitentemperatuur gemiddeld: ------ Start internal script: Buitentemp gemiddeld:, trigger: "at 07:00-23:00"
2023-12-22 22:37:00.209 Status: dzVents: Info: buitentemperatuur gemiddeld: ------ Finished Buitentemp gemiddeld
2023-12-22 22:37:00.209 Error: dzVents: Error: (3.1.8) buitentemperatuur gemiddeld: Item data is not a number type. Type is nil
2023-12-22 22:37:00.209 Error: dzVents: Error: (3.1.8) buitentemperatuur gemiddeld: An error occurred when calling event handler Buitentemp gemiddeld
2023-12-22 22:37:00.209 Error: dzVents: Error: (3.1.8) buitentemperatuur gemiddeld: /home/hein/domoticz/dzVents/runtime/HistoricalStorage.lua:282: attempt to perform arithmetic on a nil value (local 'acc')That is the reason the function gets no data from 'KNMI Wind'