Coder Social home page Coder Social logo

wyze-node's Introduction

wyze-node

This is an unofficial Wyze API. This library uses the internal APIs from the Wyze mobile app. A list of all Wyze devices can be retrieved to check the status of Wyze Cameras, Wyze Sense, Wyze Bulbs, Wyze Plugs and possibly Wyze locks (untested). This API can turn on and off cameras, lightbulbs and smart plugs.

Setup

npm install wyze-node --save

Example

const Wyze = require('wyze-node')

const options = {
  username: process.env.username,
  password: process.env.password
}
const wyze = new Wyze(options)

  ; (async () => {
    let device, state, result

    // Get all Wyze devices
    const devices = await wyze.getDeviceList()
    console.log(devices)

    // Get a Wyze Bulb by name and turn it off.
    device = await wyze.getDeviceByName('Porch Light')
    result = await wyze.turnOff(device)
    console.log(result)

    // Get the state of a Wyze Sense contact sensor
    device = await wyze.getDeviceByName('Front Door')
    state = await wyze.getDeviceState(device)
    console.log(`${device.nickname} is ${state}`)

  })()

Run

[email protected] password=123456 node index.js

Helper methods

Use this helper methods to interact with wyze-node.

  • wyze.getDeviceList()
  • wyze.getDeviceByName(nickname)
  • wyze.getDeviceByMac(mac)
  • wyze.getDevicesByType(type)
  • wyze.getDevicesByModel(model)
  • wyze.getDeviceGroupsList()
  • wyze.getDeviceSortList()
  • wyze.turnOn(device)
  • wyze.turnOff(device)
  • wyze.getDeviceStatus(device)
  • wyze.getDeviceState(device)

Internal methods

  • wyze.login()
  • wyze.getRefreshToken()
  • wyze.getObjectList()
  • wyze.runAction(instanceId, providerKey, actionKey)
  • wyze.getDeviceInfo(deviceMac, deviceModel)
  • wyze.getPropertyList(deviceMac, deviceModel)
  • wyze.setProperty(deviceMac, deviceModel, propertyId, propertyValue)

wyze-node's People

Contributors

dependabot[bot] avatar jakefishbain avatar jonathinr avatar korynunn avatar noelportugal 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  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  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  avatar

Watchers

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

wyze-node's Issues

SetProperty

I'm trying to use SetProperty with a thermostat and the response I get is this:
{
ts: 1638074427852,
code: '1',
msg: '',
data: { session_id: '[removed not sure if thats sensitive info', result: 3 }
}

Can you tell me what this response means?

Download video

Would it be possible to extend this to add a function for downloading video stored on local microSD cards? I often back up videos on the cards manually, but it's a pain to remove them and reinstall them every time.

Potential way to control wyze vacuum

Is it possible to implement wyze vacuum support? This way you could specify a device and then run clean, suction, and room query on a vacuum.

setProperty result scoping

it looks as though storing result as a const on line 224 does so within the scope of the try/catch instead of the variable initially instantiated on 212. Removing const and modifying the line to be

result = await axios.post(`${this.baseUrl}/app/v2/device/set_property`, await this.getRequestBodyData(data))

seems to fix the issue.

wyze-node/index.js

Lines 211 to 231 in c16d427

async setProperty(deviceMac, deviceModel, propertyId, propertyValue) {
let result
try {
await this.getTokens();
if (!this.accessToken) {
await this.login()
}
const data = {
device_mac: deviceMac,
device_model: deviceModel,
pid: propertyId,
pvalue: propertyValue,
}
const result = await axios.post(`${this.baseUrl}/app/v2/device/set_property`, await this.getRequestBodyData(data))
} catch (e) {
console.log('Error...', e)
throw e
}
return result.data
}

Wyze scale data

Is it possible to pull data from a Wyze scale? The data is shown in the app and it comes up in my device list using the API.

Thanks!

refresh token not found

Thanks for this, looks really cool, but I'm getting an error for .toString() because it's looking like the refresh token value is NOT found. here's the response I get for result.data.data data: { ts: 1607030431777, code: '1001', msg: '', data: {} }

I stepped up a level and console logged result but still only see the access token, not the refresh token.

Any idea how I can resolve this?

429 on Login, ECONNREFUSED for Bulb Change

On a login and device scan, it now returns a 429 rate limit after ~30 seconds.

const options = {
  username: credentials.username,
  password: credentials.password,
};
const wyze = new Wyze(options)
const allLights = await wyze.getDevicesByType('MeshLight')

(node:24268) UnhandledPromiseRejectionWarning: Error: Request failed with status code 429
at createError (C:\Users\Brian\sonoran\node_modules\wyze-node\node_modules\axios\lib\core\createError.js:16:15)
at settle (C:\Users\Brian\sonoran\node_modules\wyze-node\node_modules\axios\lib\core\settle.js:17:12)
at IncomingMessage.handleStreamEnd (C:\Users\Brian\sonoran\node_modules\wyze-node\node_modules\axios\lib\adapters\http.js:269:11)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)

I'm wondering if Wyze recently changed their API, or if the user agent listed wyze_ios_2.21.35 is no longer supported?

On a second note, I've been making local color bulb requests that have also stopped working.
http://192.168.1.197:80/device_request - these now return a ECONNREFUSED error, likely also as some sort of API update? This is separate from the library though.

Does this stream video?

Thanks for the lib - I'm a bit confused - are we able to stream video from our cameras with this? Or is it just for getting a list of the devices?

Fails to install - 99.99% a user error

Hi,

Complete node.js noob here, but need to start somewhere. Right.
Did try to google this, but finally gave up. Seeking some guidance to get this installed.

When running npm install wyze-node --save on a Windows 10 system I get the following error:

npm WARN deprecated [email protected]: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
npm ERR! code E403
npm ERR! 403 403 Forbidden - GET https://artifactory.workday.com/artifactory/api/npm/npm-virtual/node-localstorage/-/node-localstorage-2.1.6.tgz
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.

Sorry for bugging you with such simple questions.

Thanks, Marcus

New error UnauthorizedOperation during login.

Hey I've been using this repo for a while without issue. Login was working as expected and I was able to turn devices on and off easily.

However, login seems to be broken at the moment. Getting back this response when logging result.data here:

{ 
  ts: 1625055563361,
  code: '3005',
  msg: 'UnauthorizedOperation',
  data: {} 
}

I've verified my correct credentials so this may be due to a change the Wyze team made.

Question re: thumbnails_url

Great work here -- It's working great for a homebrew front end UI to monitor and manage the power state of all my various Wyze devices (cams - v2's and v3's, lights and plugs).

For the cameras, theres a JSON element for a thumbnail image -- camera_thumbnails > thumbnails_url.... Does any one know what the deal is with these and why they aren't more regularly snapped and stored? Are these the cached images that the iOS app keeps and shows for the static thumbnail in the app UI? I wonder if it's just the last known 'movement' recorded for the cam? I wish there was a way to have this programatically triggered, but I'll just do a screen capture from RTSP maybe or just the rtsp stream itself in my wall mounted tablet device.

Kudos for the hard work on this -- it's really awesome. I'm going to see if I can figure out access to lamp sockets (which are an add on for v2 and v3 cameras to control regular light bulbs.

Enable/Disable Motion Detection

Any plans to enable/disable motion detection for cameras? I tried checking the properties list after modifying the motion detection settings but none of the values changed.

Device Id

Hey, thanks for your work on this. Do you think you can give an example or point me to a decent article explaining how to get the device id using Wireshark? It sure would be greatly appreciated.

Camera snapshot

I'm wondering if I can pull a snapshot from a Wyze cam. I know video streaming needs the RTSP firmware but the "prevent the camera from supporting any future functions or features in the Wyze app" warning with a lack of reverting instructions scares me. I only need the latest shot from the cam not the whole stream.

Wyze Login does not provide an Access Token or Refresh Token

When using the login functionality it appears that Wyze does not respond with an access token or refresh token. I am not sure why this is happening now and if this means the unofficial API is broken.

{
    "access_token": null,
    "refresh_token": null
}

It appears that it has something to do with MFA. I don't have an iPhone right now to do a Mitm to get the MFA endpoint.

wyze bulb color

Will this work with Wyze bulb color? setProperty(mac, model, "P1507", "0000ff") for instance doesn't seem to affect my bulb, or return predictably.

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.