Conversation
|
EDIT: Done 👍 I did link to @AK5nowman's WyzeSenseUpgrade project... I hope that's ok 😅 |
|
|
||
| class SensorEvent(object): | ||
| def __init__(self, mac, timestamp, event_type, event_data): | ||
| def __init__(self, mac, timestamp, event_type, event_data, pkt=None): |
There was a problem hiding this comment.
This will let us pass the payload to the logging easier in the event of adding new devices in the future.
| Packet.NOTIFY_EVENT_LOG: self._OnEventLog, | ||
| event_data = pkt.Payload[10:] | ||
| event_type = event_data[4] | ||
| battery = int(event_data[2] / 155 * 100) |
There was a problem hiding this comment.
I'm really guessing here on the battery level for the keypad...
The max value I could get from it was 155, with brand new batteries, and swapping out the oldest batteries I had laying around gave me a minimum value of 142, so I don't know that this calculation is quite right, but it's still open to change.
29d1245 to
45df4a7
Compare
|
Though this is mostly all working, I have a couple more features I'd like to try to get working, so I'm converting it to a draft. |
b4072c7 to
45df4a7
Compare
e97858f to
17ff5d8
Compare
|
My latest commit (17ff5d8) sets this up to follow the state delay timings as described here: https://www.home-assistant.io/integrations/manual/#state-machine Unfortunately, I'm having an issue where the state is not updated quickly enough, because the process are being blocked by That being said, reverting back to 5b98a7e, and this was pretty stable from my testing. I wanted to try and implement the delay timings so that (for example) the keypad wouldn't arm immediately when pressed, giving some grace period while walking out the door, for example. |
raetha
left a comment
There was a problem hiding this comment.
These look good to me, nice job on the cleanup and adding support for the keypad. Unfortunately I can't directly test them as I don't have any of the newer sensors, still seems like Wyze isn't selling them without signing up for the HMS. I also didn't have time to fully read all code, but it looks good and as long as you are able to test things I'm happy. Feel free to merge whenever you are ready.
|
After playing with Alarmo for a couple days, I think this needs a bit of rework. While this is mostly functional (save for the race condition I still haven't nailed down when trying to cancel out of a Alarmo allows to set MQTT topics which it will subscribe and publish to, which allow it to interface with an external keypad or other MQTT source. This should actually be mostly possible with the current changes, but I think it would be simpler to allow Alarmo to verify codes, determine states, etc... So I'm going to look into reworking this to respond in a way that Alarmo can easily parse. Ideally, this will make it easy to integrate into Alarmo, Home Assistant (without Alarmo), or other home automation systems, with minimal configuration on any side. |
I don't want to add unnecessary comments to this discussion, but I just had to say, thank you so much for your work on this! Especially when most others have given up on attempting to implement future Wyze products/services (I don't blame them) into Smart Home Hubs such as Home Assistant. |
|
Thanks @kalyway101! I honestly ended up with the HMS "starter kit" because I had a few of the old Wyze Sense sensors that went bad, and that was the only way to get the V2 sensors at the time. I wish we could get better integration with the Sense Hub, as it has a siren (and a speaker?)... but I don't think it would be possible given what we have right now. |
Any chance we could get the keypad integration merged into main, with the aforementioned disclaimer regarding the race condition? I do think it could be easily remediated with a custom blueprint/automation within HA, and I've already begun working on a potential solution. Thanks so much! |
|
@drinfernoo I just took the huge set of fixes and updates from @nabahr which changed a fair amount, and may have included some, but not all, of this PR. Could you rebase and then resubmit this PR? I know some folks wanted this, even with the race condition issue that I'm not sure you ever solved. Alternately, if you resolve the conflicts we can take this existing PR, just might be safest to start clean. |
|
@raetha Oh my gosh! I kind of feel off of smart home things for the better part of the last year 😬 I've recently gotten back to it, and when getting my sensors and stuff set back up, I thought to check here... I'll definitely try to find time to get this (or some equivalent) PR worked out. I've been using the V2 (contact and motion) sensors for ages, and am quite happy with them. I even had a few run completely dead, and changing the battery got them back online without even re-pairing! I'm wondering if anyone has been able to get the HMS base station working, as it'd be really sweet to use as an alarm, but I'll stick to trying to figure out the keypad for now 😅 |
…yzesense2mqtt into drinfernoo-dongle47
|
Hmm... I think I made a mistake while rebasing. I've got a lot of unrelated files now 😓 I'll try to get this working another time soon! |
|
@drinfernoo Yeah, it looks like there's even some conflict markers committed here... I've got one of the keypads too, so maybe I can play around and get this working with my dongle. Not sure if I can get the firmware flash working. |
|
Just thought I'd drop these here, some payloads I grabbed from the keypad: Pin start (only fired on the first pin entry): Pin confirm (pin 1234, fired after checkmark pressed): Pin confirm (pin 5, fired after checkmark pressed): Press disarmed: Press home: Press away: Keypad motion active: Keypad motion inactive: Keypad alarm (only fired after holding alarm button, a single press does nothing): The "cancel" button seems to never fire events, regardless of any other state, and the "confirm" button only fires an event if there is a pin entry. The "cancel" button does clear any previous pin digits that were input between the last time either "cancel" or "confirm" were pressed; there just isn't an event fired. The "pin confirm" event has the first digit in the "state" byte ( Great work on figuring out this initial payload @drinfernoo! I am going through and adapting the changes from this PR to fit the new 3.x code, so just thought I would share what I found so far! |
|
Just to add to this, it seems like the "second to last two" bytes from the keypad are "number of events"... not sure if that's useful, relevant, or common to other devices yet. |
|
I also double checked today, looks like I have firmware EDIT: These are the earliest firmwares for both, not even listed on the changelog page 👀 |
@drinfernoo I just changed this PR to point at the devel branch which seems to have cleaned up a bunch of the "errant" unrelated files. So I think it now shows more cleanly what you are working on. Definitely verify before we pull it into the devel branch though in case something is non-obvious! |
|
@drinfernoo Just checking if this was ready to merge once I changed the base and the changes are more obvious. Can you let me know when you get a chance? Even if not perfect, if it's partly working that will get this out there for others to test as well. |
@raetha Hey, I still need to go through and fix the merge conflicts... Definitely don't want it going in like that. I'll try to get that done this week! I have started to have some additional second thoughts here though, as I had a go at setting up the keypad in the Wyze app, and found that there is a bunch of functionality dependent on the Hub being able to send packets to the keypad 😮💨 Seems a bit obvious in retrospect, but I had never actually tried this for myself. |
|
@raetha I actually had a computer failure in the last week, and haven't been able to get back to this. Hopefully I'll be able to soon. |
|
@drinfernoo No worries at all! Sorry to hear about the computer failure, those are never fun, hopefully you have good backups of at least the important stuff. I'm not in a rush on this or anything, just hoping to clean up some old things for v3.1. My home setup isn't really working at the moment so I can't test much but when I found out others are still using this I wanted to stabilize things as best I could! :) |
This PR adds support for only the Sense Keypad, when using this firmware, flashed to a Sense V1 bridge dongle, via the WyzeSenseUpgrade project. It is (or was?) also possible to dump this firmware for yourself by following these steps by @HclX.
I would like to also support the V2 leak and climate sensors (like #61 attempted to do), but I don't have them available to test with, so I've excluded them from this PR in particular. I have done considerable refactoring in an effort to make them trivial to add support for, if that opportunity ever comes, but have stashed their code away for now.
In addition to simply supporting them, this adds full support for MQTT auto-discovery by Home Assistant:
alarm_control_panelentity for the panel itselftriggered, which can only be controlled from the physical keypad. It is detected properly inside of Home Assistant when activated on the keypad.)binary_sensorfor motion detectionsensorentities for battery level and signal strengthKeypad devices can be configured in
sensors.yaml(and are added automatically when paired, defaults shown below):classmust bealarm_control_panelarm_requiredworks as described heredisarm_requiredworks as described hereinvert_stateacts on the motion detection, similarly to the current behavior of regular sensorspinmust be a string of digits, but can be any length. Setting this to'REMOTE_CODE'will allow Home Assistant to send any PIN towyzesense2mqttfor validation.expose_pindetermines whether or not to expose the last PIN as an entity and in the MQTT brokerThis PR, though containing significant refactoring, should not affect the behavior of other sensors (either already paired ones, or ones added in the future).