Wyze sense sensor integrations

I have these sensors working with the above python library and the Wyze Sense hub plugged in via USB on my HA machine. Gonna take a shot at writing a component this weekend. Fingers crossed!

3 Likes

I have a working golang integration for the sensors via MQTT (by hand and via mqtt discovery). Let me know if there is interest for alpha testing it, otherwise I’ll post it over the weekend.

Sorry I missed your message here, I did indeed find the signals in that spectrum so it makes a lot more sense now! I had to table working on this for a bit but it looks like plenty of work is moving forward on it!

I’d love to take a look at how you’re doing this. Unfortunately, I have 0 background in hardware or doing byte level manipulation so though I may be able to create a working python integration using the above library, there is no way I’d be able to maintain it or debug things if stuff breaks. Though ideally since this is direct access to the hardware, no over the air updates are possible which increases the chances of stability.

Quick Update. I have a wyzesense platform working! Here’s a sample log line of the component receiving an “alarm” from a contact sensor:

2019-07-12 22:32:00 INFO (Thread-2) [custom_components.wyzesense.binary_sensor] ALARM: time=2019-07-12T22:31:59.192000, mac=b'777B242C', type=A2, data=01 13 5f 00 01 01 00 25 35

Just have to figure the correct logic around when to add entities (the type of sensor isn’t known until the first motion or contact sensor activation) and I’ll have an alpha version out for people to test :slight_smile:

4 Likes

Quick update as well. I have an alpha for a sense-MQTT integration that is working for me and could be useful for others. I published docker images (both x64 linux and raspberry pi) for that application. Please take a look here for a how-to: https://github.com/dariopb/ha-gosenseapp (I’m still in the process of pushing the code but I’d like feedback about the docs and the functionality in the meantime).

2 Likes

I shared the application (docker images/instructions) and late today/tomorrow I’ll push the code as well in the github repo (this is my first contribution here and I don’t know where to “advertise” it to get more people to try it…)

3 Likes

Nice! Looks like you even got the ALARM messages decoded. Have you noticed any latency issues with MQTT? That was the biggest reason I wanted to try to implement it in python as an HA Platform. Well, that and I thought a platform might be easier to install. If there are no issues there I’ll probably stop working on the python version since yours is much further along. Any chance you could package it as a HA add-on?

@kevinvincent, I’m not seeing any noticeable delay using mqtt (I don’t have a lot of sensors though and I have a dedicated pi for the mqtt server).

I have a question about attributes for a sensor: is there a way to assign/discover custom icons and “units” for all the discovered attributes for the mqtt integration?

This is what I’m getting with my current one:

image

and I would like to get something like this:

(I’ll post this question as a separate topic as well)

@dariopb Try setting the device_class attribute in the MQTT Binary sensor. It says it should update the icon: https://www.home-assistant.io/components/binary_sensor.mqtt/#device_class

Also an update for anyone interested in the python platform: https://www.youtube.com/watch?v=ZEYEgUbraWU&feature=youtu.be
It works! Gonna do some more testing and release in a few days.
@dariopb Are you seeing that same delay in my video above when opening a contact sensor? Closing is lightning fast but I think the sensor delays opening a little bit in order to debounce.

3 Likes

I would prefer the python version docker but love seeing both options.

Thank you @KevinVincent & @dariopb.

2 Likes

Yeah I continued working on the python HA platform and have it pretty well integrated: service calls to add and remove devices, set assumed state at start, battery and signal strength, one option in your configuration file is all thats needed to setup, etc.

I’ll continue to test it for stability over the next day and release an alpha custom_component for people to test out.

@dariopb your decoding of the ALARM message was super helpful along with your Sensor delete code as the python code I based mine off of was missing working implementations of both.

3 Likes

@kevinvincent, I’m not getting any “noticeable” lag… here is what I see: https://photos.app.goo.gl/6THfbsXgL4saDd2N7

@dariopb Interesting… I’m seeing a tiny lag. I wonder if it’s just because python is gonna be naturally slower than golang. Gonna try your project out later to see if it is just my machine.

I don’t think the speed difference is going to be that noticeable… FWIW, when I tried the python application, I didn’t see lags either. Are you getting the same with multiple sensors?

Yeah I have 3 sensors hooked up (the starter kit). I was seeing some lag when using your container too so it might be something about my hassio setup / machine / the fact that there a bunch of other hubs in proximity to the Wyze hub or something random.

I think you’re right though, it’s not super noticeable unless you’re looking for it

EDIT: I tried the original python app again and I’m seeing the same lag. So its gotta just be my machine.

@dariopb

I’m trying out your docker container with a wyze sense start pack that I’ve never used before.

I’m a bit confused though, how does the rest api work so I can send the command to add new devices?

thanks!

duh feel like and idiot - just found the interface open on 8080

Did you get it to work? Yes, there is an http endpoint listening on port 8080 and when you hit the http://xxxx:8080/sensors/scan endpoint, it will put the dongle in pairing state for 30secs. If you press the button in the sensor during that time you should get back the new paired sensor (the call won’t return during those 30 secs until it pairs or times out).