Mi(Xiaomi) Smart home bindings?

@dimalo:
multicast is enabled everywhere I can see, the Mi gateway receives its IP over DHCP from the orangepi box which is running the opehnab2, the openhab2 server is in the same network as the xiaomi gateway.

I can enable logging but I wonder what I should be doing to get the setup working as expected so it would make sense to record the log to see what went wrong. Literally, I deleted all xiaomi devices, restarted the service, enable all DEBUG events, went to “inbox” and tried scanning Xiaomi binding - and it found nothing. The log is there: https://pastebin.com/YbshEnya
This does not give me a clue of what to expect really, what should have happened? Or I still have to add the bridge manually (as it is the only thing which takes an IP) and the gateway should pop up altogether with all the switches and sensors?

upd: in parallel I am also playing with domoticz, that thing does not autofind the gateway but I can add by IP+key (just like openhab does for “xiaomi bridge”) and then I can control all the sensors + sounds + lights, i.e. everything the gateway provides - these additional capabilities come as discovered switches. OpenHAB does something differently but what…

Try disabling firewall. Xiaomi MiHome Gateway not responding (Solved)

@kyomar tried that, no difference. Can you please give a hint how it is supposed to work?

Hi,

upon gearbest shopping i stumbled over the Xiaomi Thermostat Accuracy Temperature Humidity Monitor:

It seems to be basically the temperature sensor with a LCD display for displaying current temperature and humidity.

Does someone have some experience with it already? Is it supported by the binding?

Regards
Simon

You need this lamp as bluetooth gateway:

The mi home gateway is only zigbee, no bluetooth.

look here

Just follow the link I have provided, everything I know is explained there. Hint: first you have to completely turn off firewall, after the gateway has been detected you can setup the firewall as described.

Hello! I have a problem with connection xiaomi to openhab.
I add gateway and set the key, than I see all sub-items. I see them online and can see information from gateway light sensor, but if I try to send command I got the error
Did anybody face this problem?

21:57:05.152 [ERROR] [rnal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.mihome.handler.XiaomiAqaraActorSwitch2Handler@6a0d5e6a': null
java.lang.NullPointerException: null
        at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:69) [202:org.openhab.binding.mihome:2.2.0]
        at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:42) [202:org.openhab.binding.mihome:2.2.0]
        at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.getEncryptedKey(XiaomiBridgeHandler.java:291) [202:org.openhab.binding.mihome:2.2.0]
        at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.createDataJsonString(XiaomiBridgeHandler.java:277) [202:org.openhab.binding.mihome:2.2.0]
        at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.writeToDevice(XiaomiBridgeHandler.java:268) [202:org.openhab.binding.mihome:2.2.0]
        at org.openhab.binding.mihome.handler.XiaomiAqaraActorSwitch2Handler.execute(XiaomiAqaraActorSwitch2Handler.java:48) [202:org.openhab.binding.mihome:2.2.0]
        at org.openhab.binding.mihome.handler.XiaomiDeviceBaseHandler.handleCommand(XiaomiDeviceBaseHandler.java:104) [202:org.openhab.binding.mihome:2.2.0]
        at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [109:org.eclipse.smarthome.core:0.10.0.b1]
        at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [109:org.eclipse.smarthome.core:0.10.0.b1]
        at com.sun.proxy.$Proxy138.handleCommand(Unknown Source) [202:org.openhab.binding.mihome:2.2.0]
        at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:72) [116:org.eclipse.smarthome.core.thing:0.10.0.b1]
        at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [116:org.eclipse.smarthome.core.thing:0.10.0.b1]
        at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [109:org.eclipse.smarthome.core:0.10.0.b1]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [109:org.eclipse.smarthome.core:0.10.0.b1]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:?]
        at java.lang.Thread.run(Thread.java:745) [?:?]

Can you post your things, items & rules?

I configured it with Paper UI. How can I export it?

I found this
userdata\jsondb
org.eclipse.smarthome.core.items.Item.json

{
  "XiaomiMiSmartHomeGateway_Color": {
    "class": "org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem",
    "value": {
      "groupNames": [],
      "itemType": "Color",
      "tags": [],
      "label": "Color",
      "category": "ColorLight"
    }
  },
  "XiaomiAqaraWallSwitch2Button_Button1s": {
    "class": "org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem",
    "value": {
      "groupNames": [],
      "itemType": "Switch",
      "tags": [],
      "label": "Button 1s"
    }
  },
  "XiaomiMiSmartHomeGateway_Illumination": {
    "class": "org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem",
    "value": {
      "groupNames": [],
      "itemType": "Number",
      "tags": [],
      "label": "Illumination"
    }
  },
  "XiaomiAqaraWallSwitch2Button_Button1": {
    "class": "org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem",
    "value": {
      "groupNames": [],
      "itemType": "Switch",
      "tags": [],
      "label": "Button 1"
    }
  },
  "XiaomiMiSmartHomeGateway_Brightness": {
    "class": "org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem",
    "value": {
      "groupNames": [],
      "itemType": "Dimmer",
      "tags": [],
      "label": "Brightness",
      "category": "DimmableLight"
    }
  }
}

org.eclipse.smarthome.core.thing.Thing.json

{
  "mihome:ctrl_neutral2:158d00016d934d": {
    "class": "org.eclipse.smarthome.core.thing.internal.ThingImpl",
    "value": {
      "label": "Xiaomi Aqara Wall Switch 2 Button",
      "bridgeUID": {
        "segments": [
          "mihome",
          "bridge",
          "34ce0088dc70"
        ]
      },
      "channels": [
        {
          "acceptedItemType": "Switch",
          "kind": "STATE",
          "uid": {
            "segments": [
              "mihome",
              "ctrl_neutral2",
              "158d00016d934d",
              "ch1"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "mihome",
              "sw-btn"
            ]
          },
          "label": "Button 1",
          "description": "The first pushbutton on the switch.",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        },
        {
          "acceptedItemType": "Switch",
          "kind": "STATE",
          "uid": {
            "segments": [
              "mihome",
              "ctrl_neutral2",
              "158d00016d934d",
              "ch2"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "mihome",
              "sw-btn"
            ]
          },
          "label": "Button 2",
          "description": "The second pushbutton on the switch.",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        }
      ],
      "configuration": {
        "properties": {
          "itemId": "158d00016d934d"
        }
      },
      "properties": {},
      "uid": {
        "segments": [
          "mihome",
          "ctrl_neutral2",
          "158d00016d934d"
        ]
      },
      "thingTypeUID": {
        "segments": [
          "mihome",
          "ctrl_neutral2"
        ]
      }
    }
  },
  "mihome:gateway:34ce0088dc70": {
    "class": "org.eclipse.smarthome.core.thing.internal.ThingImpl",
    "value": {
      "label": "Xiaomi Mi Smart Home Gateway",
      "bridgeUID": {
        "segments": [
          "mihome",
          "bridge",
          "34ce0088dc70"
        ]
      },
      "channels": [
        {
          "acceptedItemType": "Dimmer",
          "kind": "STATE",
          "uid": {
            "segments": [
              "mihome",
              "gateway",
              "34ce0088dc70",
              "brightness"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "mihome",
              "brightness"
            ]
          },
          "label": "Brightness",
          "description": "The brightness channel allows to control the brightness of a light. It is also possible to switch the light on and off.",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": [
            "Lighting"
          ]
        },
        {
          "acceptedItemType": "Number",
          "kind": "STATE",
          "uid": {
            "segments": [
              "mihome",
              "gateway",
              "34ce0088dc70",
              "illumination"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "mihome",
              "illumination"
            ]
          },
          "label": "Illumination",
          "description": "This channel shows the brightness of the environment of the device.",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        },
        {
          "acceptedItemType": "Color",
          "kind": "STATE",
          "uid": {
            "segments": [
              "mihome",
              "gateway",
              "34ce0088dc70",
              "color"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "mihome",
              "color"
            ]
          },
          "label": "Color",
          "description": "Control the color of light.",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": [
            "Lighting"
          ]
        },
        {
          "acceptedItemType": "Dimmer",
          "kind": "STATE",
          "uid": {
            "segments": [
              "mihome",
              "gateway",
              "34ce0088dc70",
              "colorTemperature"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "mihome",
              "colorTemperature"
            ]
          },
          "label": "Color Temperature",
          "description": "Allows to control the color temperature of light.",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": [
            "ColorTemperature"
          ]
        },
        {
          "acceptedItemType": "Switch",
          "kind": "STATE",
          "uid": {
            "segments": [
              "mihome",
              "gateway",
              "34ce0088dc70",
              "enableSound"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "mihome",
              "enableSound"
            ]
          },
          "label": "Switch to turn sound off when playing",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        },
        {
          "acceptedItemType": "Number",
          "kind": "STATE",
          "uid": {
            "segments": [
              "mihome",
              "gateway",
              "34ce0088dc70",
              "sound"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "mihome",
              "sound"
            ]
          },
          "label": "Sound Selector",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        },
        {
          "acceptedItemType": "Dimmer",
          "kind": "STATE",
          "uid": {
            "segments": [
              "mihome",
              "gateway",
              "34ce0088dc70",
              "volume"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "mihome",
              "volume"
            ]
          },
          "label": "Sound Volume",
          "description": "This channel controls the volume of the gateway for playing sounds",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        }
      ],
      "configuration": {
        "properties": {
          "itemId": "34ce0088dc70"
        }
      },
      "properties": {},
      "uid": {
        "segments": [
          "mihome",
          "gateway",
          "34ce0088dc70"
        ]
      },
      "thingTypeUID": {
        "segments": [
          "mihome",
          "gateway"
        ]
      }
    }
  },
  "mihome:bridge:34ce0088dc70": {
    "class": "org.eclipse.smarthome.core.thing.internal.BridgeImpl",
    "value": {
      "label": "Xiaomi Gateway",
      "channels": [],
      "configuration": {
        "properties": {
          "serialNumber": "34ce0088dc70",
          "port": 9898,
          "ipAddress": "192.168.1.165",
          "key": "3i42kimg50l4e5t1"
        }
      },
      "properties": {
        "vendor": "Xiaomi"
      },
      "uid": {
        "segments": [
          "mihome",
          "bridge",
          "34ce0088dc70"
        ]
      },
      "thingTypeUID": {
        "segments": [
          "mihome",
          "bridge"
        ]
      }
    }
  }
}

I debuged it a bit, and I found that error was caused by not existed gateway token. It’s null. As I see it should be recieved from heartbeat, but, as I heard, now gateway doesn’t send his token into heartbeat. Anybody know something about this problem?

firmware updated: 1.4.1_153.0143

@dimalo finalized the binding

Now this switch works for you?
I have such errors:

2018-03-18 09:03:10.017 [ERROR] [ndler.XiaomiAqaraActorSwitch1Handler] - Can't handle command ON on channel mihome:ctrl_ln1:id:ch1
2018-03-18 09:03:12.751 [ERROR] [ndler.XiaomiAqaraActorSwitch1Handler] - Can't handle command OFF on channel mihome:ctrl_ln1:id:ch1

If developer mode is activated using the Mi App, it should get its own token provided that the developer key was filled in for the Gateway. I haven’t needed to fill in the token manually for the Gateways before.

Is it possible to add the functionality that would allow the Xiaomi Gateway to be defined/used as system speaker in openhab2? From my understanding, currently the device is only able to play one of the 30 predefined sounds.

Someone else can maybe correct me, but I have yet to find a way to use it as a general speaker.
The best I could do was to add a custom sound to the Gateway, and play the sound when applicable via OH.

What the version of OH you use?
I downloaded 2.2 and it doesn’t work with mi home for me.
If I just download addon and try to send command to xiomi item - I get NPE because there is no gateway token in heartbeat anymore. But it still present into get_id_list_ack, but looks like the encryption alghoritm was changed too, because in this case I get invalid key message.
By the way, anybody know who’s author of mi home addon?

I’ve been using the newest version of OH without any trouble thus far.
Are you using “Xiaomi Mi Smart Home Binding” or “Xiaomi Mi IO Binding”?

I use
Xiaomi Mi Smart Home Binding

I have the same error:

2018-03-22 22:12:26.265 [WARN ] [me.handler.XiaomiActorGatewayHandler] - Can't handle command OFF on channel mihome:gateway:7811dcb38279:7811dcb38279:colorTemperature

Any solution?