Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save illegalbyte/a4197e368a46db59228dc60439a0c738 to your computer and use it in GitHub Desktop.
Save illegalbyte/a4197e368a46db59228dc60439a0c738 to your computer and use it in GitHub Desktop.

Kogan Smarter Home & Homekit (via Homebridge)

KOGAN smarter home products use Tuya protocols except using a slightly different url and device domain. This means you can use the existing homebridge-tuya plugin for homebridge except using a different process to obtain the device id and keys.

Pre-requisites: First, Install the Kogan Smarter Home app on your idevice then add and configure all your kogan devices. (DO THIS FIRST!).

I am also assuming you already have homebridge setup and running. If not, I strongly reccomend you install homebridge via docker such as https://github.com/oznu/docker-homebridge (Makes it easy to get up and running)

Broken Advice as of 2022: Then:
  1. Visit https://github.com/codetheweb/homebridge-tuya and install the tuya plugin to homebridge using npm i homebridge-tuya (you can put this in your startup.sh file if using docker or else add -g if you're not using docker)

add the new platform to your config.json:

{
  "platform": "TuyaPlatform",
  "name": "TuyaPlatform",
  "devices": [

  ]
}

Devices are blank for now, lets find them!

  1. You can scape ID and KEYs from kogan products such as the Smart energy plugs by running Anyproxy on your computer and then opening the Smarter Home app. Anyproxy will capture HTTPS queries which include device id and passwords.

Install anyproxy from here: https://github.com/alibaba/anyproxy and ensure you add the proxy certificate to your iPhone and setup the proxy. Run using anyproxy --intercept --ws-intercept

  1. Open the Smarter Home app. Visit the anyproxy dashboard url on your laptop and check out the queries captured via anyproxy.

You will get a few https queries which include the device id and keys.

Sample:

{
  "result": [       
    {
      "result": [
        {
          "devId": "XXXXXXXX HERE IS YOUR DEVICE ID XXXXXXXXX",
          "dpMaxTime": 1542869607548,
          "virtual": false,
          "productId": "<Ignore this>",
          "dps": { "1": true, "2": 0, "3": 0, "4": 0, "5": 0, "6": 0 },
          "activeTime": 1542868361,
          "ip": "xxx",
          "lon": "xxx",
          "moduleMap": {
            "wifi": {
              "upgradeStatus": 0,
             ...
          },
          "uuid": "XXX HERE IS THE DEVICE ID AGAIN XXXX",
          "name": "Toaster",
          "isShare": false,
          "timezoneId": "xxx",
          "iconUrl": "https://images.tuyaus.com/smart/icon/1536896591itvclcq5ns_0.png",
          "lat": "-37.822664",
          "runtimeEnv": "prod",
          "localKey": "XXXX HERE IS YOUR KEY XXX"
        },
        (more devices listed here)

Write down the DEVICE ID and KEYS from the devices you wish to configure. Above is an example of my toaster wall outlet.

Now, add all your devices to the config.json you started earlier:

{
  "platform": "TuyaPlatform",
  "name": "TuyaPlatform",
  "devices": [
    {
      "name": "Tuya Outlet Device 1",
      "id": "XXX PUT THE DEVICE ID HERE",
      "key": "XXXXX PUT THE DEVICE KEY HERE XXXXX"
    },
    {
      "name": "Tuya Dimmer Switch Device 2",
      "id": "...",
      "key": "...",
      "type": "dimmer"
    }
  ]
}
  1. Restart your homebridge server and the devices should appear in homekit!

Troubleshooting:

  1. Kill the home app on your iphone
  2. Restart your iphone
  3. Restart your apple tv
  4. Restart your homebridge server sudo docker restart homebridge

Additional Help 2022

I could not get the original advice to work so I figured a more robust solution which doesn't require dissecting HTTP traffic from individual Tuya (Kogan) lights. Before following the below tutorial, reset your lights (off, on, off, on, off, on) and add them to the official Tuya iOS / Android app (identical setup process to the Kogan Smarter Home app). Then you can follow the tutorial below:

Excellent Youtube Tutorial

You will want to setup a Tuya developer account, and use your Tuya App to automatically add all your devices to this account. You can then use the official Tuya Homebridge Plugin and configure your lights this way. Remember that the email information for the plugin is your Tuya app login (not your developer account), even though you are entering API keys obtained from your Tuya developer account.

For any new devices you buy (or accidentally reset lights) they can simply be re-added via the Tuya app, and they will appear in HomeKit – albeit you will have to SSH into your server and run sudo docker restart homebridge for the plugin to query the API and identify the new devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment