Need help with presence


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?

Best Regards

What phone is it? IPhone?

no its a Samsung S8

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 :slight_smile: i want to implement something that also not fire the Welcome Rule when the Absence is lower that 30 Minutes.

Use an antiflapping timer like is used in Generic Presence Detection.

1 Like

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.


How are you detecting the presents of your wife, cell phone?

Yes Fritz Tr064 Binding and Mac Adress of the Phone

I’m not familiar with the Fritz Tr064 Binding but I detect presents of an iphone like so.
Thing file:

Thing network:pingdevice:SiPhone [ hostname="", uses_ios_wakeup=1, uses_arp_pings=1, retry=30, timeout=15000, refreshInterval=60000 ]

Items file:

Group:Switch:AND(OFF,ON) gPresent <present>
Switch Present "Phone is home" <present>
Switch Present_Timer { expire="20m, command=OFF" }
Switch MyDevice <network> (gPresent) { channel="network:pingdevice:SiPhone:online" }

Rules file:

rule "start gPresent on system start"
    System started
    Present.sendCommand(OFF) // assume no one is home

rule "gPresent updated, at least one change of state"
    Item gPresent received update
    // someone came home
    if(gPresent.state == ON && Present.state != ON) { 
        Present_Timer.postUpdate(OFF) // cancel the timer if necessary

    // 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

rule "Present_Timer expired"
	Item Present_Timer received command OFF

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 :grin: 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.

1 Like

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.


var timerCount = 0
rule "timer"
	Time cron "0 * * ? * *"
	if(LivingRoom_Light.state == OFF) {
		timerCount +=1;
rule "maxtime"
	Item LivingRoom_Light changed to ON
	if(timerCount > 1) {
		timerCount = 0


Switch LivingRoom_Light "Living Room Light" 
Number timer "[%d]"
Number timermax "[%d]"


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.

Best of Luck

Wouldn’t you just rest to zero when “the wife” becomes present again.

Yes the counter would, but the max counter will remain at the last highest count regardless of presents or time.