Reverse Engineering the iHome iSP5 SmartPlug Communications

I got a couple of the iHome iSP5 Smart Plugs and wanted to integrate them into OpenHAB. This is just some rough digging I have done so far in the communications between the phone app and their server. Part 2, if I get to it will look at the communications between the server and the plug. This will be much harder as I will need to find a way to become a MITM for the SSL communications.

Maybe this will help someone create an openHAB binding as I have never really worked with OpenHAB.

The following is all done using CURL.

Get Your Authorization ID

To start off you need to send a request to their server with your login information to get the authorization ID to communicate with the device server.

curl -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -X POST https://www.ihomeaudio.com/api/v3/login/ -d 'password=yourPassword&email=email%40domain.com'

The response to this will contain 2 important fields:

  • evrythng_user_id
  • evrythng_api_key

The evrythng_user_id isnt really useful but its nice to know. The evrythng_api_key is really where the magic happens.

Get Your Device ID(s)

Using the evrythng_api_key you can then send a packet to query all the things you have in your account. Replace evrythng_api_key with your actual value in the Authorization field.

curl -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -H "Authorization: evrythng_api_key" https://api.evrythng.com/thngs?perPage=100&sortOrder=ASCENDING

This then returns a large JSON response with all your devices.

Most of these fields can then be queried later but a few are really the most important:

  • id (Unique device ID)
  • currentpowerstate1 (1=On, 0=Off)
  • outletinuse1 (1=yes, 0=no)
  • ~connected (true=Connected, false=Disconnected)

These fields are pretty self-explanatory. currentpowerstate1 is if the switch is on/off, outletinuse1 is if there is something actually plugged into it and, ~connected is if the device is connected to the internet/accessible.

Get Device Properties

To query the device for a specific property use a GET as follows and remember to replace id in the URL with the id you found in the last command:

curl -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: evrythng_api_key" https://api.evrythng.com/thngs/id/properties/~connected?perPage=100&sortOrder=ASCENDING

Replace the last part of the URL with the property you want to query.

This query actually returns a few values so you may want to limit it to 1 instead of 100 to get the last result. I did also notice that the sortOrder didn’t appear to do anything but that may need to be experimented with a bit more.

Another example to get powerstate1

curl -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: evrythng_api_key" https://api.evrythng.com/thngs/id/properties/currentpowerstate1?perPage=1&sortOrder=ASCENDING

Setting A Property

To actually set a property value it’s basically the same except sending a PUT instead of a GET.

The following will turn the switch off:
curl -H "Authorization: evrythng_api_key" -H "Content-Type: application/json" -H "Accept: application/json" -H "Content-Length: 15" -X PUT https://api.evrythng.com/thngs/id/properties/targetpowerstate1 -d '[{"value":"0"}]'

Ya, so that’s really all there is to it. I’m sure a binding would be pretty simple for someone.

Edit: So the communications between the server and the device are SSL encrypted so I dont have a way to see what its doing. I ran TCPdump on my router and I can see packets but nothing I can work with. Not sure if anyone has any ideas.

2 Reader Comments

netstat

Hi,
First, thanks for doing the work to give me a bit of a jumpstart on my project to get my iHome outlets working with IFTTT.

I have tried using your format for setting a property to turn an outlet on or off. I am not getting a working result though. The evrythng API does return a positive result, but the actual power state of the outlet remains unaltered.

What I did notice though, is that the iHome Control Android app does reflect the change in powerstate, regardless of the actual status of the outlet, seemingly just fooling the app into thinking an outlet is on/off.

Would you possibly have any more information on this, or be able to point me at some of your sources for your research into this?

Thanks

Leave a Comment