Xiaomi Gateway Integration

Like i said again, that’s the error message for the gateway light. The rest loaded fine including temp sensor according to the log

The error message is clear enough. Invalid key

How can the key be invalid when I have all other sensors depending on the gateway working fine.
Isn’t the gateway and gateway’s light key the same?

I’ve just copied the light config coming up on the status’ list.

Again might be doing something completely stupid…

I’ve just join the community. Thanks to everyone!!

Will it be possible to add wifi plug sometime? Is there anything I can do to help?

I also have the IR WIFI Xiaomi unit, It is possible to make it work with HA?

Thanks!!

alias: Set brightness by rotating cube
trigger:
  platform: event
  event_type: cube_action
  event_data:
      entity_id: binary_sensor.cube_158d00011064e0
      action_type: rotate

action:
  service: homeassistant.turn_on
  data_template:
      entity_id: group.lights_chambre
      brightness: >
                    {% set state = states.group.lights_chambre.attributes.brightness + (trigger.event.data.action_value|float)/90 -%}
                    {%-  if state > 1 -%}
                       {%- set state  = 1 -%}
                    {%-  elif state < 0 -%}
                       {%- set state  = 0 -%}
                    {%- endif %}
                    {{ state }}

hi there, does this automation based on @Danielhiversen work, looks like it should work for changing brightness of a yeelight group ?

You should change the upper limit from 1 to 255

                {% set state = states.group.lights_chambre.attributes.brightness + (trigger.event.data.action_value|float)/90 -%}
                {%-  if state > 255 -%}
                   {%- set state  = 255 -%}
                {%-  elif state < 0 -%}
                   {%- set state  = 0 -%}
                {%- endif %}

Thanks for your reply @Danielhiversen
Like this ?

Yes, and you probably do not want to divide by 90.
Now, you have to rotate the cube many times before reaching 255.

Reading values from the gateway doesn’t need a key. Writing does. So you could have a wrong key and still be able to read sensor data but once you tried to control a device, for example a plug or gateway light, you’ll get an error

So go into the app, and double check your key

Not for the Wi-Fi plug. This component only support devices you can add using the gateway, aka Zigbee devices.

Still valid if I say that i have a wireless switcher and a cube working without issues?

thanks a lot for your help

Thanks you for the information. I dont see the temp sensor in the senor row of HA. Do i need to manually create a sensor for this?

I have three temp sensors.
You should see one temperature and one humidity sensor per device in HA.
I didn’t need to do anything except restart HA after adding them to the gw via xiaomi app.

Hmm, okay. Then it is not working for me like i said. Can you post your config please?

The setup is described in the documentation for the component and here is my config: https://github.com/Danielhiversen/home-assistant_config/blob/master/configuration.yaml#L186

Hi guys. I hope someone here can help me. Yesterday I migrated my homeassistant to hassbian 1.1 and have some problems with the xiaomi switches. (Light switch and plug switch) Temperature sensors, motion sensors and door/window sensors work OK.

@Danielhiversen i’m using your code for the xiaomi component. (Because of ghost movements)

My config:
xiaomi:
check_ghost: True
gateways:
- sid: c056xxxxxxxx
key: 5cpsxxxxxxxxxxxx

Error log:

7-03-24 12:16:23 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py", line 1010, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/switch/__init__.py", line 108, in async_handle_switch_service
    yield from switch.async_turn_off()
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/switch/xiaomi.py", line 63, in turn_off
    if self.xiaomi_hub.write_to_hub(self._sid, self._data_key, 'off'):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/xiaomi.py", line 337, in write_to_hub
    data['key'] = self._get_key()
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/xiaomi.py", line 369, in _get_key
    encryptor = AES.new(self.key.encode(), AES.MODE_CBC, IV=init_vector)
  File "/home/homeassistant/.homeassistant/deps/Crypto/Cipher/AES.py", line 95, in new
    return AESCipher(key, *args, **kwargs)
  File "/home/homeassistant/.homeassistant/deps/Crypto/Cipher/AES.py", line 59, in __init__
    blockalgo.BlockAlgo.__init__(self, _AES, key, *args, **kwargs)
  File "/home/homeassistant/.homeassistant/deps/Crypto/Cipher/blockalgo.py", line 141, in __init__
    self._cipher = factory.new(key, *args, **kwargs)
ValueError: Key cannot be the null string

Do you use the latest version? I fixed a related bug yesterday

Yes. Those are basically a sensor. You’re not changing anything on the gateway using HA, are you?

Anyway, I’m not replying anymore. The error message is clear enough and the reason i put the error message there is so that people don’t ask me question like this. But you did so i explained what that error means, and you don’t trust me, then so be it. Rather not waste anymore of my time

Okay, my config looks identically. So maybe a problem with my router?