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 custom integration:

1 Like

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:

Thanks for a great integration. I was struggling for a while to get it up and running, but now it seems to be working well. The problem seemed to be that I first added a xComfort Push button in the Bridge app, before adding the actuator. And then the integration didn’t want to populate any devices in Home Assistant (and also the Python script didn’t show any devices). But after deleting the devices and adding the actuator first, everything started working. Might this be a bug somewhere in the code?

By the way, is there a way to get the status of the actuators back to Home Assistant from the xBridge device? When I turn the light either on or off with the physical xComfort push button (which is connected to my xComfort actuator), the status of the entity doesn’t update in Home Assistant, which can cause problems with my automations

Nice to hear you got it working in the end and thanks for the bug report. I’ll test with a bridge app push button to see what is going on and will try to fix it.

The state of the entity is supposed to update in the home assistant app even if you turn it on/off with physical buttons. Not sure what is going on for you, but I’ll release a new version soon. Hopefully, it will work then. If not we can dig a bit deeper.

This is an exciting project. Does it support the latest app version released in May 2021? Does it support scenes?

I haven’t tested the May version yet. I’m currently running 2021.4.6, but I’ll check it out this week. It does support scenes (I assume you mean HA scenes, not bridge scenes). All the lights will show up under entities.

Thanks for the reply! I was talking about scenes in the xcomfort app actually. I have a lot of singers, so I use scenes extensively. I guess you haven’t coded for them?

I see. Only devices are in scope and just lights in the current version.

The way I use this is to have Home Assistant as my primary home automation system. I only open the xcomfort app to sync up new devices. You could consider just remaking the scenes in HA. Since the editor saves the current state you can basically just activate the scene from the xcomfort app and save the state in the HA app.

Ok thanks for the clarification. Still doing some basic research on home automation to see if this is for me. If I try it I’ll let you know my experience/feedback!

Ok, I have added jankrib/ha-xcomfort-bridge as a custom repository in HACS on my raspberry pi 4 running HASS OS.

I rebooted, installed the integration and input my IP and AUTH-Key, and rebooted again. The bridge shows up in my integration, but it does not automatically detect any of my lights (even after another reboot).

I am very inexperienced with HASS but I have followed the instructions carefully. Some theories:

  • I am running the latest app 12 May 2021 version 2.0.0 (bridge version 3.02). Perhaps this has changed something.
  • there is a 0.1% chance i got the IP address of the bridge wrong (couldn’t find it in the app, but pretty sure it was the static IP with device named Renseas Technology or similar. Waaaay too many devices on my local network!)
  • Something else is wrong with my home assistant configuration, due to my inexperience.

Happy to help diagnose this, but not sure where to start in providing more information. Are there log files I could provide you with?

Thank you for the theories. Its the new bridge version that is causing the issue. Mine was running the old for app version 1.2.0. Doesn’t look like that much has changed so I’ll publish a new version as soon as it’s ready.

1 Like

A new version of the custom repository for HACS is out now with support for bridge version 3.02.