i have installed the Fritz TR064 Binding and use it for Presence.
It works good but in some Cases the Mobile of my wife getting Crazy and relogin many times.
So because than my Welcome Rule will start and i want to measure how long is the absense and than in my Welcome Rule i will use if Absense was lower than for example 30 Minute don´t start Welcome Rule.
Do anyone has an idea how to handle this?
If you ping it does it drop out at the same time?
Not sure how the Samsung phone works but the iPhones go to sleep from time to time. Maybe the same thing?
That doesn´t matter for me,I allready told her that she bought trash Mobile i want to implement something that also not fire the Welcome Rule when the Absence is lower that 30 Minutes.
Ive been using Rich’s antiflapping timer for a few months with good results on both iPhone and S7. You may have to adjust the retry=???, timeout=???, refreshInterval=??? until you find what works best. For me, a few minor adjustments to the above settings were needed,
i don´t understand how this help me? i have a running presence and want to have an additional information how long is for example my wife absence so that i can use this in a rule for example only fire a rule when the time is more than 30 Minutes.
rule "start gPresent on system start"
when
System started
then
Present.sendCommand(OFF) // assume no one is home
end
rule "gPresent updated, at least one change of state"
when
Item gPresent received update
then
// someone came home
if(gPresent.state == ON && Present.state != ON) {
Present_Timer.postUpdate(OFF) // cancel the timer if necessary
Present.sendCommand(ON)
}
// no one is home and timer is not yet ticking (otherwise endless loop)
else if(gPresent.state == OFF && Present.state != OFF && Present_Timer.state != ON) {
Present_Timer.sendCommand(ON) // start the timer
}
end
rule "Present_Timer expired"
when
Item Present_Timer received command OFF
then
Present.sendCommand(OFF)
end
You can edit the rule to add something whatever you like when Present.sendCommand(OFF) occurs. You can also adjust the Switch Present_Timer expire time to suit your needs. I gave it 20 minutes to make sure the phone was not home before turning off a lamp. Also, in the things file you may need to adjust the retry, timeout and refreshInterval to find what works consistently with your devices.
I use the phones IP address that I have set as reserved in the router via the MAC address.
Thank for all your help, i should explain what i want right.
My Presense woorking good. So when my wifes Phone goes Offline i want to count the Minutes and also want to use this information in the Sitemap So that i can have an entry Offline since XX minutes.
I’m not the best at coding, still working on it but maybe you can try a rule using a time cron to run every minuet. If no presents then +1 to a proxy item that you can see in your sitemap. Try a search in the forum, you may find something similar or even better you can work with.
OK… I chicken pecked something that is working for counting and showing on sitemap. I’m sure it will need some adjustments but hopefully it will get you started.
Rule
var timerCount = 0
rule "timer"
when
Time cron "0 * * ? * *"
then
if(LivingRoom_Light.state == OFF) {
timerCount +=1;
timer.postUpdate(timerCount)
}
end
rule "maxtime"
when
Item LivingRoom_Light changed to ON
then
if(timerCount > 1) {
timermax.postUpdate(timerCount)
timerCount = 0
}
end
Item
Switch LivingRoom_Light "Living Room Light"
Number timer "[%d]"
Number timermax "[%d]"
Sitemap
Frame label="timer test"
{
Text item=timer label="Timer [%d]"
Text item=timermax label="Max Time [%d]"
}
This will show the current count number (each number is one minute) and the max time number in event someone comes then goes before you can see the count. Still need to have a way to reset the max count after you get info needed. Something like another item and rule with a button on the sitemap you can toggle and set the max count to 0.
I posted this because helping others increases my knowledge but I encourage you to search the forum for other/better ways to accomplish your needs. There are many ways to skin a cat:grinning: and certainly more elegant. If your not familiar with code, neither am I but we all have to start somewhere.