Someone already built an X-Sense integration for Home Assistant, and I’ve been digging through the code. Under the hood, it uses Python to log into X-Sense’s cloud, which then generates a special AWS key to link your X-Sense hub and devices for daily updates. Pretty clever!
I’ve already ported part of the logic over to Hubitat, BUT… here’s the catch:
Hubitat doesn’t support Python natively.
So, to make this work:
I’d have to create a standalone Python app that runs outside of Hubitat.
You’d manually enter your X-Sense username and password into that app.
The app would retrieve your AWS key.
You’d then paste that key into the Hubitat X-Sense driver to enable device syncing.
My question for you all: Would you be comfortable running an external app like this to bridge your X-Sense devices to Hubitat? Or does anyone know of a clever workaround to do this directly inside Hubitat without needing Python?
Sounds like this would depend on how it generates the key if that's all you're using it for. How does that work? That would determine whether it's possible to do it in the Hubitat environment.
I've been digging into an existing Home Assistant integration for X-Sense available here:
The authentication and token-handling logic is located in the coordinator.py file. This file relies on an external Python library called python-xsense, which is maintained separately at:
That library handles logging into the X-Sense cloud using Amazon Cognito. It performs the Secure Remote Password (SRP) login flow, retrieves the access, ID, and refresh tokens, and then exchanges them for temporary AWS IoT credentials, including the access key, secret key, and session token. These are the credentials used to link the hub and devices to AWS via MQTT.
When I tested this setup, I was able to manually retrieve the required tokens using the Python script and then created a workaround in Hubitat. I added input fields to the device driver where I could paste in the tokens manually. This allowed me to bridge the devices even though Python isn't supported directly in Hubitat.
Right now, I'm investigating whether it's possible to port the logic from coordinator.py and the supporting library into native Groovy. My goal is to eliminate the need for a separate Python script altogether and have Hubitat perform the full login and token generation on its own.
If anyone here has experience working with Cognito's SRP auth or translating async Python logic into Groovy, I'd really appreciate any advice or insight you can share.
Below is the version of utils.py I modified to print everything to the screen, including the authentication tokens and AWS credentials retrieved after logging into the X-Sense API.
This script reads the username and password either from command-line arguments or a .env file. It performs the login using the python-xsense library and then prints out the client info, access token, ID token, refresh token, AWS access key, secret key, session token, and expiry. It also lists all stations and devices in a format I was preparing to use with Hubitat.
The goal was to run this externally, grab the credentials, and manually paste them into the Hubitat driver fields to link up with the X-Sense MQTT service. Long-term, I'm exploring whether this entire process can be done inside Hubitat using Groovy, but for now this script works as a practical workaround.
I would be very interested. X-sense has some really nice, well built devices. I have the temp sensors and hub. Devices and app are top tier, not 1 single issue.
Once my Halos finally die, they are going one by one, I will invest in the 5 pack smokes by X-sense
At a quick glance this appears to be using MQTT to login and handle expiring tokens. Not my area of expertise (some may ask if I really have one ), but there are a few on here who may be able to steer you in the right direction.
Correct, it uses MQTT, and that’s exactly why I couldn’t get it working in Hubitat. Groovy doesn’t support MQTT directly, so it would most likely require something like Node-RED or a custom script running on an external processor like a Raspberry Pi to handle the connection, authentication, and token refresh logic. Hubitat just isn’t equipped for native MQTT handling at that level
Unfortunately i think this is allot more complicated then simple MQTT. Amazons IOT core product that drives this stuff and uses MQTT for communication isn't exaclty a simple user id and password/token. I tried for some time to get it to work and just couldn't because there are additional layers that are used to authenticate. You basically have to use the Amazon IOT Core SDK as part of your app to fully establish the connection. We don't have access to that in the Hubitat Grovvy deployment. Your best bet would be to get a MQTT Broker that can talk to Amazon's service and then you run in between the stuff in AWS and your hub.
Thanks for the detailed explanation—that really helps clarify things. I had a feeling it was more complex than standard MQTT, and your insight confirmed it. I think I’m going to skip trying to port X-Sense directly to Hubitat. Since we’d need to rely on a broker running on another device anyway, it’ll probably be easier and cleaner to just use Home Assistant with the already-developed X-Sense integration, then link it to Hubitat using one of the Hubitat → HA bridging apps. That way we can still run my automation rules in Hubitat based on the information received from Home Assistant. Appreciate the help!