Ping and relay with rule
Moderators: grovkillen, Stuntteam, TD-er
Ping and relay with rule
Hello,
i would like to create rule with ping an reset in case of ping fail. (reset ip cam and router- 2 relays)
Both are connected to relay NC-COM.
This is my rule but at boot relay still goes on to NO. Second problem is that ipcam takes 2 minutes before it is up and running so i at the end i also need delay.
I need to set 2 delays (after boot and after reset)
RULE FOR IPCAM:
__________________________
on System#Boot do
gpio,13,1 // relay NC
endon
HOW TO SET DELAY BEFORE PING SCRIPT
on ipcam_ping#Ping do
if [ipcam_ping#Ping]=0
timerSet,1,5 // 5 s relay to NO
gpio,13,0 // Turn NO
endif
endon
on Rules#Timer=1 do
gpio,13,1 // Turn on relay
endon
HOW TO SET DELAY FOR 2 minutes that Ipcam IS ONLINE AGAIN
___________________________
Thank you,
U
i would like to create rule with ping an reset in case of ping fail. (reset ip cam and router- 2 relays)
Both are connected to relay NC-COM.
This is my rule but at boot relay still goes on to NO. Second problem is that ipcam takes 2 minutes before it is up and running so i at the end i also need delay.
I need to set 2 delays (after boot and after reset)
RULE FOR IPCAM:
__________________________
on System#Boot do
gpio,13,1 // relay NC
endon
HOW TO SET DELAY BEFORE PING SCRIPT
on ipcam_ping#Ping do
if [ipcam_ping#Ping]=0
timerSet,1,5 // 5 s relay to NO
gpio,13,0 // Turn NO
endif
endon
on Rules#Timer=1 do
gpio,13,1 // Turn on relay
endon
HOW TO SET DELAY FOR 2 minutes that Ipcam IS ONLINE AGAIN
___________________________
Thank you,
U
Re: Ping and relay with rule
Not sure if you use an ESP8266 or ESP32.
Anyway, please check this list to pick the best GPIO for this relay: https://espeasy.readthedocs.io/en/lates ... on-esp8266
See here for the timerset command: https://espeasy.readthedocs.io/en/lates ... html#timer
What you can do is you can set a variable.
This way you have set a flag ([int#2]) to 1 to indicate you're still waiting.
Anyway, please check this list to pick the best GPIO for this relay: https://espeasy.readthedocs.io/en/lates ... on-esp8266
See here for the timerset command: https://espeasy.readthedocs.io/en/lates ... html#timer
What you can do is you can set a variable.
Code: Select all
on ipcam_ping#Ping do
if [int#2]=0 and [ipcam_ping#Ping]=0
timerSet,1,5 // 5 s relay to NO
gpio,13,0 // Turn NO
endif
endon
on Rules#Timer=1 do
gpio,13,1 // Turn on relay
timerSet,2,120 // 120 sec timer #2
let,2,1 // Set [int#2] to 1
endon
on Rules#Timer=2 do
let,2,0 // Set [int#2] to 0
endon
Re: Ping and relay with rule
A flag in var 1 is used to enable/disable the ping-check
Code: Select all
on System#Boot do
gpio,13,1 // relay NC
AsyncEvent,Rules#Timer=1 // just execute that timer 1 event once
endon
on ipcam_ping#Ping do
if %v1%=0 and [ipcam_ping#Ping]=0
timerSet,1,5 // 5 s relay to NO
gpio,13,0 // Turn NO
endif
endon
on Rules#Timer=1 do
gpio,13,1 // Turn on relay
Let,1,1 // Inhibit pingcheck
TimerSet,2,120 // Reset inhibit after 2 minutes
endon
on Rules#Timer=2 do
Let,1,0 // Release check inhibit
endon
If you still need/want to check and reset the router too, either you add a separate check, using a separate ping check and timer 3 and 4 (there are 256 timers available), or use just switch another relay at the same time the cam-relay is switched.
/Ton (PayPal.me)
Re: Ping and relay with rule
I am using wemos d1 mini- gpio is OK.
I tested this script and after boot relays are OK not switching.
Timer is not working and not switching relay.
debug is:
506110: EVENT: ipcam_ping#Ping=1.00
506162: Lev.1: [if 1=0]=false
506182: EVENT: ipcam_ping#Ping=1.00 Processing time:73 milliSeconds
506409: Ping result for:192.168.200.123 1
1005847: EVENT: ipcam_ping#Ping=0.00
1005897: Lev.1: [if 0=0]=false
1005918: EVENT: ipcam_ping#Ping=0.00 Processing time:72 milliSeconds
1006145: Ping result for:192.168.200.123 0
u
I tested this script and after boot relays are OK not switching.
Timer is not working and not switching relay.
debug is:
506110: EVENT: ipcam_ping#Ping=1.00
506162: Lev.1: [if 1=0]=false
506182: EVENT: ipcam_ping#Ping=1.00 Processing time:73 milliSeconds
506409: Ping result for:192.168.200.123 1
1005847: EVENT: ipcam_ping#Ping=0.00
1005897: Lev.1: [if 0=0]=false
1005918: EVENT: ipcam_ping#Ping=0.00 Processing time:72 milliSeconds
1006145: Ping result for:192.168.200.123 0
u
Re: Ping and relay with rule
Hello,Ath wrote: ↑24 Oct 2022, 21:23A flag in var 1 is used to enable/disable the ping-checkNB: I'd avoid resetting the router, vs. fixing the actual cause for poor WiFi performance. Resetting the cam isn't unusual, mostly because of poor software quality of many of those cheap camsCode: Select all
on System#Boot do gpio,13,1 // relay NC AsyncEvent,Rules#Timer=1 // just execute that timer 1 event once endon on ipcam_ping#Ping do if %v1%=0 and [ipcam_ping#Ping]=0 timerSet,1,5 // 5 s relay to NO gpio,13,0 // Turn NO endif endon on Rules#Timer=1 do gpio,13,1 // Turn on relay Let,1,1 // Inhibit pingcheck TimerSet,2,120 // Reset inhibit after 2 minutes endon on Rules#Timer=2 do Let,1,0 // Release check inhibit endon
If you still need/want to check and reset the router too, either you add a separate check, using a separate ping check and timer 3 and 4 (there are 256 timers available), or use just switch another relay at the same time the cam-relay is switched.
router and ipcam are on remote location… Router is mobile-5G - it works 99% of time. ipcam is cloud connected because of port blocked on mobile network.. and as you said cheap sw. first i will try only with ipcam reset but i also dont know if ipcam is online on local network when not reachable from cloud.
Shoul i create 2 rules? reset every night at 0:00 and this
ping script to be on shure side?
Your script timer is working- it waits 2 min but at boot relay is switched on- that is not ok.
u
Re: Ping and relay with rule
Then replace the System#Boot rule with this:
Code: Select all
on System#Boot do
Let,1,1 // Disable pingcheck until after cam is started
TimerSet,1,120 // Delay start of cam with 2 minutes
endon
/Ton (PayPal.me)
Re: Ping and relay with rule
Hello,
TNX- i will test now.
U
TNX- i will test now.
U
Who is online
Users browsing this forum: No registered users and 52 guests