My Automatic Device

The Unofficial SmartThings Blog
Jump to: navigation, search


Automatic: Connected Car Adapter, Engine Diagnostics, And Crash Detection, Compatible with Amazon Echo

Automatic: Connected Car Adapter, Engine Diagnostics, And Crash Detection, Compatible with Amazon Echo

Brand:Automatic

Models: Pro, Lite,Gen1, Gen2, Pro

Type: Connected Car

Protocol: Bluetooth

Link to automatic website [1]

Device Type Author:Yves Racine

ST Community handle http://community.smartthings.com/users/yvesracine/activity

Company Link: http://www.ecomatiqhomes.com#!home/mainPage



Contents

Notes to MyAutomatic Device Users - Contribution is now required

MyAutomatic device has required hundreds of hours of development & testing efforts to build; a mandatory contribution is now required.


To download the code, go to

http://www.ecomatiqhomes.com/store

Technical support packages are also available.


If you want to contribute more, here is the paypal link below.

https://paypal.me/ecomatiqhomes

Prerequisites

  • Automatic device operational & connected to Automatic.
  • Basic information about your vehicle entered at the Automatic Portal or in the Automatic app

(e.g. display name, model, submodel, color, etc.)

  • SmartThings hub fully operational

Information

Functionality: The Automatic car adapter plugs into just about any car’s standard diagnostics (OBD-II) port. It unlocks the data in your car’s on-board computer and connects it to your phone via Bluetooth wireless.

When you drive, the app wirelessly pairs with the adapter via Bluetooth and securely stores each trip in the cloud. The app offers features every driver should have like engine diagnostics, parked car locator, and emergency crash response. All without opening the app.

  • Support of US and metric scale systems (gallons/liters, miles/km, etc)

Here is the complete list of commands:

   command "getCurrentUserInfo"
   command "getTrips"
   command "getVehicles"
   command "generateVehicleEvents"
   command "generateYesterdayTripStats"
   command "generateWeeklyTripStats"
   command "generateMonthlyTripStats"

Look & Feel

AutomaticCarP1-Medium.jpg AutomaticCarP3-Medium.jpg AutomaticCarP2-Medium.jpg MyAutomatic MonthlyStats.jpg MyAutomatic Graph.jpg MyAutomatic Graph P2.jpg

The button is used to change the view window (past week Vs. last 24 hrs).

UI Fields

  • Today AvgTripConsumption in miles/US gallons (or km per liter)
  • Today AvgTripDistance in miles (or km)
  • Today AvgTripDuration in minutes
  • Today totalDistance
  • Today AvgTripFuelVolume in US gallons (or Liters)
  • Today totalFuelVolume
  • Today totalFuelCost
  • Today totalDuration in minutes
  • Today totalNbTrip
  • Today totalHardAcceleration
  • Today totalHardBrakes
  • Today AvgScoreSpeeding
  • Today AvgScoreEvents
  • Yesterday AvgTripConsumption in miles/US gallons (or km per liter)
  • Yesterday AvgTripDistance in miles (or km)
  • Yesterday AvgTripDuration in minutes
  • Yesterday totalDistance
  • Yesterday AvgTripFuelVolume in US gallons (or Liters)
  • Yesterday totalFuelVolume
  • Yesterday totalFuelCost
  • Yesterday totalDuration in minutes
  • Yesterday totalNbTrip
  • Yesterday totalHardAcceleration
  • Yesterday totalHardBrakes
  • Yesterday AvgScoreSpeeding
  • Yesterday AvgScoreEvents
  • Weekly AvgTripDuration in minutes
  • Weekly totalDistance
  • Weekly AvgTripFuelVolume in US gallons (or Liters)
  • Weekly totalFuelVolume
  • Weekly totalFuelCost
  • Weekly totalDuration in minutes
  • Weekly totalNbTrip
  • Weekly totalHardAcceleration
  • Weekly totalHardBrakes
  • Weekly AvgScoreSpeeding
  • Weekly AvgScoreEvents
  • Monthly AvgTripDuration in minutes
  • Monthly totalDistance
  • Monthly AvgTripFuelVolume in US gallons (or Liters)
  • Monthly totalFuelVolume
  • Monthly totalFuelCost
  • Monthly totalDuration in minutes
  • Monthly totalNbTrip
  • Monthly totalHardAcceleration
  • Monthly totalHardBrakes
  • Monthly AvgScoreSpeeding
  • Monthly AvgScoreEvents

Events for a given trip are generated for subscription in smartapps

  • eventVehicleId
  • eventType, examples: Trip Completed, Hard Brake, Hard Acceleration, Speeding
  • eventTripId
  • eventTripDistance
  • eventTripAvgFuelConsumption
  • eventTripStartLocation:
  • eventTripEndLocation:
  • eventTripStartAddress
  • eventTripEndAddress
  • eventTripSpeed
  • eventTripGForce
  • eventTripLocationLat
  • eventTripLocationLon
  • eventTripStartedAt
  • eventTripEndedAt


Instructions for My Automatic Device installation (readme): http://github.com/yracine/device-type.myautomatic/blob/master/README.md

Known issues

.................................................................................................................................


1. Automatic does not support wildcard URL redirection

.................................................................................................................................

Automatic does not presently support wildcard URL redirection which is required to complete the oAuth authorization flow with many SmartThings users.

A ST user would then need to start the oAuth authorization flow, copy and paste the hard coded redirect URL to the Automatic developer portal to complete the flow.

You also need to copy and paste your public and private keys generated at the Automatic portal in the MyAutomaticServiceMgr file as follows:

Examples of keys, not valid at Automatic:

def getSmartThingsClientId() { "kjPlS3AAQtaUGlmB30IU9g" }

def getSmartThingsPrivateKey() { "6Qg0niXeQDSk-dkfU475og" }

See the readme file at github for more details.

http://github.com/yracine/device-type.myautomatic/blob/master/README.md


.................................................................................................................................

2. SmartThings does not support websockets for geofencing

.................................................................................................................................

Automatic only supports geofencing with websockets, and sadly ST does not support websockets at this time.


.................................................................................................................................

3. For international users, address info is no longer available

.................................................................................................................................

Automatic changed its map provider in July 2017, and since then, there is no address info (start & end addresses) provided for trips outside of the US.

This issue has been reported many times to Automatic as per their community forum, but there is no fix in sight:

http://community.automatic.com/automatic/topics/does-not-recognize-street-names-unknown-address

This will not affect My Automatic tiles as the addresses are not shown in the UI, but it will affect presence detection for international users.

.................................................................................................................................

** NEW ** Since V2.6, I've included the option to insert your GOOGLE KEY for the Location APIs.

- Insert your GOOGLE API Key at the end of MyServiceAutomaticMgr file

Refer to the following instructions for more details:

// To be populated with your own Google API key for better presence detection

// Go to https://developers.google.com/maps/documentation/geocoding/get-api-key

// Make sure that your key is registered for your project at https://console.developers.google.com/apis/credentials

def get_GOOGLE_LOCATION_API_KEY() { return "Insert your GOOGLE Key Here!" }

Troubleshooting

Here are some typical troubleshooting cases explained below. For your specific use cases, you may want to contact the author (there may be some support fees to be applied).

.................................................................................................................................

Issue #1: I don't know how to create a custom device

.................................................................................................................................

See the explanations of a fellow community member here:

http://community.smartthings.com/t/faq-an-overview-of-using-custom-code-in-smartthings/16772

or

http://thingsthataresmart.wiki/index.php?title=Using_Custom_Code

.................................................................................................................................

Issue #2: I created the device handler and MyAutomaticerviceMgr in the IDE, but I don't know where to execute it

.................................................................................................................................


For the initial setup, under the ST app, click on the Marketspace item in the bottom menu, and then, on the smartapps link and finally, MyApps (last item in the list).

If you still do not see your smartapp, please make sure that you have published it in the IDE!

For any subsequent execution, under the ST app, click on the "hamburger" menu in the upper right section and then, Smartapps. You should see the smartapp in the list.'



.................................................................................................................................

Issue #3: I executed MyAutomaticSeviceMgr smartapp, but the 3rd page (after doing the login, and pressing Next) is blank

.................................................................................................................................

If you get a blank screen after pressing 'Next or you get the following error: " Error - bad state. Unable to complete page configuration" or any other ST errors, please check that you've enabled oAuth as specified in step 2f) in the readme.

https://github.com/yracine/device-type.myautomatic/blob/master/README.md

Refer to MyAutomaticServiceMgr's installation steps for more details:

http://thingsthataresmart.wiki/index.php?title=MyAutomaticServiceMgr#Issue_.231:_I_don.27t_know_how_to_create_a_custom_smartapp

.................................................................................................................................

Issue #4: My Automatic device is off by 'x' units with the Automatic portal

.................................................................................................................................

First try to refresh the UI by pressing the 'refresh' tile. The ST UI does not allow automatic refresh at the moment.


.................................................................................................................................

Issue #5: I want to disable any notifications from MyAutomaticServiceMgr

.................................................................................................................................

Go to the smartapp's last page, and answer 'no' to the following question:

Send a push notification?"''

Be aware that you won't be notified of any connection issues.

.................................................................................................................................

Issue #6: "An unexpected error has occurred" or 'deleteObserver onError: %s' messages in MyAutomaticServerMgr when I press 'Remove'

.................................................................................................................................


There are 2 ways now to correct this ST issue. The 1st way is the traditional way:

1) You need first to remove your Automatic device from all the smartapps (like any ST connected device) as MyAutomaticServiceMgr will not uninstall w/o doing this step. MyAutomaticServiceMgr is the Service Manager for MyAutomatic Device, so uninstalling the smartapp means that the device will be deleted.

2) You can also 'force' delete any smartapp:

Go to https://graph.api.smartthings.com/location/list

> Click on «smartapps» for your location and then «Edit»

You should now have an uninstall option for your smartapps. This is a recent ST addition

.................................................................................................................................

Issue #7: I want to get more tracing in the IDE

.................................................................................................................................

Just update the device preferences, and edit the trace parameter, see step 8 in the readme

http://github.com/yracine/device-type.myautomatic/blob/master/README.md

Do not forget to remove the trace (leave the parameter blank) after your debugging session as this setting may impact performance.

P.S. You can also edit the device's preferences under the ST app by clicking on its 'gear' button.

.................................................................................................................................

Issue #8: I want to upgrade the code but I don't know how.

.................................................................................................................................

Most of the time (unless specified otherwise), you just need to copy and paste the My Automatic Device's code from the zip code, and save & publish.

The same approach should be used for the smartapps.

For more details, please follow the instructions provided at:

http://github.com/yracine/device-type.myautomatic/blob/master/README.md


.................................................................................................................................

Issue #9: java.util.concurrent.TimeoutException: Execution time exceeded 'x' app execution seconds

.................................................................................................................................

ST has introduced some generic rate limiting rules for all smartapps and device handlers.

For cloud-to-cloud integration, these rate limiting constraints are sometimes too low (due to network latency, servers involved, etc.), and this exception can be raised from time to time. There are some threads about it in the ST community forum:

http://community.smartthings.com/t/rate-limiting-too-restrictive-max-execution-time-exceptions/17985

http://community.smartthings.com/t/execution-times-increasing/19979

http://community.smartthings.com/t/unschedule-api-execution-time-too-long/11232


.................................................................................................................................

Issue #10: I do not know how to set up the Automatic device to process the real time events coming from Automatic

.................................................................................................................................


a) Go to https://developer.automatic.com/my-apps and log in using your credentials

b) At the Automatic Developer portal, copy the OAuth Redirect URL field used to authenticate with SmartThings

The field should be similar to:

https://graph.api.smartthings.com/api/token/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/smartapps/installations/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/swapToken

c) Paste the redirect URL to the Automatic Developer portal under Webhook URL field

d) Substitute "swapToken" by "procEvent" in the field

The field value should then look like:

https://graph.api.smartthings.com/api/token/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/smartapps/installations/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/procEvent

e) Make sure that the Event Delivery Preference field is set to "WEBHOOK"

f) Save the URL value at the Automatic Developer Portal


.................................................................................................................................

Issue #11: How can I set up the Automatic device for presence detection

.................................................................................................................................

Based on the Automatic backend, be aware that presence detection can now be done only in the US. Refer to the following for more details.

Since V2.6, for better presence detection, you can set up the Google location API key in the MyAutomaticServiceMgr file (even if you're outside of the US).

http://thingsthataresmart.wiki/index.php?title=My_Automatic_Device#3._For_international_users.2C_address_info_is_no_longer_available


a) You need to set up the RT events processing as specified in step 10 (see above)

b) You need to set up your device's homeAddress preference field

- Go to https://graph.api.smartthings.com/device/list

- Edit the Automatic device's preferences

- Set your the homeAddress to the minimum information required to compare your home address with a trip's end address

- Save the preferences

Usually, a zip/postal code or a street name should suffice


c) Make sure that your homeAddress is exactly contained within the eventTripEndAddress value after completing a trip back home.


- Go to https://graph.api.smartthings.com/device/list

- Show the device's attributes by clicking on the Automatic device

- Look for the value of eventTripEndAddress in a "trip:finished" event: a slight variation, (ex. "Lane" instead of "Ln" or "Street" instead of "St") could make the comparison returns different results (see image below)

- You can copy and paste part of the eventTripEndAddress's value to make sure there is homeAddress value match''

Example, you can copy & paste your Street name and City as the homeAddress. This is the minimum information required for a match.


IDE-AUTOMATIC-CompletedRT-TripEvent.PNG


For bluetooth-enabled Automatic models only (not the Automatic Pro which has embedded 3G connection), in order to get successful presence detection using MyAutomatic device, also make sure of the following:

d) You have your phone with you while driving your car

e) Your Automatic device is connected to your phone (you may have to toggle your bluetooth Off/On)

I usually check every time (right after Ignition) in the Automatic app to make sure that MyAutomatic is properly connected to my phone. If not, I click on the Connection Troubleshooting/"Retry Connection" in the Automatic app. Sometimes, I have to toggle the bluetooth On/Off to ensure that my Automatic is connected to my phone.

f) You have the RT events processing with SmartThings as specified above in a).

g) On the road, your mobile phone's cellular data should be enabled so that the RT events are transmitted right away from your phone to the Automatic backend for processing.

Some delays may be introduced if your have poor cellular data connection during your trip.


.................................................................................................................................

Issue #12: com.datastax.driver.core.exceptions.ReadTimeoutException

.................................................................................................................................

These exceptions are thrown by the ST backend from time to time. I've been told that ST is working on it. This is not a specific issue with my code.

https://community.smartthings.com/t/cassandra-timeout-during-read-query/46227/3

...............................................................................................................................

Issue #13: I want to change all scales to the metric system.

.................................................................................................................................


The temperature scale needs to be changed for your ST account under the ST Mobile app, so that all your ST devices will be in the metric system.

Press the "hamburger" menu (upper left), and then the "gear" icon. You'll find the option to change the temperature scale there and press "save".

At the next "refresh", My Automatic Device will display the values in the metric system.


.................................................................................................................................

Issue #14: I have an unexpected error after login in MyAutomaticServiceMgr

.................................................................................................................................

If you get an unexpected error after the Automatic Login and Authorize pages, please verify that your base URL and oAuth Redirect URL match. If they don't match, you won't be able to save the full redirect oAuth URL correctly.

Refer to the steps 5e) through 5h) at the readme.

https://github.com/yracine/device-type.myautomatic/blob/master/README.md

.................................................................................................................................