Add camel config #1
2 changed files with 26 additions and 5 deletions
5
pom.xml
5
pom.xml
|
|
@ -51,6 +51,11 @@
|
|||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-arc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jscience</groupId>
|
||||
<artifactId>jscience</artifactId>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.c4181.camel;
|
|||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.measure.Measure;
|
||||
import javax.measure.quantity.Pressure;
|
||||
|
|
@ -12,24 +13,39 @@ public class CamelConfiguration extends RouteBuilder {
|
|||
|
||||
@Override
|
||||
public void configure() {
|
||||
from("paho-mqtt5:teslamate/cars/1/update_version?brokerUrl={{sys:BROKER_URL}}").process((exchange -> {
|
||||
String updateVersion = exchange.getIn().getBody(String.class);
|
||||
exchange.getIn().setBody("New Update available. Version: " + updateVersion);
|
||||
from("paho-mqtt5:teslamate/cars/1/update_version?brokerUrl={{sys:BROKER_URL}}")
|
||||
.filter(exchange -> StringUtils.isNotBlank(exchange.getIn().getBody(String.class)))
|
||||
.process((exchange -> {
|
||||
String updateVersion = exchange.getIn().getBody(String.class);
|
||||
|
||||
log.info("New Version {} found. Sending to telegram", updateVersion);
|
||||
}))
|
||||
if (StringUtils.isNotBlank(updateVersion)) {
|
||||
exchange.getIn().setBody("New Update available. Version: " + updateVersion);
|
||||
} else {
|
||||
exchange.setRouteStop(true);
|
||||
}
|
||||
|
||||
log.info("New Version {} found. Sending to telegram", updateVersion);
|
||||
}))
|
||||
.to("telegram:bots?authorizationToken={{sys:TELEGRAM_BOT_ID}}&chatId={{sys:CHAT_ID}}");
|
||||
|
||||
from("paho-mqtt5:teslamate/cars/1/tpms_pressure_fl?brokerUrl={{sys:BROKER_URL}}").process((exchange -> checkTirePressure(exchange, "Front left")))
|
||||
.throttle(1).rejectExecution(true)
|
||||
.timePeriodMillis(900000) // 15 minutes
|
||||
.to("telegram:bots?authorizationToken={{sys:TELEGRAM_BOT_ID}}&chatId={{sys:CHAT_ID}}");
|
||||
|
||||
from("paho-mqtt5:teslamate/cars/1/tpms_pressure_fr?brokerUrl={{sys:BROKER_URL}}").process((exchange -> checkTirePressure(exchange, "Front right")))
|
||||
.throttle(1).rejectExecution(true)
|
||||
.timePeriodMillis(900000) // 15 minutes
|
||||
.to("telegram:bots?authorizationToken={{sys:TELEGRAM_BOT_ID}}&chatId={{sys:CHAT_ID}}");
|
||||
|
||||
from("paho-mqtt5:teslamate/cars/1/tpms_pressure_rl?brokerUrl={{sys:BROKER_URL}}").process((exchange -> checkTirePressure(exchange, "Back left")))
|
||||
.throttle(1).rejectExecution(true)
|
||||
.timePeriodMillis(900000) // 15 minutes
|
||||
.to("telegram:bots?authorizationToken={{sys:TELEGRAM_BOT_ID}}&chatId={{sys:CHAT_ID}}");
|
||||
|
||||
from("paho-mqtt5:teslamate/cars/1/tpms_pressure_rr?brokerUrl={{sys:BROKER_URL}}").process((exchange -> checkTirePressure(exchange, "Back right")))
|
||||
.throttle(1).rejectExecution(true)
|
||||
.timePeriodMillis(900000) // 15 minutes
|
||||
.to("telegram:bots?authorizationToken={{sys:TELEGRAM_BOT_ID}}&chatId={{sys:CHAT_ID}}");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue