...
Try sending a test email to make sure that it is set up correctly.
System>Scripts
...
Option (a)
Navigate to System>Scripts menu and add a new script there.
...
You should make sure that the e-mail notification was received after manually initiating the script.
Monitoring multiple triggers
When the script (a) is initiated, RouterOS is going to check every received/stored Bluetooth payload, and if any trigger is found in the payload's list → an e-mail message is structured and sent. This e-mail message will simply indicate which triggers were detected in the list with no additional information.
Option (b)
Script (a) will send a message indicating whether all possible triggers were For monitoring multiple triggers (those are freefalling, tilt, and movement against X, Y, Z, XY, XZ, XYZ, and YZ axis), use the script:
#User configuration:
#input the tag's mac address that you wish to monitor within the ""
:local addressRegex "2C:C8:1B:4B:BB:0A"
#enter trigger value, for example "04" for freefalling trigger and "02" for tilt trigger detection
:local triggervalueF "04"
:local triggervalueT "02"
:local triggervalueX "08"
:local triggervalueXY "18"
:local triggervalueXZ "28"
:local triggervalueXYZ "38"
:local triggervalueY "10"
:local triggervalueYZ "30"
:local triggervalueZ "20"
#name the trigger accordingly
:local triggernameF "freefalling"
:local triggernameT "tilt"
:local triggernameX "Xmovement"
:local triggernameXY "XYmovement"
:local triggernameXZ "XZmovement"
:local triggernameXYZ "XYZmovement"
:local triggernameY "Ymovement"
:local triggernameYZ "YZmovement"
:local triggernameZ "Zmovement"
#enter the message for the email body that you wish to receive within the ""
:local emailmessageF "Our tag fell down!"
:local emailmessageT "Our tag tilted!"
:local emailmessageX "Our tag moved against X axis!"
:local emailmessageXY "Our tag moved against X and Y axis!"
:local emailmessageXZ "Our tag moved against X and Z axis!"
:local emailmessageXYZ "Our tag moved against X,Y and Z axis!"
:local emailmessageY "Our tag moved against Y axis!"
:local emailmessageYZ "Our tag moved against Y and Z axis!"
:local emailmessageZ "Our tag moved against Z axis!"#enter the subject for the email within the ""
:local emailsubject "RouterOS report!"#enter the email address wthin the ""
:local emailaddress "YOUR_EMAIL@gmail.com"###Bluetooth scanner
:local triggerF
:local triggerT
:local triggerX
:local triggerXY
:local triggerXZ
:local triggerXYZ
:local triggerY
:local triggerYZ
:local triggerZ:put ("[*] Gathering Bluetooth info...")
:global btOldestAdvertisementTimestamp
:if ([:typeof $btOldestAdvertisementTimestamp] = "nothing") do={:set $btOldestAdvertisementTimestamp 0}
:local btProcessingStart [/system clock get time]
:local advertisements [/iot bluetooth scanners advertisements print detail \
as-value where \
epoch > $btOldestAdvertisementTimestamp and \
address ~ $addressRegex]
:local advCount 0
:local lastAdvTimestamp 0:foreach adv in=$advertisements do={
:local address ($adv->"address")
:local ad ($adv->"data")
:local ts ($adv->"epoch")
:local trig [:pick ($adv->"data") 40 42]
:set $advCount ($advCount + 1)
:set $lastAdvTimestamp $ts
:if ($trig="$triggervalueF") do={:set triggerF "$triggernameF"}
:if ($trig="$triggervalueT") do={:set triggerT "$triggernameT"}
:if ($trig="$triggervalueX") do={:set triggerX "$triggernameX"}
:if ($trig="$triggervalueXY") do={:set triggerXY "$triggernameXY"}
:if ($trig="$triggervalueXZ") do={:set triggerXZ "$triggernameXZ"}
:if ($trig="$triggervalueXYZ") do={:set triggerXYZ "$triggernameXYZ"}
:if ($trig="$triggervalueY") do={:set triggerY "$triggernameY"}
:if ($trig="$triggervalueYZ") do={:set triggerYZ "$triggernameYZ"}
:if ($trig="$triggervalueZ") do={:set triggerZ "$triggernameZ"}:if ($advCount > 0) do={:set $btOldestAdvertisementTimestamp $lastAdvTimestamp}}
:put ("[*] Found $advCount new advertisements \
(processing time: $[([/system clock get time] - $btProcessingStart)])")###Result
:if ($triggerF="$triggernameF") do={/tool e-mail send to=$emailaddress subject="$emailsubject" body="$emailmessageF"}
:if ($triggerT="$triggernameT") do={/tool e-mail send to=$emailaddress subject="$emailsubject" body="$emailmessageT"}
:if ($triggerX="$triggernameX") do={/tool e-mail send to=$emailaddress subject="$emailsubject" body="$emailmessageX"}
:if ($triggerXY="$triggernameXY") do={/tool e-mail send to=$emailaddress subject="$emailsubject" body="$emailmessageXY"}
:if ($triggerXZ="$triggernameXZ") do={/tool e-mail send to=$emailaddress subject="$emailsubject" body="$emailmessageXZ"}
:if ($triggerXYZ="$triggernameXYZ") do={/tool e-mail send to=$emailaddress subject="$emailsubject" body="$emailmessageXYZ"}
:if ($triggerY="$triggernameY") do={/tool e-mail send to=$emailaddress subject="$emailsubject" body="$emailmessageY"}
:if ($triggerYZ="$triggernameYZ") do={/tool e-mail send to=$emailaddress subject="$emailsubject" body="$emailmessageYZ"}
:if ($triggerZ="$triggernameZ") do={/tool e-mail send to=$emailaddress subject="$emailsubject" body="$emailmessageZ"}
...