Hey all!
I am looking for a method to get an alert of certain flights when it is received by my receiver, is this possible with the DUMP1090 of flightaware? Preferably the alert via telegram
Regards Dion
Hey all!
I am looking for a method to get an alert of certain flights when it is received by my receiver, is this possible with the DUMP1090 of flightaware? Preferably the alert via telegram
Regards Dion
You will need to use additional software and probably customize to do what you want.
Donāt you need a mobile phone to send telegram messages, thought it was not possible without one.
Anyway the following is software to send mails, maybe thatās what you are looking for.
You need to change the radar php if you are using the current dump1090-fa version.
The discussion on that is the last about 20 posts.
AboveTustin is an ADS-B Twitter Bot running on a Raspberry Pi 2. It tracks airplanes and then tweets whenever an airplane flies overhead.
I get emails for specified aircraft using thisā¦
Iāve just recently put together a Telegram Bot that you can host your own instance of. Currently it just sends notifications to āsubscribedā Telegram users when a plane is within a certain radius of a specified set of lat/lon coordinates.
Could you please repost flights.py , thanks!
Here you go. I donāt know what happened to the previous link.
This python script has real potential use for me. A friend of mine has asked if itās possible to get notifications of a specific aircraft if it comes within 50 miles. I told him ānopeā but I wonder if this can be tweaked in any way to only alert when the aircraft gets within a prescribed distance.
I was hoping I could use this for the same purpose but as far as I can see, the co-ordinates are in the json but not the distance. It is obviously possible to calculate the distance because software such as PiAware and Virtual Radar show it. I assume they do it using a haversine formula as discussed here and helpfully, they even give an example python script to do it.
Another method discussed elsewhere is to use an equirectangular distance approximation.
Unfortunately, my brain is refusing to allow me to put either of these into practice at present.
If you want an example in bash with awk, I used it for calculating range in my heat map plots.
Rosetta code is quite useful for code snippets in various languages.
So it is. Thanks. Iāll give it a try when I have some spare brain power.
Heās interested in one particular helicopter and Iāve set up an email alert for him. Because itās a heli that generally flies at a low altitude, the alert actually works well because it has to come relatively close before I see it anyway. It would be nice to set a range if anyone does play with it but in this usage case, itās not absolutely essential.
Iāve done this now using PlaneAlerter on my VRS box.
Based on the script of @Jranderson777 I added telegram functionality and the ability to match on SQUAWK or Flightnumber patterns.
#!/usr/bin/python3
# this file is called flights.py
# WHAT THIS DOES:
# ---------------------------------------------------------------
#
# 1) Read aircraft.json generated by dump1090-fa.
# 2) check to see if we are looking for this icao, flightpattern or squawk
# 3) send a telegram message to a defined channel
import datetime
import json
import time
import syslog
import telegram
import re
################################################################
# Define Telegram Bot token
bot = telegram.Bot(token="ask Botfather for key")
# Define flights to watch for
icaolist = {
'a6aa75': 'B29 flying fortress',
'a6aa76': 'B29 flying fortress'
}
flightlist = {
'HBAL': 'HBAL Google balloons',
'AIB': 'Airbus',
'JU52': 'JU52',
'DAQUI': 'JU52'
}
# Define Squawks to watch for
squawklist = {
'6303':'JU-Air',
'7500':'FlugzeugentfĆ¼hrung (hijacking; seven-five ā man with a knife)',
'7600':'Funkausfall (radio failure; seven-six ā hear nix / radio nix / need a radio fix)',
'7700':'Luftnotfall (emergency; seven-seven ā going to heaven / falling from heaven / pray to heaven / close to heaven)'
}
# Set your Telegram ChannelID
def sendTelegram(msg_content):
bot.sendMessage(chat_id=<telegramchannelid>, text=msg_content)
return None
def processAircraftList( aircraftList, icaolist, flightlist, squawklist, processed):
for aircraft in aircraftList:
hexcode = aircraft["hex"]
msg_content = ''
additional_infos = ''
squawk = ''
flight = ''
if 'squawk' in aircraft:
squawk = aircraft["squawk"]
#print(aircraft)
if "flight" in aircraft:
flight = aircraft["flight"].strip()
if hexcode in icaolist or any(code in flight for code in flightlist) or squawk in squawklist:
syslog.syslog('Match ' + flight)
if hexcode not in processed:
processed[hexcode] = datetime.datetime.now().replace(microsecond=0)
msg_content += 'http://tar1090.adsbexchange.com/?icao=' + hexcode + ' \n'
msg_content += 'https://www.planespotters.net/hex/' + hexcode.upper() + ' \n'
if hexcode in icaolist:
additional_infos += icaolist[hexcode] + ' \n'
if flight:
msg_content += 'https://www.radarbox.com/data/flights/' + flight + ' \n'
if any(code in flight for code in flightlist):
additional_infos += next((v for k, v in flightlist.items() if k in flight), None) + ' \n'
if squawk:
if squawk in squawklist:
msg_content += 'Squawk: ' + squawk + ' ' + squawklist[squawk]
else:
msg_content += 'Squawk: ' + squawk
msg_content += additional_infos
syslog.syslog(msg_content)
sendTelegram(msg_content)
else:
# we are tracking this aircraft and have already sent a telegram message. Just update the timestamp.
processed[hexcode] = datetime.datetime.now().replace(microsecond=0)
# dd print ('updated timestamp for ', hexcode )
# if the last time we saw the aircraft is more than 'goneaway' seconds old, then we will assume it landed or flew away.
# if it shows up again, we will send another email.
goneaway = 1200
syslog.syslog('Hi, flights.py starting up') # just for fun
# create dictionary for flights currently being tracked
processed = {'start':datetime.datetime.now() }
while True:
# Read dump1090-mutability's aircraft.json.
with open('/run/dump1090-fa/aircraft.json') as data_file:
data = json.load(data_file)
processAircraftList(data["aircraft"], icaolist, flightlist, squawklist, processed)
# remove entry from processed dictionary if not seen in the last 'goneaway' seconds
for hexcode in list(processed) :
if processed[hexcode] < datetime.datetime.now() - datetime.timedelta(seconds= goneaway) :
# print ('removing ', hexcode)
del processed[hexcode]
# have a rest, then look again at the json file
time.sleep(30)
#
###################################################################################################
And I also made a service file to add to /etc/systemd/system/flight-watcher:
[Unit]
Description=flight-watcher
[Service]
ExecStart=/opt/flight-watcher/flights.py
Restart=always
[Install]
WantedBy=multi-user.target
Thanks @awlnx for your script.
Just only a doubt, are you considering to use a file (.csv) instead of a list for icaolist or flightlist?
Thanks for your effort in make this awesome script, is just what I was looking for
Yep, I am working on implementing that at the moment :). Not sure about CSV tho, I think YAML or JSON is the better choice.
I also want to watch for the file changes so the services does not need to be restarted and just re-reads the list on change.
And I think I also publish a .deb so itās easy to install. But not sure about that yet.
Hi Kevin!
Iāve tried to install the AboveTustin but I got in trouble with phantomjs.
Image manipulation module "Pillow" not found, cropping disabled
/home/pi/.local/lib/python3.7/site-packages/selenium/webdriver/phantomjs/webdriver.py:49: UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless '
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'phantomjs': 'phantomjs'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tracker.py", line 137, in <module>
display = datasource.get_map_source()
File "/usr/share/mm2/AboveTustin/datasource.py", line 33, in get_map_source
return get_driver()['map'](g_map_url)
File "/usr/share/mm2/AboveTustin/screenshot.py", line 53, in __init__
self.loadmap()
File "/usr/share/mm2/AboveTustin/screenshot.py", line 95, in loadmap
browser = webdriver.PhantomJS(desired_capabilities={'phantomjs.page.settings.resourceTimeout': '20000'})
File "/home/pi/.local/lib/python3.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 56, in __init__
self.service.start()
File "/home/pi/.local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH.
Iām using raspi 2. By the way. Iāve installed Pillow-7.2.0 but Iām still getting the above error statating itās not installed.
Thank you.
Thanks awlnx and @Jranderson777 !
Your code Help me lot !
Hello @awlnx , I am very interested in your Python code, I will need a little advice. I will want to use this script on another Raspberry using the local: 8080 / data / aircraft.json.
To read the info on the raspberry which has the DUMP1090 with another raspberry on the same network.
Thank you in advance for your help.