How to Dev Portal Part 2: Rules, Subscriptions, and DTCs
This is the second post in our series "How to Dev Portal". Check out the entire series here.
What we'll cover
In this post, we'll examine the Rule and Subscription interface, how we can use Rule Service in the context of the Developer Portal, and finally, we'll take a look at how DTC codes are exposed for vehicles that your app has access to.
Events, Rules, & Subscriptions
Events are created for every critical action made by a vehicle. For example, there are startup
and shutdown
events that are triggered whenever a vehicle is turned on or off. You can find a full list of event types here.
You can find events by vehicle by clicking into Devices > Vehicle > Events.
The Vinli platform automatically creates events for the super important actions that most developers were use. But you can also specify criteria for your own Events. This is done using Rules Service.
You can create geospacial rules, which are based on the vehicles coordinates entering or leaving a geospacial region that you've define. You can also define parametric rules, which are based on OBDII parameters passing thresholds that you've defined.
The Developer Portal makes it very easy to experiment with rules (at least for a single vehicle). Use the GUI to define parametric criteria, or draw a polygon on the map.
Subscriptions
This all becomes very powerful when we add Subscriptions to the mix. When you subscribe to an event, you'll get a notification payload delivered to a destination you define.
Creating a Subscription is easy.
POST https://events.vin.li/api/v1/devices/de01abb1-453d-4293-831a-f0d804b48fdf/subscriptions
Accept: application/json
Content-Type: application/json
{
"subscription" : {
"eventType" : "startup",
"url": "https://myapp.com/notifications"
}
}
** Notification payloads will be different based on the type of event, but you get the idea... **
Within each Event, you'll get a complete list of Notifications for that event.
Drill into an individual notification to reveal it's payload.
DTCs
DTCs (diagnostic trouble codes) are critical for repairs, maintenance and vehicle service. We've taken the mystery out of the check engine light, by allowing developers like you to decipher these codes and bring peace of mind to your users!
Within the Vinli Developer Portal, DTCs will pop up in 2 places:
1) As Events
The platform will create an event any time a DTC turns on or off. You can subscribe to these events using the event types dtc-on
and/or dtc-off
.
2) DTC Lookup Utility
Most app developers aren't auto mechanics (some are though, which is awesome!) Which is why we added the DTC Lookup utility to the dev portal. We wanted to make it easy for you to decipher these codes, so that you can give users the best possible information whenever a specific code surfaces.
Just pop in a code, and we'll pull up as many details as we can to help make sense of things.