Wyze sense sensor integrations

Okay it seems to boot up now and see my sensors but i am not seeing any open or close or motion. I see the lights change status on the motion and the contact sensors.

Update: I was able to use the wyzesense.remove and removed each sensor one at a time. Then I ran wysesense.scan and added each device back on at a time. They are all showing correctly in home assistant now. The only thing I am not seeing is the red light on the motion sensor when it detects motion. No big but would be very helpful for trouble shooting.

@MediaCowboy Interesting that you had to remove and re add them. That’s the exact issue one of my testers was experiencing but I didn’t explore that solution with them. I think the problem might come back after a restart but thank you for that information!

And regarding the red light on the motion sensor. That shouldn’t really be affected by the code but I’ll see if I can reproduce it. It may just be that you’re in the 40 second window after it recognizes motion once. In that period it won’t report another motion event.

Gonna be pretty busy this week but I’ll try to get an updated version out (only if I can figure out why it’s slower than gosense too). Otherwise it’s not worth having a slower implementation.

Mines not a very long delay. Maybe half a second. I’ll see if I can’t get a video uploaded. This has already sparked ideas of where to put sensors and automations.

I also just tested the light issue on the motion sensor again and same result. I will try a reboot and report back.

Yeah I mean overall it isn’t terrible. That’s the same I was seeing but I’d just like to get it as fast as possible. When using motion sensors for lights and stuff I feel like a half a second difference might get a little bothersome but that’s just my opinion.

Gonna ask in the ha backend dev discord for a code review to see if they can figure anything out.

Also I’m glad it has sparked some ideas! These sensors are dirt cheap and perform very well for their price.

I don’t think you should pause! Having options is always good!
In the meantime, I’ve added support as an addon for hassio, it is actually very handy since everything is handled right there!

If you want to try it (only for raspberry pi right now), please add the custom repository https://github.com/dariopb/hassio-gosenseaddon (Hass.io -> Add-On-Store -> Add new repo by URL). When the plugin is installed, (for now) you’ll have to disable “Protection mode” for the container to be able to read from the device. Edit the configuration to match your setup. The rest api should be available in 8080 (I’ll hook up the ingress and label integration later on).

Let me know!

@kevinvincent, I may have spoke to soon about the reboot issue. After installing HACS and community plugins, read several reboots, my sensors are back to not reporting. I do not think this is just an issue affecting you as my zwave and zigbee devices do the same. Biggest difference is they will reconnect after a new event happens, door opens or turning a smart light on and off at the switch.

Let me know if you want this as a issue submitted on github.

@MediaCowboy Interesting! By any chance are you running on a pi with hass.io? My tester whose experiencing that same issue is on that setup. I’m still trying to reproduce it on my side (i’m running off a ubuntu machine, on docker). If so I’ll keep working with my tester to debug it and let you know when I figure it out. Gonna be a busy week so probably this weekend.

@kevinvincent, I am running Ubuntu 18.04 lts, docker, and then home assistant. Could be I need to update the host OS but I run more then home assistant so have to do it after family goes to sleep. No rush as I fully get having a life outside of this.

@kevinvincent

Please don’t stop developing this module just because it’s a bit slower. It’s nice to have choices, plus the fact that it could be integrated into the core at some point is fantastic. No messing with extra docker containers and or another pi or additional software. I’m still waiting for my sense to arrive but from the videos the speed is fast enough even for motion lighting and I would be inclined to use your module as it’s easier to configure.

@MediaCowboy Looks like we have the same exact setup. I’ll have a chance to do some work on it tonight so hopefully I’ll have an update then.

@warllo54 This week’s been a bit busy but I’m definitely still working on it. The problem is also around stability after restarts which is one of my main concerns. The author of the original code to interface with the wyzesense hub recently updated it so im gonna pull those changes in and see if helps!

This is great! Amazing job @dariopb. Just spun up the docker container on unRAID and mapped it over without much effor at all. Thanks for the great work.

@MediaCowboy I did it! I found the cause of the delay and i’m happy to report that sensor state updates are now instant. I also feel like its more stable now as a result of the updated library (I haven’t been able to get it not to report). Can you try it out and let me know if the sensors report now? https://github.com/kevinvincent/wyzesense

This version is much “better” as in it pulls in the library from pypi instead of hardcoding it locally, it avoids a lot of issues with asynchronous state updates in HA, and finally it actually closes the connection to the wyze sense hub when HA restarts or exits instead of leaving it open which causes issues.

@kevinvincent, I will give this a shot tomorrow or extremely late tonight.

@kevinvincent Thank you for your hard work! I’m still on 0.90.2 and keep receiving this error when running check_config. I never have a config directory so I created one under ~/.homeassistant and follow the instructions. I’m using Rasbian. Any idea?


Failed config
  General Errors:
    - Platform not found: binary_sensor.wyzesense

Also try to put wyzesense under ~/.homeassistant/custom_components and receive same error as above.

Thanks for trying it out @quattr0. On Hassbian I think the final location will be /home/homeassistant/.homeassistant/custom_components.

Can you ensure that ~/ is /home/homeassistant not another user’s home? The custom_components folder should be in the same folder as your configuration.yaml

Did you also try restarting your instance? It may not have loaded the platform automatically.

Some progress…I guess

File "/home/homeassistant/.homeassistant/custom_components/wyzesense/binary_sensor.py", line 10, in <module>
    from homeassistant.const import CONF_FILENAME, CONF_DEVICE, EVENT_HOMEASSISTANT_STOP, STATE_ON, STATE_OFF, ATTR_BATTERY_LEVEL, ATTR_STATE, ATTR_DEVICE_CLASS, DEVICE_CLASS_SIGNAL_STRENGTH, DEVICE_CLASS_TIMESTAMP
ImportError: cannot import name 'DEVICE_CLASS_SIGNAL_STRENGTH'ESC[0m
ESC[31m2019-07-28 10:14:01 ERROR (MainThread) [homeassistant.loader] Unable to find platform wyzesense. Search path was limited to path of component: custom_componentsESC[0m

@kevinvincent, awesome work. I got around to updating the component this morning. Before I updated my motion was showing an error. Went ahead and updated and rebooted. It came back as off until I triggered motion. All the sensors seem to be instant now. Keep up the great work.

Hi @quattr0 I’m glad it found the component, may I ask what you had to do so I can fix my documentation and install instructions?

And that error is because your HA is a little out of date. Looks like the device class I’m using was was introduced about 4 months ago https://github.com/home-assistant/home-assistant/pull/22738 . So if you haven’t updated since then it won’t work. If you really really don’t want to update I can provide a modified file that will work with your version.

Didnt do anything else except putting it in /home/homeassistant/.homeassistant/custom_components

If you won’t mind…I would like to receive that modified file. If it will take you some time then, don’t worry about it. I’m afraid to upgrade at this point as everything is working to my liking. I will need time to test the new version before doing the upgrade as I have a spared machine.

Thanks!

@quattr0 Ah okay thats good. I’ll update my documentation to specify the full path for non hass.io installations.

The modified file is here: https://gist.github.com/kevinvincent/375a063723ecd8b0b06943e3d28ebc93
You’ll have to replace binary_sensor.py in custom_components/wyzesense/ with the one above. Let me know if you run into any issues with it (I’m not able to test it since I’m on the latest version).