[RELEASE] Alpha WyzeSense Integration [Code no longer being updated]

Could be faulty sensors? Not sure... do your devices show up in the device list in the WyzePy app? (the software that you pair/unpair sensors with)

Like I said previously, generally those question-mark/diamond characters come up when you have character set problems. My code is written with the expectation of en_US UTF-8 on your Pi... if you don't have that (or at least a UTF-8 character set, NOT ISO-8859) then you may have problems. You can find what you have by running the raspi-config program on your Pi and going to Locality settings. By default the Pi is running in en_GB with a English (UK) keyboard layout.

I am still experiencing the Bridge just stop registering any of the motion or contact sensors. I have a Rule that if none of the Wyze Sensors report for 6 hours, it sends me a notification that the bridge might not be working. I then go and disconnect telnet, reconnect telnet, and restart bridge and that fixes problem.

This device handler requires a fairly robust network to work effectively. Because it requires an 'always-on' telnet session to work, if you have even the slightest packet drop in your network then you're going to have problems. If you're running your Pi on WiFi, you're likely going to have problems as well. Unfortunately telnet, as a protocol, really sucks but that is what we're stuck with. I have a Lutron hub and unfortunately it uses telnet as well. I've ran both of these out of my C-5 Hub without any drops for multiple weeks -- all of my devices are connected to Ethernet though and my main switch is a Unifi enterprise-class switch.

First, any suggestions on why the bridge would stop? Second, is there any way within the driver that it can check that and warn the user immediately when it becomes unresponsive?

Packet loss or latency on your network. Telnet isn't as resilient as SSH or other console protocols. As far as alerts, sort of. My suggestion would be to modify your device handler so that it automatically runs the reset command when it detects that the telnet session is down or it has been X seconds since the last message received. Since I'm not having this problem, it's a little tough to write that and actually test it properly.

Barring that, I am curious if there is a way to automate disconnecting telnet, reconnecting telnet, and starting the bridge? I noticed in the driver that there is a command line for Raspberry pi "sudo reset && sudo sh -c ${wyzeSensePyScriptPath}/hubitat.py". Does that stop then restart the bridge?

See most of the previous statement :slight_smile: . The 'sudo reset' just resets the terminal session because Hubitat gets a little wonky with it. The '&&' is appending the next statement. The 'sudo sh -c ${wyzeSensePyScriptPath}/hubitat.py' tells your Pi to open up a new shell and run the command ${wyzeSensePyScriptPath}/hubitat.py which is the listener script that it scrapes. The variable wyzeSensePyScriptPath is filled in by the device handler when it sends the command to the telnet session. The 'reset()' command in the device handler just drops the telnet session altogether and resets the appropriate session variables in the handler. This would be sufficient to call when you issue a reset in NodeRed or whatever automation tool you'd like to use.

Feel free to edit your device handler and application on your Pi -- it won't hurt anything! If you have an error, it either won't work or the IDE will just say 'fix yo crap' before it saves :slight_smile: . This is the beauty of open source: if it doesn't meet your needs, change it! :smiley:

I am running my Pi 4 on an ethernet connection and I too have Lutron running. Unfortunately I am not so lucky with the reliability.

Since I have never even written a simple device handler, the chances of me being able to modify anything that you have written are as likely as me learning Mandarin Chinese. :laughing::laughing::laughing: If I am understanding what you are saying, I can't screw anything up by setting up an Exec node in Node Red that runs the "sudo reset..../hubitat.py" command if everything goes dark. I am equally a newbie on Node Red as I am with Hubitat.

I

I bet i could $&%* up your crap if I were to get into your device handler and start making changes. :smiley: I was just pure luck that I recognized "sudo" as a common command when using the Pi and determine that it did something important.

Thanks again your work on this project.

In the past week the systems has been working good for me and I have had no issues with devices not working or issues with the WyzeUsb not being connected. I use wireless on my PI and have no issues pairing or unpairing devices and I also would like to mention that the range has been good. I have also not turn off the Telnet or bridge connect when pairing device or unpairing devices and had no issues. Like I said I live in a two story home and before this I had five Wyze camera with a bridge on each to add the motion and contact sensors and now just to the PI. I like to and want to thank @kellykoehn128 for taking his time and putting this together for us.

@kellykoehn128 Excellent work on this btw!

This is almost working perfectly for me, minus one small thing. When the contact sensor is closed, it reports as "close" instead of "closed". So rules that expect a contact switch to say "closed" don't work. The tile in the dashboard, attached pic, says "close" so the tile doesn't understand either. Along with the status of the device itself, always shown below.

Thoughts?

DoorSensor.DoorSensor2

Edit
So in the Telnet driver there's the following.

}
if (sensorType == "switch") {
if (sensorState == "close") {
sensorState == "closed";
}

Unfortunately I'm not intelligent enough in that area to understand for sure what that says. My guess, it's saying if the contact reports "close" that it means it's "closed". Just a guess, anyway. So I still would appreciate some assistance if someone out there has an idea.

Based on your post, I looked and have the same thing. All of my warnings for my contact sensors are for if it changes to open not if it changes to closed so I didn't notice.

That bit of code was supposed to fix this scenario but for whatever reason it isn't applying. The contact switch from Wyze sends the state 'close' but Hubitat wants 'closed'... it was just a variable change.

Let me test on my contact sensors and see what needs to happen.

Alright I should have a fix for it. I'll get it uploaded shortly to the repo but here are the changes if you want to make them:

After sensorSignal = sensorSignalArray[1]; around line 111, add the following (right above the log line:

if (sensorType == "switch") {
   if (sensorState == "close") {
      sensorState = "closed";
   }
}

Next, go to the section around line 130 that says if (sensorType == "switch") and remove the if statement that follows talking about the close and closed. We just want to send the child event here and that is it.

The root of the problem is that I had an extra equals sign when setting the sensorState variable and that messed things up. I'll update the repo in a bit if you guys just want to recopy the entire driver instead. All you have to do is edit the driver and save -- your telnet driver will take the changes right away.

@kellykoehn128 Perfection! Thank you so much!

I wanted to post again and to say that I am 99% sure I figured out why I was having the sensors just stop working without warning and I hate to admit IT WAS MY FAULT!!!

I was not going to device and restarting Telnet and Bridge after re-booting hub. UGH!!!!

In the device screen, it still said that the Telnet Session and the Bridge is connected after reboot when it really isn't.

1 Like

Thanks to @fblackburn creating Hubitat nodes in Node Red, I was able to figure out a way to Disconnect Telnet, Reconnect Telnet, and Start Bridge in a Node Red Sequence. I could never find the commands to do so in RM under Custom Actions.

Now, I have a sequence in Node Red that tells me if none of the Wyze sensors have reported activity in 4 hours and then again at 6 hours. I can then just flip a virtual switch and it will restart the Telnet & Bridge connection. I have also set up a Rule that flips that switch 2 minutes after a hub reboot. Of course, now that I have all of this backup for a failure, it's running like a charm and I haven't needed it. KNOCK ON WOOD!!!

Once again, Great Integration!!! I am surprised more people haven't commented on their use of it. You can't beat the price of the Wyze sensors and door contacts and they have been as fast as hoped using this integration

I’m glad it’s working great for you! Mine has been exceptionally stable, even with a few additional sensors. I’ve got two WyzeLocks on the way so that’ll be the next project.

1 Like

NOOOO!!!!! YOU ARE NOT ALLOWED TO INTEGRATE A WYZELOCK BECAUSE THEN I WILL BE FORCED TO BUY ONE AND I AM ALREADY TEMPTED. I DON'T THINK MY MARRIAGE WOULD SURVIVE IT THOUGH. :grinning:

I have a mixture of 10 door contacts and motion sensors running with another motion sensor sitting in a box waiting for a need.

I use this alot and have replacement all my windows contact sensors and use all Wyze contacts and they are doing a good job. Thanks goes to @kellykoehn128 for doing this and I'm for the Wyze locks as I already have one and I like it and it works great. @stephen_nutt can you share how you set up the node that you have set up for pi? Thanks.

You will need to add the following pallets:
node-red-contrib-hubitat (@fblackburn's hard work: Node-RED nodes for hubitat)
node-red-contrib-mytimeout
Some sort of notification method. I use Join on Android.

I added Hubitat Device Nodes for each Wyze Sense device. Basically, I have it setup so that any activity from any of the Wyze sensors will reset the mytimeout timer. The mytimeout timer allows you to send on a message at a warning threshold and final. I use a 4 hour warning and 6 hour final and get a text message at each point.

Then, in Hubitat I created a virtual switch called WyzeSense Rebooter. I next created another Node Red Sequence that triggers when WyzeSense Rebooter turns on (it turns off 2 seconds later automatically). That triggers a Hubitat Command Node that disconnects Telnet, waits 10 second, triggers another Command Node to reconnect Telnet, waits 20 seconds, then a 3rd Command Node to restart bridge.

If you do this, your Hubitat nodes will look different. In the original, all of the nodes are the same color but have different icons. I change it so that the backgrounds for each node type are different but all have the Hubitat logo icon. Blue are device nodes and red/orange are command nodes. I don't use them here but my Mode Nodes are yellow. It makes it easier for me to distiguish the node types.

I am new to Node Red so this might not be the quickest and most efficient way to do it but it works. You could probably do it with a lot less nodes using Function Nodes but to me, if I am using a Function Node, I am going against the point of Node Red being a graphical way to create code. Plus I have no idea how to write JSON.

Finally, even if you decide that you don't want to do this, I highly recommend going ahead and downloading the Hubitat pallet that @fblackburn created. It has simplified a bunch of the sequences that I had already created using HTTP requests and allowed me to make new sequences that I wouldn't have attempted otherwise. I believe that I have been able to take a lot of stress off of my hub. That thread I linked to has lots of great info and is over 400 posts long as of today.

1 Like

@stephen_nutt Thanks for the info. I will work on it this weekend, by the way are you using it on the same pi that you have the Wyzesense on?

I only have a Pi Zero running Pi-hole (as 2nd DNS) and then a Pi 4.it is is also running Pi-hole as 1st DNS address. The Pi 4 has Node Red and WyzeSense on it and haven't noticed any issues. If thw Pi 4 fails I have bigger issues than WyzeSense because I converted about half of my HE Rules to Node Red flows

@stephen_nutt thank you for that info. Right now i'm only running an Pi 3B+ and like it and was considering a Pi 4. I'm going to put the Node Red on the Pi that I have and run it that way. Is making a Node Red flows easy or hard ? Thanks

It's easier than learning JSON I would imagine. Check out the thread linked above about the Node Red integration. IT'S A LONG READ!

@stephen_nutt Thanks for the help on the node red. I finally got it working where I can see the Wyze motion, etc working. Can you share how you did the node "msg.payload" in green and the one that "set.msg.payload" in yellow? Thanks