hello, i want to add timer to my dzvents script, however with adding timer, still the script goes on every minute. Can someone help?
return {
on = {
devices = {
5, -- Flow Meter IDX
15, -- Temperature Delta IDX
25, -- Watt Sensor IDX
31,
29,
34 -- Power Sensor IDX
},
timer = {
'every 1 minute'
}
},
execute = function(domoticz, devices, timer)
timer not working in dzvents
Moderator: leecollings
-
- Posts: 621
- Joined: Saturday 21 September 2019 17:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.1
- Location: The Netherlands
- Contact:
Re: timer not working in dzvents
'every 1 minute' is exactly what you specified, so what is it that you want?
by the way, I think in the execute you should only add one parameter behind "domoticz", like this
execute = function(domoticz, trigger)
then you can check in your script whether the trigger is a device or a timer.
by the way, I think in the execute you should only add one parameter behind "domoticz", like this
execute = function(domoticz, trigger)
then you can check in your script whether the trigger is a device or a timer.
Re: timer not working in dzvents
sorry, its still runs every second i mean, not every minute.
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: timer not working in dzvents
Your script has 2 triggers:
1. Every minute
2. On every device change on the by you defined devices.
If your devices are updates every second then your script will also run every second.
BTW updating sensor devices every second is very fast for a domotica system. It is possible but your hardware should be accordingly fast.
If you just want to run it every minute you have to remove the device trigger from your script.
1. Every minute
2. On every device change on the by you defined devices.
If your devices are updates every second then your script will also run every second.
BTW updating sensor devices every second is very fast for a domotica system. It is possible but your hardware should be accordingly fast.
If you just want to run it every minute you have to remove the device trigger from your script.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 528
- Joined: Saturday 02 June 2018 11:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2022.1
- Location: Echt, Netherlands
- Contact:
Re: timer not working in dzvents
Do you need to have those devices as a trigger?
What i often see when people start using dzvents, that they out the devices In the trigger list, because they think this is necessary to use the data in the script. This is not the case.
Maybe you van post the complete script, that we can look if that device list can be shorters. And like waltervl said, look at your devices. Is an every second update necessary?
What i often see when people start using dzvents, that they out the devices In the trigger list, because they think this is necessary to use the data in the script. This is not the case.
Maybe you van post the complete script, that we can look if that device list can be shorters. And like waltervl said, look at your devices. Is an every second update necessary?
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
Re: timer not working in dzvents
return {
on = {
devices = {
5, -- Flow Meter IDX
15, -- Temperature Delta IDX
25, -- Watt Sensor IDX
31,
29,
34 -- Power Sensor IDX
},
timer = {
'every 1 minute'
}
},
execute = function(domoticz, timer)
-- Get devices
local flowMeter = domoticz.devices(5) -- Flow Meter IDX
local temperatureDelta = domoticz.devices(15) -- Temperature Delta IDX
local wattSensor = domoticz.devices(25) -- Watt Sensor IDX
local powerSensor = domoticz.devices(34) -- Power Sensor IDX
local customSensor = domoticz.devices(17) -- Custom Sensor IDX for COP
local sensor1 = domoticz.devices(31) -- Temperature Sensor 20 IDX
local sensor2 = domoticz.devices(29) -- Temperature Sensor 29 IDX
-- Check if all devices are available
if flowMeter and temperatureDelta and wattSensor and powerSensor and customSensor then
-- Get flow reading (default to 0 if nil)
local flow = flowMeter.flow or 0
-- Get the value from the temperatureDelta device
local temperatureDeltaValue = sensor1.temperature - sensor2.temperature
-- Calculate power
local power = (flow * 60 / 1 ) * 4 * 975 * temperatureDeltaValue / 3
-- Get watt reading (default to 0 if nil)
local watt = wattSensor.actualWatt or 0
if watt > 0 then
-- Calculate COP
local cop = power / watt
cop = math.floor(cop * 100) / 100
customSensor.updateCustomSensor(cop)
else
-- Set COP to 0 if watt reading is 0
customSensor.updateCustomSensor(0)
end
-- Update power sensor with calculated power
powerSensor.updateCustomSensor(power)
temperatureDelta.updateCustomSensor(temperatureDeltaValue)
end
end
}
now it gets triggered by every device change (interval for devices is 1 second)
on = {
devices = {
5, -- Flow Meter IDX
15, -- Temperature Delta IDX
25, -- Watt Sensor IDX
31,
29,
34 -- Power Sensor IDX
},
timer = {
'every 1 minute'
}
},
execute = function(domoticz, timer)
-- Get devices
local flowMeter = domoticz.devices(5) -- Flow Meter IDX
local temperatureDelta = domoticz.devices(15) -- Temperature Delta IDX
local wattSensor = domoticz.devices(25) -- Watt Sensor IDX
local powerSensor = domoticz.devices(34) -- Power Sensor IDX
local customSensor = domoticz.devices(17) -- Custom Sensor IDX for COP
local sensor1 = domoticz.devices(31) -- Temperature Sensor 20 IDX
local sensor2 = domoticz.devices(29) -- Temperature Sensor 29 IDX
-- Check if all devices are available
if flowMeter and temperatureDelta and wattSensor and powerSensor and customSensor then
-- Get flow reading (default to 0 if nil)
local flow = flowMeter.flow or 0
-- Get the value from the temperatureDelta device
local temperatureDeltaValue = sensor1.temperature - sensor2.temperature
-- Calculate power
local power = (flow * 60 / 1 ) * 4 * 975 * temperatureDeltaValue / 3
-- Get watt reading (default to 0 if nil)
local watt = wattSensor.actualWatt or 0
if watt > 0 then
-- Calculate COP
local cop = power / watt
cop = math.floor(cop * 100) / 100
customSensor.updateCustomSensor(cop)
else
-- Set COP to 0 if watt reading is 0
customSensor.updateCustomSensor(0)
end
-- Update power sensor with calculated power
powerSensor.updateCustomSensor(power)
temperatureDelta.updateCustomSensor(temperatureDeltaValue)
end
end
}
now it gets triggered by every device change (interval for devices is 1 second)
Re: timer not working in dzvents
also, maybe someone has information on controlling pwm signal?
http://192.168.8.182/control?cmd=PWM,12,3 i put in this code to my selector switch (i need to generate 18Hz 3% pwm signal) , however it doesnt seem to react to this command
http://192.168.8.182/control?cmd=PWM,12,3 i put in this code to my selector switch (i need to generate 18Hz 3% pwm signal) , however it doesnt seem to react to this command
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: timer not working in dzvents
Better keep questions seperated.
To return to your original question of script being run every second instead of every minute:
Remove the following section from your script:
To return to your original question of script being run every second instead of every minute:
Remove the following section from your script:
Code: Select all
devices = {
5, -- Flow Meter IDX
15, -- Temperature Delta IDX
25, -- Watt Sensor IDX
31,
29,
34 -- Power Sensor IDX
},
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: No registered users and 1 guest