SecKatie / ha-wyzeapi

Home Assistant Integration for Wyze devices.
748 stars 114 forks source link

[Feature Request] V3 Siren #144

Closed eiiot closed 2 years ago

eiiot commented 3 years ago

Would it be possible to add a toggle for the V3's Siren? There's a switch in the settings of each camera. It would be an easier way to control it than tasker :)

SecKatie commented 3 years ago

Oh, that is super cool! I didn't know that was even a feature 😅

I will look into it! Might be good for a Home Assistant security system!

eiiot commented 3 years ago

Any updates on this? I'm still clicking the button manually using tasker lmao

SecKatie commented 3 years ago

Not yet. Working on other items. In particular, making the integration faster

JoeSchubert commented 3 years ago

This has actually been added to some of the other firmwares as well now... V2 and WCO cameras both have it now.

I don't know of a clean way though to have 2 switches on one device in HA. Maybe 2 entities for the device, one for power and one for siren?

SecKatie commented 3 years ago

@yoinx you can totally have two switches on one device. We just have to make sure that the device unique id is the same for both but they each have a different unique id

JoeSchubert commented 3 years ago

"action_key": "siren_on" "action_key": "siren_off"

not entirely sure how they're determining if the device has the ability from the API. But I think that they're just doing a model check. Currently, the V3s and the Wyze Came Outdoors support this. Which should be "WYZE_CAKP2JFUS" and WVOD1

Also, if we do add this... I would highly recommend that it not be something that we poll to check the state of unless we're can find its state in an existing poll. It would basically just be an on/off switch that would reflect the state as it was set through HomeAssistant. So, if you turned it on through Wyze's app you would end up in a desynced state.

We're starting to have to manage how much load we put onto Wyze's APIs.

eiiot commented 2 years ago

Any updates on this? I haven't found any way to control the sirens other than tasker & autoinput which is a pain...

JoeSchubert commented 2 years ago

I actually have written the code for it, but we were rethinking our merge process for the project so it hasn't been implemented yet. I can provide commits if you know how to pull them in manually to test it. However, it should be in a beta version soon hopefully.

eiiot commented 2 years ago

That's great :)

Thanks so much for all the work you're doing on the project. It's one of those things that I literally use every day so I appreciate how responsive the community is!

JoeSchubert commented 2 years ago

That's great :)

Thanks so much for all the work you're doing on the project. It's one of those things that I literally use every day so I appreciate how responsive the community is!

Great to hear!

Personally, I only use the integration to toggle my lock automatically when I get home since the Wyze app really sucks for that. But I'm glad people use get more use out of it. Kinda hard for me to test everything, side I don't use it for any of that functionality.

eiiot commented 2 years ago

I also realized that this could be implemented using rules, but it appears they aren't working right now? Or was that removed because of API limits?

JoeSchubert commented 2 years ago

I also realized that this could be implemented using rules, but it appears they aren't working right now? Or was that removed because of API limits?

Last I knew that code became broken (I think) and the contributor that provided it hasn't updated it. The rules in this integration were from before I got involved though.

I've already implemented an entity to toggle this, the PR is just waiting for the PR in wyzeapy to be merged, since is not going to work without it.

eiiot commented 2 years ago

That's awesome, thanks again!

LordNex commented 2 years ago

I still wish I knew how your getting the lock to work as I was one of the contributing members for that. I have my lock paired with ZHA so everything stays local but it gets out of sync if anyone uses the app or the keypad on the outside. I wish I could find a way to use the keypad locally as well and then just do away with its connection to Wyze since I already have my cameras RSTP’d, all except my WOC

Benjamin T Powers

On Nov 10, 2021, at 1:12 PM, Joe Schubert @.***> wrote:



That's great :)

Thanks so much for all the work you're doing on the project. It's one of those things that I literally use every day so I appreciate how responsive the community is!

Great to hear!

Personally, I only use the integration to toggle my lock automatically when I get home since the Wyze app really sucks for that. But I'm glad people use get more use out of it. Kinda hard for me to test everything, side I don't use it for any of that functionality.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/JoshuaMulliken/ha-wyzeapi/issues/144#issuecomment-965657155, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACGXNJHPBSXT4DVPXW3KBX3ULK7YPANCNFSM43JU3HIA.

JoeSchubert commented 2 years ago

I still wish I knew how your getting the lock to work as I was one of the contributing members for that. I have my lock paired with ZHA so everything stays local but it gets out of sync if anyone uses the app or the keypad on the outside. I wish I could find a way to use the keypad locally as well and then just do away with its connection to Wyze since I already have my cameras RSTP’d, all except my WOC

Sounds like an issue because of ZHA then. Is ZHA pushing the updated status to the server, or getting it from the server? If not, you're always going to have issues if someone unlocks through the app, since it's not telling ZHA that it unlocked.

If ZHA was querying the lock, and had a route to exchange that back and forth with this integration (though no effort would likely go into that happening) you wouldn't have that issue, nor the issue with the keypad.

The lock works perfectly fine, through this integration, through wyze as the integration assumes that you're using it given that the integration queries wyze's servers for everything... I don't have any sync issues with it whatsoever.

eiiot commented 2 years ago

Saw the PR got merged, thanks again!

JoeSchubert commented 2 years ago

It did, but it's only merged into a development branch right now. It'll be there for a bit before it makes it into a beta. We changed our git flows up a bit so that I could guide and merge into development and those changes could move from there to staging for beta's, then over to main for stable releases.

If you want to test them from development and you know how to do that, awesome (you need the wyzeapy changes though for it to not implode). Please give feedback so that things can be addressed in development. Otherwise, hopefully the beta will have it soon :)

eiiot commented 2 years ago

I'm not 100% sure on how to test the dev, although I've done it on other integrations, so I'll try to figure it out. I'll let you know if it works

eiiot commented 2 years ago

Okay, don't want to bother you about this too much, but If I'm correct, I can just merge the files from the #develop branch of wyzeapy with the files from the #develop branch of ha-wyzeapi? From what it looks like, they are both just sitting in /custom_components...

Edit: Or do I need to change from wyzeapy import Wyzeapy?

I don't use python much so I really don't know what's going on lol :)

JoeSchubert commented 2 years ago

So... Things that need wyzeapy changes are a bit trickier to test. You would actually have to overwrite the files in site-packages the path should be relative to your home assistant directory, though the python version could possibly be something other than 3.8 I suppose.

homeassistant/deps/lib/python3.8/site-packages/wyzeapy

Personally, I do all my testing in a vscode devcontainer. Which can make it hard to test things long term.

WyzeApy shouldn't be in custom components at all

eiiot commented 2 years ago

The folder in custom components is called wyzeapi, not ha-wyzeapi (for some reason).

I'll give this a shot and let you know about any bugs!

eiiot commented 2 years ago

Oh interesting, homeassistant/deps is empty - it may have to do with running container?

JoeSchubert commented 2 years ago

No idea. Maybe it's a different type of home assistant? I run a container as well.

ghcr.io/home-assistant/raspberrypi4-homeassistant:stable

Is what I'm running. So maybe you're running supervisor or something.

eiiot commented 2 years ago

Definitely running container... Interested to know why it might not be working.

I guess I'll just wait for the beta :shrug:

System Health

version core-2021.11.1
installation_type Home Assistant Container
dev false
hassio false
docker true
user root
virtualenv false
python_version 3.9.7
os_name Linux
os_version 5.11.0-38-generic
arch x86_64
timezone America/Los_Angeles
JoeSchubert commented 2 years ago

Definitely running container... Interested to know why it might not be working.

I guess I'll just wait for the beta 🤷

System Health

version core-2021.11.1 installation_type Home Assistant Container dev false hassio false docker true user root virtualenv false python_version 3.9.7 os_name Linux os_version 5.11.0-38-generic arch x86_64 timezone America/Los_Angeles

Looks like you're a couple versions behind.

System Health

version core-2021.11.4
installation_type Home Assistant Container
dev false
hassio false
docker true
user root
virtualenv false
python_version 3.9.7
os_name Linux
os_version 5.10.63-v8+
arch aarch64
timezone America/New_York

If you've never seen/used it. There's a container called "watchtower" that will auto update your container images whenever there's an update.

Highly recommend it. Simplifies keeping up to date to alleviate some of the concerns of missing updates

https://containrrr.dev/watchtower/

JoeSchubert commented 2 years ago

ok... so I'm apparently an idiot. The location that I gave above for the installed wyzeapy library files is not right. During testing for the update_manager breaking, I had to go in and pull some files manually since it's a slow breaking bug...

You can find your wyzeapy location by issuing: pip show wyzeapy

which should show something like: Name: wyzeapy Version: 0.5.1 Summary: Python client for private Wyze API Home-page: https://github.com/JoshuaMulliken/wyzeapy Author: Mulliken LLC Author-email: joshua@mulliken.net License: UNKNOWN Location: /usr/local/lib/python3.9/site-packages Requires: cchardet, aiohttp, aiodns Required-by:

in that location, there's a directory for wyzeapy that contains the files. If you're running home-assistant in a docker container, you'll need to access the container first by using: assuming that your contianer name is "homeassistant" the command for that will look like:

docker exec -it homeassistant /bin/bash

so if you're trying to pull in specific changes from github, you can go into that directory then do

curl -O url_to_raw_file

this will overwrite that file, and it should be replaced next time pip updates the library. Unfortunately, these are installed packages not git repos, so you can't just checkout the changes from git... you have to pull the file that has the changes (or manually edit them there if they're small changes). Then, restart the machine/docker container for good measure to make sure you get the changes in the library.

JoeSchubert commented 2 years ago

This should be live in the new beta.

Version 2021.12.1b1

jscherry commented 2 years ago

Very cool. Have sirens on V2, V#, and outdoor cameras. Do the pan cams not have sirens?

JoeSchubert commented 2 years ago

Very cool. Have sirens on V2, V#, and outdoor cameras. Do the pan cams not have sirens?

I've never seen the option for them in the official app, so even if they did I would have no way to determine what the API calls they used would be.

eiiot commented 2 years ago

Getting an error when setting up:


Logger: homeassistant.config_entries
Source: custom_components/wyzeapi/__init__.py:184
Integration: Wyze Home Assistant Integration (documentation, issues)
First occurred: 7:51:20 PM (1 occurrences)
Last logged: 7:51:20 PM

Error setting up entry Wyze Home Assistant Integration for wyzeapi
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 313, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/config/custom_components/wyzeapi/__init__.py", line 123, in async_setup_entry
    await cleanup_registries(hass, config_entry, mac_addresses)
  File "/config/custom_components/wyzeapi/__init__.py", line 184, in cleanup_registries
    await entity_registry.async_remove(ent.entity_id)
TypeError: object NoneType can't be used in 'await' expression
JoeSchubert commented 2 years ago

Thanks. I'll have to figure that out I guess. It was in a batch of other changes that came in with that beta because we made some changes to how entities were being stored to correctly attach them to devices.... and wanted to clean up the ones that used old naming schemes. For some reason it didn't throw any errors during my testing.

JoeSchubert commented 2 years ago

@eIiot I'm having a hard time figuring out that error off the top of my head.... That's in a bit of code I added to remove binary sensors, if they were still dangling (I never had any, which is likely why it never triggered a fault in my setup). Might you be willing to share your entity registry with me? It's in the .storage filler of home assistant. There shouldn't be anything that is sensitive in there, but please look through it first.

The path should be .storage/.core-entity_registry

The directory and file are both hidden, so you have to type them in and they will show with ls -la

Your error you posted makes it sound like you have an entity that doesn't have an entity-id, which I took for granted would always be available in HA.

eiiot commented 2 years ago

I looked through the file with regex + a simple script, and I'm not seeing any undefined entities. I'm not 100% into sending my .storage files in a public forum, could I send you a DM somewhere?

JoeSchubert commented 2 years ago

I looked through the file with regex + a simple script, and I'm not seeing any undefined entities. I'm not 100% into sending my .storage files in a public forum, could I send you a DM somewhere?

Yeah, I totally get that. GitHub doesn't like letting me post email addresses here. But you can email me at yoinx (at) graffiti.net

Or, you could catch me or Josh on irc, we both keep bouncers connected, at librechat in the #wyzeapi channel.

Kinda sounds like you did the check I was going to do anyway though if you didn't see any without an entity id, then I'm REALLY confused why you would get a None type error at the line you in the log you posted.

LordNex commented 2 years ago

I still wish I knew how your getting the lock to work as I was one of the contributing members for that. I have my lock paired with ZHA so everything stays local but it gets out of sync if anyone uses the app or the keypad on the outside. I wish I could find a way to use the keypad locally as well and then just do away with its connection to Wyze since I already have my cameras RSTP’d, all except my WOC

Sounds like an issue because of ZHA then. Is ZHA pushing the updated status to the server, or getting it from the server? If not, you're always going to have issues if someone unlocks through the app, since it's not telling ZHA that it unlocked.

If ZHA was querying the lock, and had a route to exchange that back and forth with this integration (though no effort would likely go into that happening) you wouldn't have that issue, nor the issue with the keypad.

The lock works perfectly fine, through this integration, through wyze as the integration assumes that you're using it given that the integration queries wyze's servers for everything... I don't have any sync issues with it whatsoever.

No I created automation based upon templates that toggle based upon the state. If it sees the Wyse app lock or unlocks, it triggers ZHA. The usually causes double triggers but i have a few conditions that help. The problem is that I have to use IFTTT webhooks to get that info because I haven't been able to get this integration to do anything with my lock except give the battery status. I have several cameras I can toggle on and off too and those work fine but thats it.

eiiot commented 2 years ago

@yoinx Did you get the email I sent you? I'm still getting the error in 2021.12

JoeSchubert commented 2 years ago

@yoinx Did you get the email I sent you? I'm still getting the error in 2021.12

I did. I didn't see anything wrong in it either. so I'm not really sure what to do with it right now. I'll have some time next week to look at this stuff hopefully

JoeSchubert commented 2 years ago

This issue's functionality has been added and this issue should/could be closed. The bug mentioned in the thread should be discussed in the issue linked above as it's related/caused by the changes for that issue.

eiiot commented 2 years ago

The previous issue fixed itself somehow, but now the siren entities are unavailable :/

Screenshot_20211214-231355.jpg

Logs ``` Logger: homeassistant.helpers.entity Source: helpers/entity.py:549 First occurred: 11:12:47 PM (32 occurrences) Last logged: 11:12:50 PM Entity switch.view () implements device_state_attributes. Please report it to the custom component author. Entity switch.deck () implements device_state_attributes. Please report it to the custom component author. Entity switch.under_stairs () implements device_state_attributes. Please report it to the custom component author. Entity switch.below_deck_wyze () implements device_state_attributes. Please report it to the custom component author. Entity switch.small_roof () implements device_state_attributes. Please report it to the custom component author. ```
JoeSchubert commented 2 years ago

Yeah. It looks like the changes that enabled the sirens as well as clearing out old/unused entities are in the beta trees. After the tag/release issues, those changes don't exist in any releases. Which is why you don't have the same bug now and the sirens don't work.

eiiot commented 2 years ago

Oh that's annoying... Is there a fix other than re-releasing the beta?

eiiot commented 2 years ago

Did this feature ever get re-released?

SecKatie commented 2 years ago

Yeah. It looks like the changes that enabled the sirens as well as clearing out old/unused entities are in the beta trees. After the tag/release issues, those changes don't exist in any releases. Which is why you don't have the same bug now and the sirens don't work.

Have you had an opportunity to resolve the issues with the changes that add the siren feature?

JoeSchubert commented 2 years ago

Yeah. It looks like the changes that enabled the sirens as well as clearing out old/unused entities are in the beta trees. After the tag/release issues, those changes don't exist in any releases. Which is why you don't have the same bug now and the sirens don't work.

Have you had an opportunity to resolve the issues with the changes that add the siren feature?

I haven't. I'm sure I still have the branches on my laptop. I'll see if I can't get them sorted and PR'd this weekend.