-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Sense Keypad #63
base: master
Are you sure you want to change the base?
Conversation
EDIT: Done 👍 I did link to @AK5nowman's WyzeSenseUpgrade project... I hope that's ok 😅 |
@@ -226,71 +231,115 @@ def AsyncAck(cls, cmd): | |||
|
|||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Thanks for the feedback @raetha! Unfortunately I don't feel like this one's going to be ready to merge until I can figure out the race condition in my delay process... Seems like being able to delay arming and triggering is a big deal that would be broken/nonexistent if I merged now 😫 |
@drinfernoo, are things mostly working? Without the right hardware I can't really help on the race condition, but if it's like 90% of the way there, you could update the readme saying that piece is a work in progress and has some issues, then merge. Maybe someone else would even see it and be able to help with the race condition aspect. As a side question, just because I haven't been able to keep up reliably, what is the actual issue you are seeing, maybe I can spot something, even if I can't test. |
Basically, the only thing that's not working, as far as I can tell, is "canceling" from a "pending" state. What happens is that if the system is armed, and a The bit of code I have for this (https://github.com/drinfernoo/wyzesense2mqtt/blob/1d0b7f7347b517008ef16a8487d9285c157df6ac/wyzesense2mqtt/wyzesense2mqtt.py#L640) uses the new method I added ( For the time being, this means there isn't a way to disarm the system before the alarm gets triggered, like when returning home (where you might expect to have a grace period to do so), for example. Writing this out, I guess there is also no mechanism at this point to cancel out of the "triggered" state either, so once triggered, it will stay that way for the specified |
I'm planning on testing this out during the week, in order to integrate it into Alarmo for Home Assistant. There is a Z2M -> Alarmo blueprint (by the author of Alarmo, in fact), and I should be able to get this to work with that (or a similar) blueprint, so that we can use the physical keypad with Alarmo for better integration into Home Assistant. However, I still haven't really been able to figure out how to effectively "cancel out" of a @AK5nowman or @raetha, any ideas on that? |
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! |
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_panel
entity 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_sensor
for motion detectionsensor
entities for battery level and signal strengthKeypad devices can be configured in
sensors.yaml
(and are added automatically when paired, defaults shown below):class
must bealarm_control_panel
arm_required
works as described heredisarm_required
works as described hereinvert_state
acts on the motion detection, similarly to the current behavior of regular sensorspin
must be a string of digits, but can be any length. Setting this to'REMOTE_CODE'
will allow Home Assistant to send any PIN towyzesense2mqtt
for validation.expose_pin
determines 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).