Xiaomi Gateway Integration

Thank you so much! I will do it and report back! Please tell me another thing I should put after the key what is in the app after “token”: right?? Thank you so much once again.

Can you show image how that look?

Sure here you go.

Biksem

Thanks men, but did not working for me, where i need to add this line?
all my code for smart home xiaomi is on customize.yaml
when i add this line to my config, that still did not show, what i miss:?

Big Thanks!

So, has anyone updated to the new 145 firmware, release yesterday? Everything working smoothly?

Hi @abmantis,

I updated, and all more or less is the same in HA, but in the Mi App, many times i have problems to control radio, or light gateway with in the LAN, but with 3G/4G, all works well.

1 Like

Add it in your sensor section, remember to change the values in my code to your unique values

states.binary_sensor.door_window_sensor_158d00011c7eac <- change this as appropriate
lounge_door_status: <- change this as appropriate
friendly_name: ‘Lounge Front Door’ <- change this as appropriate

sensor: 
  - platform: template
    sensors:
      lounge_door_status:
        value_template: '{% if states.binary_sensor.door_window_sensor_158d00011c7eac %}
          {% if states.binary_sensor.door_window_sensor_158d00011c7eac.state == "on" %}
            Open
          {% else %}
            Closed
          {% endif %}
          {% else %}
            n/a
          {% endif %}'
        friendly_name: 'Lounge Front Door'
1 Like

There is a pre-formatted text button you can highlight your text and click so spaces become visible and probably more helpful, copyable.

so

space:

  • platform: spacing:
    spacer: ‘Space Space Space Space Space Space’
    space: ‘{% if states.ispace.sensor.state == “paste.with.no.code.block”%} Invisible {%- else -%} Visible {%- endif -%}’

becomes

space:
  - platform: spacing:
        spacer: 'Space Space Space Space Space Space'
          space: '{% if states.ispace.sensor.state ==  "paste.with.no.code.block"%} Invisible {%- else -%} Visible {%- endif -%}'

See pretty picture

Thanks, fixed up :slight_smile:

Hi All,

i need help, randomly my binary_sensor change the status to on. how to fix it?

Many Thanks

Have you tried turning it off and on again?

That is, power off and power on hub. Restart Hass. Walk past sensor / wave, or open close door.

yes, if i reboot the status of sensor do not change :frowning:
The problem is for binary_sensor.door_window_sensor, i do not use template for binary_sensor.

After a reboot or power failure I always have to open and close my door once everything is up and running to get it to register as being closed, or off but if you have already done this and it still remains open do you know if it actually registers the change when you open and close?

I can try to explain better, When i open and close the door the system register the change. For example @12:15 am all sensor are off but suddenly all sensor change to on.

I think this is what is being called the ghost thing earlier in the thread.

@Danielhiversen has a fork with ghost workaround, you could try installing his fork and config example in link below. I haven’t tried it with the config for ghost check added to my setup so I don’t know if this is still current.

Add another bit, in the Mi Home app the status change of the senso is not logged.

it is gateway issue, getaway always report invalid state after reboot and we cannot change this behaviour.

Search for ghost in this thead. It is an issue with the gateway. We could probably work around it by ignoring the heartbeat messages…

Hi all. I’m new here.

I just got a gateway in the mail. Don’t even have any devices for it yet, but have a bunch on the way! I set it up in HA, but am having the same issue Ordep was having 16 days ago. Namely, when trying to toggle the gateway light, I get an “Invalid key” response.

This screenshot shows the configuration, the gateway’s key in the Mi app, the gateway light in the UI and the “invalid key” error message: https://i.stack.imgur.com/10F2n.jpg

I have refreshed and re-typed the key at least five times already. I have also tried the latest versions from both lazcad and Danielhiversen repos and this problem exists with both. I have also tried recent older versions and it’s there.

My gateway is brand new, model lumi.gateway.v3, updated to fw 1.4.1_145.

As you can see from the screenshot, the key is the same in the config and the app. I haven’t seen many mentions of this firmware version on this forum. Perhaps something in it breaks the key handling. Also possible that there is something wrong with my HA setup. It is very new. That said, it works fine with Kodi and a couple of Yeelights. I have pycrypto 2.6.1 installed, if that’s relevant.

If there is any debug information that would be helpful, I’d be more than happy to provide it.

I had an issue with the key. I changed region to mainland China, logged out of the app, logged back i regenerated the key and then it started working. Don’t know which of the above fixed it but you could try it.