X-Sense Security - is it possible to create an integration?

Regarding battery drain, I would not care. A pack of rechargeable AAAs is about $10, and the inconvenience of swapping out the batteries is well worth it if it enables bigger and grander things. In my case, I am juggling a leaky mini split on its last legs, a neverending source of thermal load (boiler room below me), and a temperature-sensitive pet.

Thank you for your work again. The integration is coming along great and clean so far. Hopefully, this lazy API issue gets figured out :pray:

1 Like

Oh, and one more thing. Another possibility is that there is no special request for actual data refresh, merely a “normal” request that’s appended and lets data come in for a few minutes. It might be something as blunt as reauthenticating or appending “yes send the data now please” to the status inquiry. This might be the case because I saw similar lagging in the app, too, after staying on the same device’s screen for too long - the graph seems stuck, and after a pulldown, the last few minutes load.

I’m sorry if I sound like a backseat developer. I am new to appliance reverse engineering, yet very excited about this specific project. Thank you again for all that you do.

yes it must be something like that, I’m sure we will figure it out. Mitmproxy is very helpful so far and all api-calls are visible. I just have to play around with it.

Don’t worry, It’s useful for me that we can discuss it and that you tell about your experiences.

Just published the first version of the python-xsense library to pypi. It is now installable via pip install “python-xsense[async]”

I’ve committed and pushed the latest changes (basestation + some entities)

Also managed to install it as a custom component in my normal home assistant installation. I installed all files from the components/xsense directory to custom_components/xsense and added “version”: “0.0.1” to the manifest. After a restart of home assistant, xsense was available in the integrations page.
You don’t have to add anything to the configuration.yaml.

I have no idea how it will behave, so run it at your own risk.

Hello,

I have tried to launch the “setup.py” with pip, but i have an error (cf. screen)
i have installed all requierments manually: request, boto3, botocore, pycognito
I’m running in a Docker container

have you an idea for resolve this ? :slight_smile:

EDIT : i tried to launch "pip install python-xsense[async]” and i haven’t the package after reboot

I’m afraid my instructions were not very clear.

You don’t need to touch python-xsense, but fetch the files from here:

Place those files in a folder called xsense in the custom_components directory. Then add a version-number in the manifest.json, because home assistant needs that for external components. Then restart home assistant. The component should now be available for testing.

The required python packages are installed automatically by home assistant. You don’t need to install them, but it won’t harm if you do.

My installation looks like this in visual code server:

Thanks Theo for this great work!

Could you make your repository compatible with HACS?

You have to put “xsense directory” in a “custom_components” directory, change your manifest.json adding “version”: “1.0.0” and removing “async” for requirements.

At last, you need a “hacs.json” file like this

{
    "name": "xsense",
    "render_readme": true
}

and a README.md.

I made a test here and it’s working:
GitHub - Elwinmage/ha-xsense-component: Home assistant component for X-sense devices

Users will only have to put the url in HACS > Custom repositories

1 Like

Cool that you have it working in hacs!

I’m currently working in a branch of home-assistant-core and the goal is to have it included there. I don’t think that changes for hacs belong inside the home-assistant-core code, but correct me if I’m wrong.

1 Like

I’ve spend some time tonight on the sync issue and I discovered an issue in my test-setup.
In my phone a proxy was configured, in order to intercept all traffic with mitm-proxy.

It turns out that xsense is ignoring the proxy-settings for websocket-connections.
I already noticed before that I no longer saw those requests and I now know why.

I added a few forwarding-rules (for a tranparent proxy) and I can see the websockets again. These contain mqtt messages, including updates to the temperature.

Figuring out how to connect to the websockets/mqtt will probably take some time.
My goal now is to finalize the other parts first:

  • add entities for all the things that I’m still ignoring
  • implement active info (if a device goes offline, show it in HA)
  • implement error-handling in the authentication, I’m currently ignoring things if authentication fails.

Any suggestions what else we should have?

2 Likes

Agreed, hacs can be a separate repo or branch

If you Need some help, i have the waterleak Sensors and 2 cams.

But One Thing, you have to explain how i can help, for example for sniffing the Communications, i don‘t know how it works.

Great Job man, One month ago, i googled a lot, But there was nothing to implement xsense in smart homes, and now, the fist Things in HA.

I was in contact with xsense, month ago and asked when they will implement mqtt or something like that, or a apicall. The answer was, „thats not in planning“

Some pictures

The Alarm and the Signalstenght entity is missing by the waterleak sensor

1 Like

cool to hear and to see it running om someone elses installation.

Just spotted a stupid bug in refreshing the access-tokens. Because of that bug, the system will disconnect after 24 hours. I’ve fixed it already, but I have to build a new package.

About the sensors: I do have an waterleak sensor and will make sure that those entities show up. I don’t have a camera yet, so it would be very nice if you can help. I can make a script that dumps all information that is available and you can send me the relevant parts. What kind of information would be useful in home-assistant? Battery and online-status?
Including the video will probably much harder, and I guess I have to buy one myself to get that working.

Hopefully we can get the realtime alarms working if we have mqtt working.

1 Like

At first, i can send you a cam for free, If i get the cam later back. I have not paid for the cam, i get this from xsense to made a Video about it.

I think all data is interesting, for one more for the other less. What you don’t need, you can hide.

Can it be that no more than one can log into the xsense account? I tried to log in with 2 cell phones at the same time, I didn’t work.

That would be very nice, but you can also just share your camera via the app. If you don’t use it to guard your personal stuff and the stream is suitable for sharing, that would even be easier.

Can I find your review somewhere? I’m curious about the quality of the camera.

You cannot login more than once to the same account, but it is possible to make a second account and invite that account to view your devices. I did that for home assistant as well.

1 Like

The cam is still on the way, it will be here in 3 days, yes i can share it. i will test it

there is a video, but its not mine-

the cam do not need th hub.

1 Like

I had the same problem for connect 5 phones for check 7 temperature sensors, i got around the problem with send a share link through the base station on other mailbox.

It works for me ! :star_struck:

Temperature, humidity, battery is good

Very good job Theo !
with your help, it’s really simple to add the component on my HA.

one thing, when activate the component, we need to enter our login/pass but no field descriptions appear, it’s superficial detail :wink: