Xiaomi Gateway Integration

how can i set Gateway light color/brightness?
I tried with customize (by setting rgb_color: (160,160,0) and when it didn’t work, with xy_color: (0.575,0.474) and brightness: 80) but doesn’t appear to work :frowning:

yes :slight_smile:

3 Likes

for me the color customization works… i’ve used for example

action: service: homeassistant.turn_on entity_id: light.gateway_light_f0b4299ab68b data: brightness: 255 rgb_color: [255, 0, 0]

for red color

255,255,255 for white and it works

but what about ‘default’ values?
gateway light is now available as a default ‘light’ switch, so i can switch on/off from the UI, but it changes the color to white and brightness to maximum. I’d like to set a default value for the light, so when I switch on/off, it uses that color.
As a temporary solution I modified the python code, but it would be much better to read that values from the config file (I still didn’t investigate the code to see what it reads from config, maybe I’ll find something)

17-01-15 14:05:36 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/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1049, in         _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/light/__init__.py", line 243, in     async_handle_light_service
    yield from light.async_turn_off(**params)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 363, in async_turn_off
  None, ft.partial(self.turn_off, **kwargs))
 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/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/light/xiaomi.py", line 169, in     turn_off
    if self.xiaomi_hub.write_to_hub(self._sid, self._data_key, 0):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/xiaomi.py", line 290, in     write_to_hub
    key = self._get_key()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/xiaomi.py", line 315, in     _get_key
    encryptor = AES.new(self.GATEWAY_KEY, AES.MODE_CBC, IV=IV)
  File "/home/hass/.homeassistant/deps/Crypto/Cipher/AES.py", line 95, in new
    return AESCipher(key, *args, **kwargs)
  File "/home/hass/.homeassistant/deps/Crypto/Cipher/AES.py", line 59, in __init__
    blockalgo.BlockAlgo.__init__(self, _AES, key, *args, **kwargs)
  File "/home/hass/.homeassistant/deps/Crypto/Cipher/blockalgo.py", line 141, in __init__
    self._cipher = factory.new(key, *args, **kwargs)
ValueError: Key cannot be the null string

why?

Missing key?

APP open, can be displayed in the Homeassisant, but Homeassisant can not open

it needs SID, not IP. you can get SID from MAC address. Read the BBS link i provided in README

Thank you so much for your guidance.Normal working

1 Like

lots of sensors!! Very cool

Which you find the most usable, and really “helpful”?

using the right automations are all helpful… motion sensors can be useful for alarms or to trigger actions (like turn on light and so on…) door and windows sensor to protect your house and send notifications to your phone in case of opening…

the wireless button to trigger actions like activate scenes…

:slight_smile:

Binding the socket to the configured interface breaks receiving on my end. I can clearly see the packets with a sniffer, but the HASS UI is not getting updated at all. I think these changes are very much OS specific.

@jmvermeulen what OS are you running hass on? I’m using ubuntu for my tests.

@kirichkov Interesting… I was getting a exception like ‘address not valid in this context’ on a Windows 10 PC with multiple network interfaces. This was fixed by rave.

But I also had your problem of not receiving any events in Hass from the gateway on Ubuntu.
My Ubuntu installation was running as a virtual machine in hyper-v (on the same Windows 10 host). I thought this was a hyper-v issue and didn’t find a solution. That’s why I moved the development to Windows 10. Maybe it wasn’t a hyper-v issue but Ubuntu related. Is anyone using Ubuntu with this component?

The actual Hass instance is running on a Raspberry, think its Debian based.

The master branch works fine (1 motion sensor), but it takes up to 30 seconds before HA sees the sensor as ‘on’. (a bit long to switch the lights on). I tried the staging branch version of the binary_sensor xiaomi.py but then the sensor does not work. It is on Rasbian.

1 Like

Running on my PI, when using the master version I had delay issues, those where fixed with the staging patch! :smiley: So for me the staging version is fine now.

But I can reproduce @kirichkov issue on the PI running HASSbian as well when specifying a interface. Event’s don’t come through then. On Windows specifying a interface works as expected, in fact required in my case (otherwise a invalid address in this context exception). I don’t know the reason but maybe @kirichkov has a point that’s a OS specific issue.

@Pilot have you tried running Hass manually?
Do you see the motion event coming in in your console logging?

Btw @rave the threading issue I reported before, has disapperd automagically :cold_sweat:.
Cannot reproduce it anymore…

1 Like

@jmvermeulen I removed the interface specification from the settings and now the staging version works without delays under Raspbian. Thanks! :slight_smile:

I see the event state change for the binary sensor journalctl and in the console when I run hass manually, is that what you mean?

Yes, only use the interface option if you have issues with the socket.

I’ve just installed the latest version, anyone else having this problem? All of my sensors are on?

Restarted/rebooted, but still the same problem. Updated firmware on gateway, still the same.

Was working fine before latest update. Am I doing something different from a couple of versions back?

Did you update HA too?

Yes to 0.36. Before I updated xiaomi component.