Je viens de faire ce script mais ca ne marche pas.
Le compteur s'incremente a chaque fois et depasse 6 (1,2,3,4,5,6,7,8,9,10,...) mais le script ne passe jamais dans les 2 derniers "if" comme si le timer n'etait ni true ni false. Le timer est mis sur 5 secondes pour l'nstant. Qu'est-ce qui ne va pas ?
Le compteur s'incremente a chaque fois et depasse 6 (1,2,3,4,5,6,7,8,9,10,...) mais le script ne passe jamais dans les 2 derniers "if" comme si le timer n'etait ni true ni false. Le timer est mis sur 5 secondes pour l'nstant. Qu'est-ce qui ne va pas ?
Code:
print("script_panic: start script")
-- IO id
timer_id = "input_58" -- InputTimer type
counter_id = "intern_0" -- InternalInt type
-- Increment the counter
local counter = calaos:getInputValue(counter_id) + 1;
calaos:setOutputValue(counter_id, counter);
-- Start the timer the first time
if counter == 1 then
print("script_panic: Start timer")
calaos:setOutputValue(timer_id, "start");
end
-- Panic mode: Counts reached before the timer is done
if counter >= 6 and calaos:getInputValue(timer_id) == false then
print("script_panic: Panic mode")
calaos:setOutputValue(timer_id, "stop");
return true
end
-- Counts not reached when the timer is done
if calaos:getInputValue(timer_id) == true then
print("script_panic: Reset timer and counter")
calaos:setOutputValue(timer_id, "stop");
calaos:setOutputValue(counter_id, 0);
return false
end
print("script_panic: Timer continues, counter = " .. counter)
return false
▶ calaos-os-raspberrypi2-v3.0-alpha6-14-g341535a-2021-01-17 on Raspberry Pi 2 ▶ Wago_2.2/wago_881.pro on Wago 750-881 ▶ DS18B20 sensors on Pi GPIO ▶ Node-RED