GithubHelp home page GithubHelp logo

wyzeapy's Introduction

Wyzeapy

A python library for the (unofficial) Wyze Labs web APIs.

Used By

This project is used by the ha-wyzeapi project. Let me know if you are utilizing it so that I can feature your project here!

Usage/Examples

Getting logged in:

import asyncio
from wyzeapy import Wyzeapy


async def async_main():
    client = await Wyzeapy.create()
    await client.login("EMAIL", "PASSWORD")


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(async_main())

Thanks to:

  • @shauntarves: for contributing the App ID and Signing Secret
  • @yoinx: for considerable contributions to the project

License

GNU GPLv3

Appendix

Full doc reference - Please note that I am still working on doc strings so please be patient

wyzeapy's People

Contributors

akudaikon avatar brg468 avatar danielkwalsh avatar dependabot[bot] avatar faanskit avatar guillaumeb-github avatar jdeath avatar joeschubert avatar mrlt8 avatar seckatie avatar semgrep-bot avatar widewing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

wyzeapy's Issues

Feature request: full support for Light Strips

@brg468 @JoshuaMulliken It seems #32 added some support for light strips, but the only functionality that I can reliably effect using wyzeapy directly against my Light Strip Pro is turn_off

I looked over Josh's post on how to intercept SSL pinned comms to see if I might do some feature work myself, but it'd be a heavy lift for me in my current state. I'd have to start from the very beginning, acquiring and rooting an Android device.

If enough time goes by, I might end up giving it a whirl, but if someone else is better equipped, I'd be grateful!

color and brightness attribute of bulb devices are always 000000 and 0, respectively

After logging in, I use the bulb service and the get_bulbs method to get a list of bulbs. I find the one I want, and can turn it on and off, which is great, but when I use the brightness and color attributes, they come back as all zeroes, even when I can clearly see that I've turned the bulb on to non-zero brightness, and its color is not black.

improvement: sanitize urls from events response

Since logging response json, there have been many extra things that need to be sanitized. While working on event code, I noticed that we aren't sanitizing the events urls. As these are s3 links with the authentication embedded in the URL these should be sanitized to prevent leakage of personal videos if logs are posted.

Thermostat updates in mobile app but not on thermostat itself

Hello, Home Assistant user, here. I've had a problem for a long time where temperature and various other updates via Home Assistant will be reflected on the mobile Wyze app, but not on the thermostat itself. This was reported by someone else and ignored on the Home Assistant Wyze integration repository here: SecKatie/ha-wyzeapi#437

After doing some digging, I found the same behavior was reported in another Wyze API Python library here: shauntarves/wyze-sdk#15

They solved the issue by changing the endpoint of various set functions from set_iot_prop to set_iot_prop_by_topic. I checked the code for this repo's thermostat control and it appears to me that it is indeed using set_iot_prop to set various states.

Cchardet blocked by Home Assistant

https://github.com/JoshuaMulliken/wyzeapy/blob/466cb527d0d2c212a7ca4aecff35c3efb1d79617/pyproject.toml#L12

As pointed out here: SecKatie/ha-wyzeapi#462 (comment)

This package is unmaintained and as of last week is now blocked by Home assistant.

This line should be updated to read:

faust-cchardet = "^2.1.18"

I am currently on mobile but will submit a PR as soon as I'm on my computer. Opening this issue as a reminder.

We just need to make sure that the functions being used retained the same names/parameters/returns.

Wyzeapy time related code not transportable and get_event_list possibly have a design flaw

Issue 1
In get_event_list() in base_client.py, the following time functions is used:

"begin_time": int(str(datetime.date.today().strftime("%s")) + "000"),

strftime("%s") is not supported on Windows. For more info what is supported for strftime(), see this link.

This results in the following error on Windows:

Traceback (most recent call last):

  File "C:\Users\-\AppData\Local\Programs\Python\Python39\lib\site-packages\wyzeapy\client.py", line 237, in get_latest_event
    raw_events = self.client.get_event_list(device, 10)['data']['event_list']
  File "C:\Users\-\AppData\Local\Programs\Python\Python39\lib\site-packages\wyzeapy\base_client.py", line 432, in get_event_list
    "begin_time": int(str(datetime.date.today().strftime("%s")) + "000"),

ValueError: Invalid format string

Issue 2
This method also has a built in flaw. Possible number of events differs depending of time-of-day. 1am will only provide 1hrs of possible hits, but 11pm will provide 23hrs of possible hits.

Propose to change to a function relative to now. Suppose 2hrs x 60 minutes x 60 seconds should be enough.
"begin_time": int(str(int(time.time() - (2 * 60 * 60))) + "000"),

This should fix both issue as time.time() is transportable, and the function now works as intended (?)

Feature Request: Room Sensors for Thermostats

I'm not sure if this is already implemented and I just didn't see it but I'd like to see if it's possible to get data from Room Sensors in this API.

There is another API project "wyze-sdk" that is able to get Room Sensor temp and humidity but this is the API that the Home Assistant Addon I like uses (same author).

I'm new to github and home assistant but have programming experience in python and will likely try to see if I can figure this out myself if I can focus long enough on this home automation hobby.

I have a Wyze thermostat and am disappointed that the official app can't ever use a room sensor as the sole temperature control target. My house is stupid and the Wyze Thermostat is in a room that is not directly cooled by it's AC unit so I usually have to babysit temperatures throughout the day. My long term goal is trying to write my own hack-y logic to control the thermostat and get it to target the room sensors.

Adding support for Locking and UnLocking states for LockService

As per HA documentation (https://developers.home-assistant.io/docs/core/entity/lock/), the Lock entity supports transition states Locking and UnLocking.
It would be great to add the support for these states as unlocking or locking a Wyze lock can take several seconds.

Note: ha-wyzeapi has a bug in the way the lock state is managed, and it will need to be fixed after the support for Locking and UnLocking states will be added in wyzeapi. I'll create an issue there too.
Note2: Great work !

List Index out of Range

I have a couple of Wyze Lock Bolts and they seem to be causing an out of range error in this integration:

home-assistant  | 2023-08-04 13:48:31.221 ERROR (MainThread) [homeassistant.components.lock] wyzeapi: Error on device update!
home-assistant  | Traceback (most recent call last):
home-assistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 570, in _async_add_entity
home-assistant  |     await entity.async_device_update(warning=False)
home-assistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 940, in async_device_update
home-assistant  |     await self.async_update()
home-assistant  |   File "/config/custom_components/wyzeapi/token_manager.py", line 45, in inner_function
home-assistant  |     await func(*args, **kwargs)
home-assistant  |   File "/config/custom_components/wyzeapi/lock.py", line 149, in async_update
home-assistant  |     lock = await self._lock_service.update(self._lock)
home-assistant  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
home-assistant  |   File "/usr/local/lib/python3.11/site-packages/wyzeapy/services/lock_service.py", line 18, in update
home-assistant  |     device_info = await self._get_lock_info(lock)
home-assistant  |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
home-assistant  |   File "/usr/local/lib/python3.11/site-packages/wyzeapy/services/base_service.py", line 499, in _get_lock_info
home-assistant  |     device_uuid = device.mac.split(".")[2]
home-assistant  |                   ~~~~~~~~~~~~~~~~~~~~~^^^
home-assistant  | IndexError: list index out of range

I don't really need those locks supported but this is impacting updates to my other Wyze devices.

Question: Filter in get_event_list()

Question:
When the Wyze app query for events from a camera with ./get_event_list, it asks for "all" events:
"event_value_list": [],

Wyzeapy sends a filter, that likely makes the app omit sound detections. Is this on purpose?

            "event_value_list": [
                "1",
                "13",
                "10",
                "12"
            ],

By adding "2" to this list, also sound events gets published to Home Assistant:

            "event_value_list": [
                "1",
                "2",
                "13",
                "10",
                "12"
            ],

Do you have documentation what 1, 13, 10 and 12 means?
1 = Camera Motion
2 = Sound Detection
10 - ?
12 - ?
13 - ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.