Not as much as I had hoped. But here is what I have.
Items
Switch flighttest
Switch Traveling_Switch
String FlightNumber_String "FlightNumber_String [%s]"
String FlightOrgAirport_String "FlightOrgAirport_String [%s]"
String FlightDstAirport_String "FlightDstAirport_String [%s]"
String FlightEstimatedDeparture_String "FlightEstimatedDeparture_String [%s]"
String FlightActualDepartureTime_String "FlightActualDepartureTime_String [%s]"
String FlightEstimatedArrival_Time "FlightEstimatedArrival_Time [%s]"
String FlightActual_Arrival_Time "FlightActual_Arrival_Time [%s]"
String FlightStatus "FlightStatus [%s]"
Number FlightProgress_Percent "FlightProgress_Percent [%s]"
String FlightAircraftType "FlightAircraftType [%s]"
Rules
rule "flight"
when
Time cron "0 * * * * ?"
then
logInfo("General","here")
if(Traveling_Switch.state == ON)
{
//traveling is turned on, we need to check
//lets see if we have a flight number
logInfo("Travel","Flight:" + FlightNumber_String.toString)
if(FlightNumber_String.state.toString != "")
{
logInfo("Travel","Flight not empty")
var String FlightOriginAirPorttmp = sendHttpGetRequest("http://192.168.2.35/flightaware/test.php?flightnum=FlightNumber_String").toString
FlightOrgAirport_String.postUpdate(transform("JSONPATH", "$.FlightInfoStatusResult.flights[0].origin.airport_name",FlightOriginAirPorttmp).toString)
FlightDstAirport_String.postUpdate(transform("JSONPATH", "$.FlightInfoStatusResult.flights[0].destination.airport_name",FlightOriginAirPorttmp).toString)
FlightEstimatedDeparture_String.postUpdate(transform("JSONPATH", "$.FlightInfoStatusResult.flights[0].estimated_departure_time.time",FlightOriginAirPorttmp).toString)
FlightActualDepartureTime_String.postUpdate(transform("JSONPATH", "$.FlightInfoStatusResult.flights[0].actual_departure_time.epoch",FlightOriginAirPorttmp).toString)
FlightEstimatedArrival_Time.postUpdate(transform("JSONPATH", "$.FlightInfoStatusResult.flights[0].estimated_arrival_time.time",FlightOriginAirPorttmp).toString)
FlightActual_Arrival_Time.postUpdate(transform("JSONPATH", "$.FlightInfoStatusResult.flights[0].actual_arrival_time.epoch",FlightOriginAirPorttmp).toString)
FlightStatus.postUpdate(transform("JSONPATH", "$.FlightInfoStatusResult.flights[0].status",FlightOriginAirPorttmp).toString)
FlightProgress_Percent.postUpdate(transform("JSONPATH", "$.FlightInfoStatusResult.flights[0].progress_percent",FlightOriginAirPorttmp).toString)
FlightAircraftType.postUpdate(transform("JSONPATH", "$.FlightInfoStatusResult.flights[0].aircrafttype",FlightOriginAirPorttmp).toString)
}
}
else {
logInfo("General", "Cron check: Travel = Off")
}
end
rule "detected flight"
when
Item flighttest changed
then
if (flighttest.state==ON)
var url = transform("REGEX", ".*\(.*?\).*", "Flight to Atlanta (DL 1961)".toString())
logInfo("Flight","Flight:" + url.toString())
}
end
The php file i used for test is here.
{"FlightInfoStatusResult":{"next_offset":1,"flights":[{"ident":"UPS782","faFlightID":"UPS782-1501705398-0-0-15","airline":"UPS","flightnumber":"782","tailnumber":"N150UP","type":"Form_Airline","blocked":false,"diverted":false,"cancelled":false,"origin":{"code":"KSAT","city":"San Antonio, TX","alternate_ident":"","airport_name":"San Antonio Intl"},"destination":{"code":"KLRD","city":"Laredo, TX","alternate_ident":"","airport_name":"Laredo Intl"},"filed_ete":1680,"route":"MILET4 LRD","filed_altitude":200,"display_filed_altitude":"20,000 feet","filed_airspeed_kts":353,"distance_filed":150,"filed_departure_time":{"epoch":1501760160,"tz":"CDT","dow":"Thursday","time":"06:36AM","date":"08/03/2017","localtime":1501742160},"estimated_departure_time":{"epoch":1501760100,"tz":"CDT","dow":"Thursday","time":"06:35AM","date":"08/03/2017","localtime":1501742100},"actual_departure_time":{"epoch":0},"departure_delay":-60,"filed_arrival_time":{"epoch":1501761840,"tz":"CDT","dow":"Thursday","time":"07:04AM","date":"08/03/2017","localtime":1501743840},"estimated_arrival_time":{"epoch":1501761780,"tz":"CDT","dow":"Thursday","time":"07:03AM","date":"08/03/2017","localtime":1501743780},"actual_arrival_time":{"epoch":0},"arrival_delay":-60,"status":"Scheduled","progress_percent":-1,"aircrafttype":"A306","full_aircrafttype":"A306","inbound_faFlightID":"UPS782-1501690099-0-0-64","adhoc":false}]}}
That way I wasn’t burning up a bunch of my calls to flightware.
The real page is
<?php
// get flight status on flight
$options = array(
'trace' => true,
'exceptions' => 0,
'login' => 'apilogin',
'password' => 'apikey',
);
$client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML3/wsdl', $options);
$params = array(
"ident" => "UPS782",
"howMany" => 1,
"offset" => 0 );
$result = $client->FlightInfoStatus($params);
print_r($result);
So there is some work left to do. In the index page you can see the “ident” is hard coded. That needs to be changed to most likely to the item “FlightNumber_String” and that would put your flight number in.
I was working on that part with the rule “detected flight”
What I was trying to do was do some regex that would search for flight number in a string, that string would be my appointments since google was putting my flight numbers on my calendar automatically.
However, if you do something like just put in a string where you could type in your flight number and the date you are flying you could have the cronjob match that string and turn on the “Traveling_Switch” and then the rest of the rules would fire.
There was another item type i never got around to doing.
String FlightAircraftImage
Then in the rule it would update like:
FlightAircraftType.postUpdate(transform("JSONPATH", "https://www.skybrary.aero/images/$.FlightInfoStatusResult.flights[0].aircrafttype",FlightOriginAirPorttmp).toString)
Or whatever the format is. Not actually doing this on my server. But it seems the site skybrary.aero has ALOT if not all the aircraft type images stored based on their names.
I stopped working on this as my job duties changed and I don’t travel much (if any) like I was.
I hope this helps get you further and would love to see any progress you make or add!!