Xiaomi Gateway Integration

i think after separating the platform code from the component itself, it will be quite complex to fix bugs in the platform code. Right now, i just have to update the py files and i’m done.

I think i’ll go down that road once multi gateway code is completed (code is done, testing right now)

1 Like

I disabled your component, and put fooxy componet. Now everything works on my installation (now at least). Have no idea what is wrong with yours, but was working intermittently

So maybe is not such a bad idea to include your code in the general picture

Does anyone knows how RGB light works in HA? I have added the gateway as a light but i don’t see any option to change the color or brightness in HA.

Hi @anon35356645,

No not for all xiaomi, only for door sensor and motion sensor.

I’m waiting to receive morre sensors like motion and door, and also switch button. Once when i will have all (hope soon), then i will try to use @rave code.

Best regards,

Hi @maud,

As @Danielhiversen says, i used the customizing devices and services.

To use it, these are the lines codes that you need to add:

  • In configuration.yaml just, after time zone add this line:

    time_zone: Europe/Madrid
    customize: !include customize.yaml

  • In customize.yaml file that you must create i have this:

binary_sensor.door_entrada:
** icon: mdi:glassdoor**
** friendly_name: Sensor_Puerta_Ent**
binary_sensor.move_comedor:
** icon: mdi:walk**
** friendly_name: Sensor_Mov_Comedor**

Also i have defined a binary_sensor file:

- platform: template
** sensors:**
** door_entrada:**
** friendly_name: Frontdoor**
** value_template: “{{ states.sensor.magnet_158d00010104ab.state == ‘open’ }}”**
** sensor_class: opening**
** entity_id:**
** - sensor.magnet_158d00010104ab**

- platform: template
** sensors:**
** move_comedor:**
** friendly_name: SensorComedor**
** value_template: “{{ states.sensor.motion_158d00012934e6.state == ‘motion’ }}”**
** sensor_class: opening**
** entity_id:**
** - sensor.motion_158d00012934e6**

And at the end, I have a file to manage groups in the main page of HA:

Alarma:
** entities:**
** - binary_sensor.door_entrada**
** - binary_sensor.move_comedor**

Hi @rave,

Do you refer for example xiaomi RGB light bulb?

Here you have a python code that works with xioami light bulbs:

https://community.home-assistant.io/t/xiaomi-yeelight-e27-bulb-component/695/168

In HA, when you switch on light, and then click on the icon, appears this windows, where you can choose color:

1 Like

thanks but i still can’t find how a color can be changed from HA user interface.

Edit: just saw your screenshot, thanks! that helps

major update coming soon in a few hours. Multi hub support, motion sensor status update in 1min and gateway light support

3 Likes

@rave you can also do this from config:

scene:
  - name: Morning First Motion
    entities:
      light.livingroom:
        state: on
        brightness: 100
        rgb_color: [205,160,90]
        color_temp: 500
      light.keuken:
        state: on
        brightness: 100
        rgb_color: [205,160,90]
        color_temp: 500
3 Likes

If you like I can help do some pre-testing/bug fixing?

thanks! great info as always

that would be great. i’ll create a branch later after i get my dinner :grinning: have been coding for almost half a day

1 Like

I’m also here for testing… I’ve 22 xiaomi sensors online :grimacing:

Update posted. Read the first post for details

Cool @rave thanks for all your work!

Having trouble with the new interface feature, it detects my setting but the binding still fails as before.
Had this patched manually before but didn’t save the change.

Before the gateway wasn’t discovered without the patch, that’s working fine now.
But a few moments later it fails at this line 134 with the same exception:
sock.bind((self.MULTICAST_ADDRESS, self.MULTICAST_PORT))

Maybe this needs the interface parameter too?

I have not tried that. The code was from @kirichkov

I think you’re right. Try replacing self.MULTICAST_ADDRESS with the IP and see if it works

For me it’s ok… All sensors detected

Yep changed to
sock.bind((self._interface, self.MULTICAST_PORT))

That works! Testing the rest tonight!

Just added RGB + brightness Gateway Light support :slight_smile: also fix some bug related to performance.

2 Likes

Great. If there’s no issue then i’ll update the code and do a final commit

        if self._interface != 'any':
            sock.bind((self._interface, self.MULTICAST_PORT))
            mreq = socket.inet_aton(self.MULTICAST_ADDRESS) + socket.inet_aton(self._interface)
        else:
            sock.bind((self.MULTICAST_ADDRESS, self.MULTICAST_PORT))
            mreq = struct.pack("4sl", socket.inet_aton(self.MULTICAST_ADDRESS), socket.INADDR_ANY)