Automatic OBD-II Indigo Plugin (discontinued)

Posted on
Thu Nov 16, 2017 5:33 pm
dgarozzo offline
Posts: 132
Joined: Jan 08, 2009

Automatic OBD-II Indigo Plugin (discontinued)

Introduction

This is a plugin to support the Automatic OBD-II device. This is a device that connects to your car's OBD-II port and allows you to gather all kinds of neat information about your car, including when the car starts, when the car is turned off, the current location of the car, even things like if hard acceleration or breaking occur, check engine light notification and information, and even crash detection. It's an amazing device! While the native mobile apps for it do a fantastic job of keeping me aware of what's going on with my cars, I wanted to be able to tie actions from my car into my home automation system. Automatic does have IFTTT support, but I wanted to be able to hook directly into Indigo.

Some usage ideas:

  • If it's between 7am and 8am, Monday to Friday, and the car starts, then send a message to my carpoolers letting them know I'm on my way.
  • If it's after 2pm, the car is currently on Enterprise Drive, and the car starts, then let my wife know I'm on my way home from work.
  • As the car approaches home, announce what street the car is on.
  • And of course, things like changing the lights, the temperature of the house, locking the front door when the car leaves the house, etc.

Installation Details

Dependencies

I have updated the plugin to include all of the dependencies within the plugin itself, so you should not need to install anything other than the plugin itself.

The old info:
This plugin has a dependency on socketIO-client, as well as some other modules. One way to install this is to bring up a Terminal, and type:

sudo -H pip install -U socketIO-client --ignore-installed six
sudo -H pip install -U requests[security] --ignore-installed six
sudo -H pip install --ignore-installed pyOpenSSL --upgrade
sudo -H pip install ndg-httpsclient

If you have both python 2.7 and 3.x installed, then you will need to explicitly install into 2.7 like this:

sudo -H pip2.7 install -U socketIO-client --ignore-installed six

It may make sense to just do both pip and pip2.7 for each of the modules.

I'm not sure if you need to reboot your whole computer or just quit out of Indigo and re-launch it, but one or the other is definitely required in order to get things working.


Automatic API Access

In order to use this plugin, you will need to have API access to Automatic to be able to access your device's data.

Create a developer account at Automatic. Once you have your account, click on Create a New Application. Give it a Name and Description - it really doesn't matter what you put here as you will never be requesting to move "your app" to production mode, but you may want to make it sound official.

You will want to capture your Client ID and your Secret. Those both will need to be entered in the plugin configuration screen.

Change the Event Delivery option to WEBSOCKET. The plugin will make a request to Automatic's API, and will remain connected. When your device has updates, they will be sent to this socket for the plugin to process.

By default, they don't give you access to your current location information, so you need to ask for that access. Click on Request Changes to Scopes. Read the info and click Continue. In the Tell Us About Your App section, tell them something like you are working on a home-automation plugin to be able to do neat things based on the car's current location. Then check off the Access heartbeat location updates in realtime during a drive. (scope:current_location) checkbox, and click on Submit Request.

NOTE: It took them four days to give me access to the current_location information.

Google API Access

In order to use this plugin, you will need to have API access to Google Maps to be able to convert the Automatic location data to human-usable information.

Go to Google Developers Google Maps APIs. Click on Get Started. You will need access to Google Maps Distance Matrix API, as well as Google Maps Geocoding API. You will have one API key to access both of these services, but I think you need to request access to each of them. (maybe not?) For each of them, click on Get a Key, and capture the Google Maps API Key that they give you. You will need this key to configure the Automatic plugin.

Indigo Automatic OBD-II Plugin

You can get the plugin here: https://github.com/dgarozzo/indigo-automatic-obd-ii-plugin. To install it, you should be able to double-click it, and Indigo will take care of the rest.

Plugin Configuration

Once you have installed the plugin, the first thing you will want to do is navigate to menu option Plugins -> Automatic OBD-II -> Configure...

This dialog box is where you will enter in your Client ID and Secret for the Automatic API. After you enter that information, click the Click to Authorize Go button. Assuming you are on the box that you have Indigo running on (and not connected to it remotely), a browser window should appear, prompting you to log in to your Automatic account.

IMPORTANT NOTE: If you haven't yet received approval for access to current_location, leave the current location access checkbox unchecked. After you get the access, re-do the authentication with the checkbox checked so you start receiving current_location information. If you check off this box before you have access, you will get an error.

Once you log in, Automatic will redirect you to another page that will likely be some kind of Page Not Found. The url will start with http://localhost. Copy that entire url and go back to your Indigo Configure Automatic OBD-II dialog box, and paste it in to the Callback URL box. Then click the Go button to obtain your Access Token. You should see a success message appear.

At the bottom of the dialog box is where you need to enter in your Google Maps API Key, as well as your home address.

If you want to fill up your Indigo logs with lots of neat info, check off the Enable Debug Logging checkbox.

Click Save.

Create a Device

From Indigo, create a New Device. Select Type: Automatic OBD-II. Select Model: Automatic OBD-II. The Device Settings dialog box should appear. On this screen, you will be able to choose which Vehicle you want the device to represent. Click Save.

Once you have saved your device, the plugin will retrieve some additional data for that vehicle, and will save that data in it's device states. You can see that info in Indigo on the bottom half of the screen when you select the device.

States include:

ETA - A formatted string containing the time, distance, and estimated time of arrival to home.
currentMilesFromHome - the number of miles from home
location - the street the vehicle is on
previousMilesFromHome - a way to keep track of where the vehicle was when it started a trip; used to determine if the vehicle is approaching home; resets to zero every time it gets "half-way home"
tag - the JSON response from the Automatic API for tag info
trip - the JSON response from the Automatic API for trip info
user - the JSON response from the Automatic API for user info
vehicle - the JSON response from the Automatic API for vehicle info

Triggers

You can create a trigger based on events that are received from Automatic. Click on Create New Trigger, and choose Type: Automatic OBD-II Event.

Choose the Event you want to trigger on: Trip Finished, Ignition On, Ignition Off, Speeding, Hard Break, Hard Acceleration, Check Engine Light On, Check Engine Light Off, Location Updated, Approaching Home.

Once you choose an Event, you will be presented a dialog box asking for which vehicle you want this trigger to be for.

After you set your trigger, you can then invoke the actions that you wish to take.

For example, I have a trigger for when my car's ignition turns ok. The action that I set is of Type: Execute Script, and I have Embedded Python with the following code:

Code: Select all
car = indigo.devices["Automatic OBD Audi"]
indigo.server.speak("The car has started on " + car.states["location"])



Device Actions

I created one device action - it's to refresh the device's states. The states get updated automatically based on information received by the Automatic device, so I don't think this action will be used by anybody. I left it in there for debugging, I guess.

Posted on
Fri Nov 17, 2017 11:33 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Automatic OBD-II Indigo Plugin

Neat. I glanced at the source – so you are able to create Indigo devices that have states for if the car's ignition is on, how many miles from home the car is, etc.? How well does the hardware work?

Image

Posted on
Sat Nov 18, 2017 7:04 am
dgarozzo offline
Posts: 132
Joined: Jan 08, 2009

Re: Automatic OBD-II Indigo Plugin

Basically. I'm currently primarily using the plugin to notify my wife and kids when I'm on my way home. So, I have the computer announce what street the car is on when the car has started, and then again as the car approaches home (heading in the direction of home, and every time it gets 50% closer to home from the last time it was announced). I've been very impressed with the hardware so far.

Posted on
Sat Nov 18, 2017 7:44 am
eme jota ce offline
Posts: 618
Joined: Jul 09, 2009
Location: SW Florida

Re: Automatic OBD-II Indigo Plugin

Thanks!

Very cool. I've been wondering about integrating Automatic into Indigo and look forward to playing with the plugin.

Quick Question ... would this work with more than one car, if each has a separate Automatic module, or does it just work with one Automatic module at a time?

mjc

Posted on
Sat Nov 18, 2017 7:50 am
dgarozzo offline
Posts: 132
Joined: Jan 08, 2009

Re: Automatic OBD-II Indigo Plugin

You will have access to each Automatic module that you have. I have one of each of my cars, and I can set up notifications separately for each one.

As you go through the installation process, please let me know if anything needs to be more clear in my documentation so I can update it for others. Thanks!

Posted on
Sat Nov 18, 2017 8:30 am
eme jota ce offline
Posts: 618
Joined: Jul 09, 2009
Location: SW Florida

Re: Automatic OBD-II Indigo Plugin

Requested the additional Access from Automatic and will await the reply. Requested and have the Google API keys.

When installing the I/O-Socket in terminal I receive errors, is this normal?
Code: Select all
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.[/color]
    Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-CN1Rbi-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'[/color]


Installed Plugin but do not see any way to input the API keys in the plugin.

Posted on
Sat Nov 18, 2017 8:48 am
dgarozzo offline
Posts: 132
Joined: Jan 08, 2009

Re: Automatic OBD-II Indigo Plugin

Not sure about those errors. I'll update the installation instructions shortly to show you where to configure things.

Posted on
Sat Nov 18, 2017 10:13 am
dgarozzo offline
Posts: 132
Joined: Jan 08, 2009

Re: Automatic OBD-II Indigo Plugin

Updated the instructions. Let me know how things go.

Posted on
Sat Nov 18, 2017 3:53 pm
eme jota ce offline
Posts: 618
Joined: Jul 09, 2009
Location: SW Florida

Re: Automatic OBD-II Indigo Plugin

dgarozzo wrote:
Updated the instructions. Let me know how things go.


Thanks. Had assumed there would be a configuration page, but "Plugins -> Automatic OBD-II -> Configure..."doesn't exist. Maybe, it's those IOSocket installation errors, which means I'll need to re-visit some other time, but there are only three options under "Plugins -> Automatic OBD-II -> ...", which are "Disable" "Reload" and "About...."
Last edited by eme jota ce on Sun Nov 19, 2017 7:31 am, edited 1 time in total.

Posted on
Sat Nov 18, 2017 7:19 pm
dgarozzo offline
Posts: 132
Joined: Jan 08, 2009

Re: Automatic OBD-II Indigo Plugin

Weird. Are you on the latest release of Indigo?

What happens if you try to run the install for SocketIO-client again?

Posted on
Fri Nov 24, 2017 9:11 pm
DVDDave offline
Posts: 470
Joined: Feb 26, 2006
Location: San Jose, CA

Re: Automatic OBD-II Indigo Plugin

I'm also not getting a configure option. I get an error when trying to enable the plugin:

Code: Select all
   Starting plugin "Automatic OBD-II 1.0.0" (pid 3656)
   Automatic OBD-II Error          Error in plugin execution InitializeMain:

Traceback (most recent call last):
  File "plugin.py", line 55, in <module>
ImportError: No module named socketIO_client

   Stopping plugin "Automatic OBD-II 1.0.0" (pid 3656)
   Stopped plugin "Automatic OBD-II 1.0.0"


When installing socketIO_client, I had to use SUDO -H but then it seemed to install. Any way of checking this?
Code: Select all
sudo -H pip install -U socketIO-client
Password:
Requirement already up-to-date: socketIO-client in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Requirement already up-to-date: requests>=2.7.0 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from socketIO-client)
Requirement already up-to-date: six in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from socketIO-client)
Requirement already up-to-date: websocket-client in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from socketIO-client)
Requirement already up-to-date: idna<2.7,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from requests>=2.7.0->socketIO-client)
Requirement already up-to-date: chardet<3.1.0,>=3.0.2 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from requests>=2.7.0->socketIO-client)
Requirement already up-to-date: urllib3<1.23,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from requests>=2.7.0->socketIO-client)
Requirement already up-to-date: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from requests>=2.7.0->socketIO-client)


Thanks.

Posted on
Sat Nov 25, 2017 6:58 am
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Re: Automatic OBD-II Indigo Plugin

Very awesome. I've been meaning to take some time to get my two vehicles more integrated and have had the automatic devices for quite some time. My only real complaint is how the app launches and takes over the entire screen when it initially connects.

Posted on
Sat Nov 25, 2017 8:01 am
dgarozzo offline
Posts: 132
Joined: Jan 08, 2009

Re: Automatic OBD-II Indigo Plugin

I'm using Python v2.7.10. That could be your problem. Have you aliased python to the 3.5 version?

Code: Select all
David-J-Garozzos-new-Mac-mini:Users davidgarozzo$ which python
/usr/bin/python
David-J-Garozzos-new-Mac-mini:Users davidgarozzo$ python -V
Python 2.7.10
David-J-Garozzos-new-Mac-mini:Users davidgarozzo$



DVDDave wrote:
I'm also not getting a configure option. I get an error when trying to enable the plugin:

Code: Select all
   Starting plugin "Automatic OBD-II 1.0.0" (pid 3656)
   Automatic OBD-II Error          Error in plugin execution InitializeMain:

Traceback (most recent call last):
  File "plugin.py", line 55, in <module>
ImportError: No module named socketIO_client

   Stopping plugin "Automatic OBD-II 1.0.0" (pid 3656)
   Stopped plugin "Automatic OBD-II 1.0.0"


When installing socketIO_client, I had to use SUDO -H but then it seemed to install. Any way of checking this?
Code: Select all
sudo -H pip install -U socketIO-client
Password:
Requirement already up-to-date: socketIO-client in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Requirement already up-to-date: requests>=2.7.0 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from socketIO-client)
Requirement already up-to-date: six in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from socketIO-client)
Requirement already up-to-date: websocket-client in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from socketIO-client)
Requirement already up-to-date: idna<2.7,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from requests>=2.7.0->socketIO-client)
Requirement already up-to-date: chardet<3.1.0,>=3.0.2 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from requests>=2.7.0->socketIO-client)
Requirement already up-to-date: urllib3<1.23,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from requests>=2.7.0->socketIO-client)
Requirement already up-to-date: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from requests>=2.7.0->socketIO-client)


Thanks.

Posted on
Sat Nov 25, 2017 8:03 am
dgarozzo offline
Posts: 132
Joined: Jan 08, 2009

Re: Automatic OBD-II Indigo Plugin

I'm not following what your complaint is about. What app launches and takes over the entire screen? Is that related to Indigo and the plugin?


Dewster35 wrote:
Very awesome. I've been meaning to take some time to get my two vehicles more integrated and have had the automatic devices for quite some time. My only real complaint is how the app launches and takes over the entire screen when it initially connects.

Posted on
Sat Nov 25, 2017 8:08 am
dgarozzo offline
Posts: 132
Joined: Jan 08, 2009

Re: Automatic OBD-II Indigo Plugin

I reran the install, and I do get the same errors about "six".

eme jota ce wrote:
Requested the additional Access from Automatic and will await the reply. Requested and have the Google API keys.

When installing the I/O-Socket in terminal I receive errors, is this normal?
Code: Select all
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.[/color]
    Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-CN1Rbi-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'[/color]


Installed Plugin but do not see any way to input the API keys in the plugin.

Who is online

Users browsing this forum: No registered users and 1 guest