New custom component : ZiGate


@eLRIC I’m seeing the same issue with its first generation version (which is essentially the same thing). It’s near my zigate, so that’s not the issue.

I have it configured as a sensor with default_state event. However, the same applies to the switch version I tried.

It says “presence detected” but never goes back to an “empty room” / “nothing detected” state.

Is that state something we have to reset through an automation ourselves? (Let’s say after a minute for example?)

Also… Does anyone know if this sensor also reports light intensity? Lumens or anything else?


I configure them as momentary switches. I’ll provide an example tomorrow
regarding the status not sent, it happened to me with outdoor sensors as well … maybe they don’t like low temperatures

- platform: zigate
  name: 'my_xiaomi_presence_sensor'
  address: xxxx01
  default_state: 'event'
  type: 'momentary'

When detection occurs, the switch representation in HA will go from OFF to ON, and switch back 15 secs to OFF. (you can modify ZGT_AUTOTOGGLE_DELAY in zigate/ if you want another delay)


That seems to be working nicely, thanks! :+1:

Your project and Zigate prevented me from having to get the proprietary Xiaomi gateway. While I don’t think they are worse than, say, Google… I don’t like the idea of anyone having a connection into my home.

Now I just need to find some cheap light sensors because I don’t think the “presence sensors” from Xiaomi report light. :thinking:


any of you using python 3.6 ?
I have issues with the custom components I don’t have with python 3.5:

2018-02-19 12:00:27 ERROR (MainThread) [homeassistant.setup] Error during setup of component sensor
Traceback (most recent call last):
  File "/home/ha/home-assistant/homeassistant/", line 148, in _async_setup_component
    component.setup, hass, processed_config)
AttributeError: module 'custom_components.sensor' has no attribute 'setup'

this is with python 3.6.4 and ha 0.63.3


Why don’t u just block the internet for the gateway? I block all internet access for my xiaomi devices as it’s not needed to use in home assistant


can you advise me what I am doing wrong? I have successfully added ZiGate component to Hassio and Xiaomi Motion sensors. My configuration file looks like this

#Enable ZiGate

#Presence detection (wardrobe)

  • platform: zigate
    name: 'Presence detection’
    address: 526E01
    default_state: 'event’
    type: ‘momentary’

Motion sensor appears among my device list. However, whenever I try to add automation it doesn’t work. My automation.yaml looks like this:

  • alias: Occupancy - Turn on Closet lights


    • platform: state
      entity_id: switch.presence_detection
      to: ‘on’

    condition: time
    after: '05:25:00’
    before: ‘00:00:00’


    • service: light.turn_on
      entity_id: group.closetlights
      brightness_pct: 100

Can someone advise me what I am doing wrong? Thank you!


can you try to add the automation through the GUI provided with HA ?
The trigger that works for me is :

  - entity_id: switch.deviceX
    from: 'off'
    platform: state
    to: 'on'

and my automations always start with action which includes all the parameters needed. Doing it with the GUI may help to have it in proper order


Currently running HA 0.63.3 with python 3.6.4 on a docker image without trouble …
Maybe have a look at your sensor.yaml file (or configuration.yaml) , check if there is a setup attribute somewhere …


I get the error with a config as simple as:

  name: Home



~/.homeassistant/custom_components/ directories are up to date.

if I remove ~/.homeassistant/custom_components/sensor then the error vanishes.

I’m upgrading from an old rpi to an atom pc with ubuntu bionic on it. the same config is still working on the rpi, the only difference I can see for now is the python version.
I can see the zigate platform is active, it receives events. switch component also errors with the same message.


Maybe it’s just me, but I don’t see why I should take the trouble to block a closed, proprietary, single manufacturer hub when I can get an open, general purpose hub to do basically the same thing as the proprietary one. :blush:

Unless you see a good feature on the hub that I can’t get with Zigate…?


apart from light, speaker and light sensor ? :wink:


didn’t help… Automation didn’t start.


Lights I don’t care about. Speaker and light sensor I didn’t find. (Maybe you have a link or name I can look up?)

In any case, I believe Zigate will be able to handle all of them as long as its Zigbee.

Ofcourse it’s my personal preference. I can image people wanting to use the official hub.


I own both :slight_smile: the aqara gateway v2 has light/light sensor/speaker.


Ah yes, you’re right. That’s on the gateway. No good for me though since I want multiple ones. Thanks for the mention though. I’d forgot about that. :smile:


probably not an issue with hass_zigate as I can also reproduce this error when only using


ahh… this drives me crazy. Maybe I am doing something wrong? I am integrating sensors with ZiGate by using NXP TestGUI by following the steps that are described on ZiGate page?
One more thing whenever I connect ZiGate to PC and run TestGUI app it shows that sensors are working. For instance when motion sensor detects movement I receive this message in TestGUI app:

  Cluster ID: 0x0406 (Measurement: Occupancy Sensing)
  Attribute ID: 0x0000
  Attribute Size: 0x0001
  Attribute Type: 0x18 (8-bit Bitmap)
  Attribute Data: 0x01
  Status: 0x00


Let’s try to figure out where the trouble is

  1. Did you declare your presence sensor as a “switch” (in configuration.yaml) ?
  2. If yes : did you see the status of the switch changing in HA when it is triggered ?
  3. if yes : have you tried a simple automation based on this switch (let’s say : if detection, send nottification) and is it working ?

Xiaomi presence sensors are known to work usually :slight_smile:


I will use the momentary parameters (usefully advice)
The sensor seems not working properly.
The sensor is in my mailbox and it has no detected today letters. :frowning:

It seems it need enough “lumens” to work …

If I open the mailbox, with the flashlight now the sensor work, but I will not asking my postman to work with a flashlight the day :slight_smile: