extract line, too. It is published for each direction to MQTT
This commit is contained in:
@@ -12,12 +12,18 @@ async fn publish_departure_data(client: &AsyncClient, data: &straba::NextDepartu
|
||||
client
|
||||
.publish("departure/outbound/station", QoS::AtLeastOnce, false, data.outbound_station.as_bytes())
|
||||
.await?;
|
||||
client
|
||||
.publish("departure/outbound/line", QoS::AtLeastOnce, false, data.outbound_line.as_bytes())
|
||||
.await?;
|
||||
client
|
||||
.publish("departure/outbound/diff", QoS::AtLeastOnce, false, format!("{}", data.outbound_diff).as_bytes())
|
||||
.await?;
|
||||
client
|
||||
.publish("departure/inbound/station", QoS::AtLeastOnce, false, data.inbound_station.as_bytes())
|
||||
.await?;
|
||||
client
|
||||
.publish("departure/inbound/line", QoS::AtLeastOnce, false, data.inbound_line.as_bytes())
|
||||
.await?;
|
||||
client
|
||||
.publish("departure/inbound/diff", QoS::AtLeastOnce, false, format!("{}", data.inbound_diff).as_bytes())
|
||||
.await?;
|
||||
|
||||
@@ -79,8 +79,10 @@ pub struct NextDeparture {
|
||||
pub request_time: i64,
|
||||
pub station_name: String,
|
||||
pub outbound_station: String,
|
||||
pub outbound_line: String,
|
||||
pub outbound_diff: i64,
|
||||
pub inbound_station: String,
|
||||
pub inbound_line: String,
|
||||
pub inbound_diff: i64,
|
||||
pub failure: bool,
|
||||
}
|
||||
@@ -149,8 +151,10 @@ pub fn fetch_data(station_id: u64, debug_print: Option<bool>) -> NextDeparture {
|
||||
let mut return_value = NextDeparture {
|
||||
failure: false,
|
||||
outbound_station: String::from(""),
|
||||
outbound_line: String::from(""),
|
||||
outbound_diff: 10000,
|
||||
inbound_station: String::from(""),
|
||||
inbound_line: String::from(""),
|
||||
inbound_diff: 10000,
|
||||
request_time: seconds as i64,
|
||||
station_name: String::from(""),
|
||||
@@ -204,6 +208,7 @@ pub fn fetch_data(station_id: u64, debug_print: Option<bool>) -> NextDeparture {
|
||||
if stop.destination_label.contains("Rheinau") {
|
||||
if diff < return_value.outbound_diff {
|
||||
return_value.outbound_station = stop.destination_label;
|
||||
return_value.outbound_line = el.line.line_group.label.clone();
|
||||
return_value.outbound_diff = diff;
|
||||
}
|
||||
} else if stop.destination_label.contains("Hochschule")
|
||||
@@ -212,17 +217,20 @@ pub fn fetch_data(station_id: u64, debug_print: Option<bool>) -> NextDeparture {
|
||||
{
|
||||
if diff < return_value.inbound_diff {
|
||||
return_value.inbound_station = stop.destination_label;
|
||||
return_value.inbound_line = el.line.line_group.label.clone();
|
||||
return_value.inbound_diff = diff;
|
||||
}
|
||||
} else if stop.destination_label.contains("Mannheim") {
|
||||
if diff < return_value.inbound_diff {
|
||||
return_value.inbound_station = stop.destination_label;
|
||||
return_value.inbound_line = el.line.line_group.label.clone();
|
||||
return_value.inbound_diff = diff;
|
||||
}
|
||||
} else {
|
||||
// Unkown stations are declared as outbound
|
||||
if diff < return_value.outbound_diff {
|
||||
return_value.outbound_station = stop.destination_label;
|
||||
return_value.outbound_line = el.line.line_group.label.clone();
|
||||
return_value.outbound_diff = diff;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user