Integration with XComfort Bridge

I’m working on an integration with Eaton XComfort Bridge. I have XComfort lights in my house and bought the Bridge, so my integration is using a websocket connection to the bridge. It’s beginning to work quite well and I trying to figure out how I can share this with others. The XComfort devices are of high quality, but they are stuck with closed source code so I had to backward engineer their websocket api. Will this be a deal-breaker for merging it into the main repository? I’m also not sure if integrations that require a seperate bridge is wanted in the main codebase.

Eaton has a lot of different XComfort devices, but I only have lights. If others are interested in this integration and have different devices I would love some help getting them to work properly.

The code is still raw and just a prototype at this point:

GitHub fork of Home Assistant:

Python package for communication:

Hei Jan, antar at du er norsk.
Det arbeidet du nå gjør er veldig interessant - iallefall for oss her på berget. OBOS/Veidekke har valgt xComfort som standard i sine nybygg og jeg som kunde (beboer) river meg i håret over at vi enda en gang får et proprietært system tredd nedover hode. Dersom du klarer å “åpne opp” systemet gjennom reverse engineering slik at det kan styres via Home Assistant, så er vi et langt stykke på vei videre. SÅ får vi bare håpe at ikke produsenten saboterer slike som deg, men faktisk etterhvert innser at åpne standarder fører til mer salg (og ikke utgjør noen trussel).
Stå på!

This is very interesting !! Could you share some of your recent progress ?

I made some progress and It’s working quite well. there is some code cleanup to do before I can try to get it into HA core.

Decided to make a repository compatible with HACS so that it can be easily tested by the community: https://github.com/jankrib/ha-xcomfort-bridge

It might have issues with HA versions lower than 0.112 (beta track as of writing this, scheduled for release July 1st).

I’ll try to get this into the default gallery for HACS as soon as possible.

1 Like

Hi @jankrib i am also interested in integrating my xComfort lights relay with Bridge to Home assistant.
I have bought Bridge recently and added all my xComfort switch to it. and also added your Github repository () https://github.com/jankrib/ha-xcomfort-bridge and configured my bridge IP and key, through HACS integration.

Now I don’t know how to move forward to get the entities populated? i can see you have python GitHub repository(https://github.com/jankrib/xcomfort-python) but i don’t see any documentation to make the communication to turn on and turnoff lights. I can see the python code but don’t know how to integrate the same in HA and trigger on/off to xComfort devices/entities… Some documentations in layman would be appreciated :slight_smile: thanks alot for all the efforts you are making in this so far…

Thank you for testing it out. The entities should be populated automatically, but it wouldn’t surprise me if there is a bug there. Which version of HA are you running? Have you tried to restart HA?

Could you check your logs and see if there is anything there?

You can try this python code:

import asyncio
from xcomfort import Bridge


async def main():
    bridge = Bridge("xxx", "xxx")

    runTask = asyncio.create_task(bridge.run())

    devices = await bridge.get_devices()

    print("Devices:")

    for device in devices.values():
        device.state.subscribe(lambda state: print(f"State [Device#{device.device_id}]: {state} -- {device.bridge.connection.device_id}"))
        print(device)

    # Wait 50 seconds. Try flipping the light switch manually while you wait
    await asyncio.sleep(50) 

    # Turn off all the lights.
    for device in devices.values():
        await device.switch(False)


    await asyncio.sleep(5)

    await bridge.close()
    await runTask

asyncio.run(main())

I’ll write up some documentation when I get the time.

Published an update now to


and
https://github.com/jankrib/xcomfort-bridge

This fixes a quite serious bug that have made the device state buggy since eaton released v1.2 of their app.

I also updated the readme in the xcomfort-bridge repo to something that is actually working.

HI @jankrib, thanks for the response, yes soon i rebooted the HA i can see all the entities well.
I am curious to know how to run this python code and manually manage devices state.

more info on how to and where to execute this code in HA would be appreciable.

from xcomfort import Bridge


async def main():
    bridge = Bridge("xxx", "xxx")

    runTask = asyncio.create_task(bridge.run())

    devices = await bridge.get_devices()

    print("Devices:")

    for device in devices.values():
        device.state.subscribe(lambda state: print(f"State [Device#{device.device_id}]: {state} -- {device.bridge.connection.device_id}"))
        print(device)

    # Wait 50 seconds. Try flipping the light switch manually while you wait
    await asyncio.sleep(50) 

    # Turn off all the lights.
    for device in devices.values():
        await device.switch(False)


    await asyncio.sleep(5)

    await bridge.close()
    await runTask

asyncio.run(main())

I am running HA - HassOS 4.15

I’m not sure what you mean by “execute this code in HA”. As far as I know, you can’t directly execute python code in HA. You can make a custom_component, and jankrib/ha-xcomfort-bridge is a good starting point.

If you want to execute the example code you can do it from any computer with python 3.7 (no need to involve HA). The example quoted is flawed, so rather grab the new example code from jankrib/xcomfort-bridge. Do you have experience with python?

Disclaimer: jankrib/xcomfort-bridge is in pre-release and the API will be subject to change.

Great got it now, i have very basic knowledge in Python. i will try to execute this script on my MAC with python packages. and will update you. thanks for the information :slight_smile: