Merge pull request #5484 from hypoclone/master

Add quantity of fuel drop/increase in notification
This commit is contained in:
Anton Tananaev 2024-12-19 15:11:10 -08:00 committed by GitHub
commit cfefe03ff1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 2 deletions

View File

@ -55,13 +55,19 @@ public class FuelEventHandler extends BaseEventHandler {
double threshold = AttributeUtil.lookup(
cacheManager, Keys.EVENT_FUEL_INCREASE_THRESHOLD, position.getDeviceId());
if (threshold > 0 && change >= threshold) {
callback.eventDetected(new Event(Event.TYPE_DEVICE_FUEL_INCREASE, position));
Event event = new Event(Event.TYPE_DEVICE_FUEL_INCREASE, position);
event.set("before", before);
event.set("after", after);
callback.eventDetected(event);
}
} else if (change < 0) {
double threshold = AttributeUtil.lookup(
cacheManager, Keys.EVENT_FUEL_DROP_THRESHOLD, position.getDeviceId());
if (threshold > 0 && Math.abs(change) >= threshold) {
callback.eventDetected(new Event(Event.TYPE_DEVICE_FUEL_DROP, position));
Event event = new Event(Event.TYPE_DEVICE_FUEL_DROP, position);
event.set("before", before);
event.set("after", after);
callback.eventDetected(event);
}
}
}

View File

@ -4,6 +4,8 @@
<body>
Device: $device.name<br>
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.eventTime, $locale, $timezone)<br>
Quantity Before: $event.attributes.before<br>
Quantity After: $event.attributes.after<br>
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
<br>
<a href="$webUrl/settings/notifications?token=$token">Unsubscribe</a>

View File

@ -4,6 +4,8 @@
<body>
Device: $device.name<br>
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.eventTime, $locale, $timezone)<br>
Quantity Before: $event.attributes.before<br>
Quantity After: $event.attributes.after<br>
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
<br>
<a href="$webUrl/settings/notifications?token=$token">Unsubscribe</a>