Python code to notify you when an aircraft you want to track is in range

I have search the forms for a way to be notified when an aircraft that I was interested in was spotted on my dump1090. I never found any code that worked for me so I wrote my own. You are welcome to use this code if you know Python. You will also need a Amazon AWS account if you wish to receive text messages.

import json
import requests
import time
import datetime
import boto3

Create an SNS client

client = boto3.client(
“sns”,
aws_access_key_id=“YourID”,
aws_secret_access_key=“YourKey”,
region_name=“us-east-1”
)

plane = [‘PlaneToTrack’, ‘PlaneToTrack’, ‘PlaneToTrack’, ‘PlaneToTrack’] #Planes that you want to track

while True:
try:
r = requests.get(‘http://192.168.1.101:8080/data/aircraft.json’) #Your URL
rData = json.loads(r.text, encoding=“utf-8”)
x = rData[“aircraft”]
y = json.dumps(x)
current_date = datetime.datetime.now().replace(microsecond=0)
for z in plane:
if z in y:
print((z), " @ “, str(current_date))
#client.publish(PhoneNumber=“YourPhoneNunumber”, Message=str(z) + (” @ ") + str(current_date))
time.sleep(30)
except:
current_date = datetime.datetime.now().replace(microsecond=0)
print(‘Failed to open url’, " @ ", str(current_date))
time.sleep(120)

I wrote a script as well a while back which I posted about here, but I’ve changed the code a bit so the most recent version is available here. It runs as a daemon in the background and is able to filter ADS-B by country, callsign, and plane registration (if from a supported country).