...
### User params
:local addressRegex "DC:2C:6E:91:D6:F3"
:local urlNotInRange "https://maker.ifttt.com/trigger/{The_tag_is_NOT_in_range}/json/with/key/-xxxx"
:local urlInRange "https://maker.ifttt.com/trigger/{The_tag_IS_within_range}/json/with/key/-xxxx"
:local missingInterval 60000###Time
:global EpochTime do={
:local ds [/system clock get date];
:local months;
:if ((([:pick $ds 9 11]-1)/4) != (([:pick $ds 9 11])/4)) do={
:set months {"an"=0;"eb"=31;"ar"=60;"pr"=91;"ay"=121;"un"=152;"ul"=182;"ug"=213;"ep"=244;"ct"=274;"ov"=305;"ec"=335};
} else={
:set months {"an"=0;"eb"=31;"ar"=59;"pr"=90;"ay"=120;"un"=151;"ul"=181;"ug"=212;"ep"=243;"ct"=273;"ov"=304;"dec"=334};
}
:set ds (([:pick $ds 9 11]*365)+(([:pick $ds 9 11]-1)/4)+($months->[:pick $ds 1 3])+[:pick $ds 4 6]);
:local ts [/system clock get time];
:set ts (([:pick $ts 0 2]*60*60)+([:pick $ts 3 5]*60)+[:pick $ts 6 8]);
:return ($ds*24*60*60 + $ts + 946684800 - [/system clock get gmt-offset]);
}:local Epomili
:set Epomili ([$EpochTime]."000")###Bluetooth
:local adver
:local adver2
:local ts
:local clockmin:set adver [/iot bluetooth scanners advertisements print detail as-value where address ~ $addressRegex]
:set adver2 ($adver->0)
:set ts ($adver2 -> "epoch")
:set clockmin ($Epomili-$missingInterval):global local counterIN
:global local counterOUT:if ($ts<=$clockmin) do={
:set $counterIN 0;
:if ($counterOUT=0 or $counterOUT=null) do={
:set $counterOUT 0;
/tool fetch http-method=get output=user url=$urlNotInRange;
:set counterOUT ($counterOUT+1);
:log info "IFTTT notification - the tag is OUT OF range!"
} else={
:log info "Tag is OUT of range! Notification was already sent before!"
}
} else={
:set $counterOUT 0;
:if ($counterIN=0 or $counterIN=null) do={
:set $counterIN 0;
/tool fetch http-method=get output=user url=$urlInRange;
:set $counterIN ($counterIN+1);
:log info "IFTTT notification - tag IS WITHIN range!"
} else={
:log info "Tag is WITHIN the range! Notification was already sent before!"
}
}
...