Xiaomi Gateway Integration

Check my example to see how I made sure it was between 0 and 1.

I think the Xiaomi app gets the data via China. :smile:

So try to connect them to the same wifi. I think this is a network issue

他媽的 :smile:

man I need the second gateway to be on that WiFi, because the gateway will be too far away from the other Wifi

Hope @rave can fix this

EDIT: let me see if connecting to the same Wifi works

Try to connect the gateway to the other wifi, to check if that works.
If that works, you know it is a network issue. Then you should try to check the settings on your router.

router is fine, I have around 200 devices on the network, split between the two WiFi, and all interact with each other

Is still think you should try to connect the gateway to the other wifi, to check if that works.

yes, like this it works …

Ok, so it is something wrong with the network settings. The Xiaomi component broadcast a package to discover all gateways, and for some reason the package never gets to the gateway on the other wifi.

Thanks, that was stupid of me…
Anyway, now I’m getting:

17-01-31 22:05:51 ERROR (Thread-12) [custom_components.light.yeelight] Error when calling <function YeelightLight.set_default at 0x6efebf18>: {‘message’: ‘general error’, ‘code’: -5000}

>   action:
>     service: light.turn_on
>     data_template:
>       entity_id: light.living_room
>       brightness: >
>                   {% set state = states.light.living_room.attributes.brightness + (trigger.event.data.action_value) -%}
>                   {%-  if state > 255 -%}
>                     {%- set state  = 255 -%}
>                   {%-  elif state < 0 -%}
>                     {%- set state  = 0 -%}
>                   {%- endif %}
>                   {{ state|round }}

Setting the brightness directly like this works fine:

  action:
    service: light.turn_on
    entity_id: light.living_room
    data:
      brightness: 255
1 Like

mmhhh, I have 2 WiFi

  1. WIFI-1st floor where I am now programming all
  2. WiFI–GroundFloor where the Gateway2 should go.

Now I connected the Gateway2 to the WIFIGroundfloor (but I am in first floor and that WiFi is weak).
Maybe putting it somewhere where is not weak will go, have to check

Go to YOUR_IP:8123/dev-template to test and validate the template.

Replace trigger.event.data.action_value with a test number.

I also think you need to convert the rotation to a float is I did, (trigger.event.data.action_value|float)

Testing through there seems fine. I’m using round at the end anyway so I always get an integer…

Ok, but I though the rotate value might be a string that needs to be converted to a number.
i do not know the yeelight component, so do not know what the error code mean.

YES! The problem was the weak WiFI.

Strangely during initialization of the Gateway the weak WiFi was enough to make iit connect and register to it.

But then in HASS was not strong enough … strange …

Great, so it works now?
One gateway connected to each network and both connected to HA?

1 Like

Yes one gateway to one wifi, and other gateway to other wifi. Both inside HASS working.

Thanks!!!

Wonder if anyone can help with my continuing problem.
All my devices are listed on Home Assistant and i receive updates updates from all of them.
I have a motion sensor, door sensor, switch and of course the gateway.
Problem i cannot control the switch and the gateway from Home Assistant although i do receive updates when i turn them on manually.
I looked at the error log and found this:
17-01-30 15:16:03 INFO (MainThread) [homeassistant.components.http] Serving /api/services/homeassistant/turn_on to 192.168.1.6 (auth: True)
17-01-30 15:16:03 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=homeassistant, service_call_id=1978650000-1, service=turn_on, service_data=entity_id=switch.plug_edited>
17-01-30 15:16:03 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=switch, service_call_id=1978650000-2, service=turn_on, service_data=entity_id=[‘switch.plug_158d00013e243b’]>
17-01-30 15:16:04 ERROR (Thread-11) [custom_components.xiaomi] Invalid Key
17-01-30 15:16:04 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=1978650000-2>
17-01-30 15:16:04 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=1978650000-1>

I verify the switch key and is the same as shown in the app, so i don’t know why i get an error.
If anyone has an idea how to fix it please let me know.
Thanks.

Try to make a new key

Thanks for your quick response and sorry for my beginner question how you make a new key?
The motion sensor and the door switch works fine but it sims that for some reason the Home Assistant does not send commands to the hub. The switch key is correct as displayed in Mi Home app, it is possible to regenerate it? How?
Thanks

I think it will generate a new key if you click on the key?