Giter Site home page Giter Site logo

thomasmunduchira / myq-api Goto Github PK

View Code? Open in Web Editor NEW
137.0 15.0 39.0 611 KB

An updated API to interface with myQ devices

Home Page: https://www.npmjs.com/package/myq-api

License: MIT License

JavaScript 100.00%
chamberlain liftmaster garage-door-opener api-wrapper light myq-garage-door nodejs

myq-api's People

Contributors

bsell93 avatar chadsmith avatar dependabot[bot] avatar kennethklee avatar khuezy avatar nsnyder avatar parnic avatar strathcole avatar thomasmunduchira 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

myq-api's Issues

V6 Support

Noticed errors being thrown from my implementation of this package. After a bit of looking, it appears that Chamberlain has deprecated V5 of their API, and has moved to V6. (Discussion here.)

It looks like someone on that side has been able to reverse engineer it, but I'm not sure how to grab the logs myself to get an implementation going. Might be possible to get into the Discord server and ask them for the info.

Not sure how big a change this is. Ideally, the public facing API for this package remains as-is.

Happy to help if I have time.

Hub/Lockitron door locks?

Is it possible to get the state of a lockitron lock, which is integrated with MyQ via a MyQ hub? Their app supports getting and settings state, and I think it's a subdevice on the hub. But I don't know how to get the serial in order to try issuing commands.

This is what I see:

state: {
      firmware_version: '2.11',
      homekit_capable: false,
      homekit_enabled: false,
      learn: 'http://api.myqdevice.com/api/v5/XXXXXXXXXXXXXXXXXXXXX/learn',
      learn_mode: false,
      updated_date: '2020-12-02T22:49:55.8860265Z',
      physical_devices: [Array],
      pending_bootload_abandoned: false,
      online: true,
      last_status: '2020-12-02T22:49:52.8676884Z'
    }

is it possible to get history?

This is really nice and works well. Thanks for the effort. The MyQ app supports the ability to show a device's history, e.g., when it has been opened/closed. Any plans to add this support?

Cannot run getDevices(): Unidentified error returned from service.

I cannot seem to list any of the devices on my account using getDevices(). I attempted this using example.js from the documentation.

The only error that is logged is MyQError: Unidentified error returned from service.

So I checked the response from axios and found the following response from MyQ:

{
  ReturnCode: '-99',
  ErrorMessage: 'please contact customer care, supportID: xxxxxxxxxxxxxx',
  CorrelationId: ''
}

Any ideas? I am using a MyQ integration for hubitat that still works so I assume MyQ didn't change anything.

Edit: If I change the API Version in constants.js to 5 instead of 5.1 everything works.

myq-api returning ERR_MYQ_SERVICE_UNREACHABLE

This module is now returning ERR_MYQ_SERVICE_UNREACHABLE per the last two days of E2E cron tests. See the latest run as an example.

Based on related repos, there appears to be upstream API changes. Assuming there is an agreed upon fix that is relatively trivial, I should be able to land and deploy a new version by end of day.

SSO with Google/Amazon

Does anyone have a pattern to login with a Google or Amazon account, is it even possible with the current implementation?

Great package BTW, really nice job.

Thanks

ERR_MYQ_INVALID_SERVICE_RESPONSE recently started appearing

Hey Thomas,

I've been using this library to control my garage door opener for awhile now and it's been working pretty well. However, recently I've started getting the dreaded ERR_MYQ_INVALID_SERVICE_RESPONSE error. Do you have any advice on how to further troubleshoot this? I'm happy to try to contribute a fix if it turns out there's been a small tweak in the API, but some guidance would be much appreciated.

Relevant snippet: (using express)

    const myq = new MyQ();
    try {
        await myq.login(myq_credentials.username,myq_credentials.password);
        const state = await myq.getDoorState(garage_door);
        res.send(state);
    } catch (err) {
        res.send(err);
    }

Error response:

{
  "name": "MyQError",
  "code": "ERR_MYQ_INVALID_SERVICE_RESPONSE",
  "_serviceError": {
    "message": "Request failed with status code 400",
    "name": "Error",
    "stack": "Error: Request failed with status code 400\n    at createError (/home/julian/blinds/node_modules/myq-api/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/home/julian/blinds/node_modules/myq-api/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/home/julian/blinds/node_modules/myq-api/node_modules/axios/lib/adapters/http.js:260:11)\n    at emitNone (events.js:111:20)\n    at IncomingMessage.emit (events.js:208:7)\n    at endReadableNT (_stream_readable.js:1064:12)\n    at _combinedTickCallback (internal/process/next_tick.js:138:11)\n    at process._tickCallback (internal/process/next_tick.js:180:9)",
    "config": {
      "url": "Login",
      "method": "post",
      "data": "{\"Username\":\"jul***@gmail.com\",\"Password\":\"******\"}",
      "headers": {
        "Accept": "application/json, text/plain, */*",
        "Content-Type": "application/json",
        "MyQApplicationId": "JVM/G9Nwih5BwKgNCjLxiFUQxQijAebyyg8QUHr7JOrP+tuPb8iHfRHKwTmDzHOu",
        "ApiVersion": "5.2",
        "BrandId": "2",
        "Culture": "en",
        "User-Agent": "3d599e2ae7215f47fb49",
        "Content-Length": 56
      },
      "baseURL": "https://api.myqdevice.com/api/v5",
      "transformRequest": [
        null
      ],
      "transformResponse": [
        null
      ],
      "timeout": 0,
      "xsrfCookieName": "XSRF-TOKEN",
      "xsrfHeaderName": "X-XSRF-TOKEN",
      "maxContentLength": -1,
      "maxBodyLength": -1
    }
  }
}

Pure React implementation issues

I'm implementing a pure front end usage and keep coming into polyfill errors.

Since this was intended to be used server side, I understand the usage of Node.js server side npm packages. However, I have been able to polyfill a few dependencies in my package.json via npm aliases:

    "crypto": "npm:crypto-browserify",
    "stream": "npm:stream-browserify",

I've gotten past those errors but now trying to figure out how to get past all of the stream_readable usages of buffer.

Any ideas or tips?

TS Support?

Just curious if Typescript support (typings) will be added at any point or if I should consider creating them to and pushing to DefinitelyTyped?

Amazon accounts

Will this API work if you have registered with an Amazon account or only when email and password?

Access to devices shared with me?

The API works great if I am the owner of the device. In my case, however, somebody shared a device with me as a guest, and no devices show up.

Return code 11 and HTTP code 500 returned when sending a setDoorState() request

Hi Thomas!

This is my first time working on a node.js project on my own so I apologize if I'm doing something incorrectly or if my code style is a bit odd.

I am able to use the 'myq-api' just fine and can login() & getdevices() just fine but when I go to set the door state, I get a 500 internal server error. In your repo, it says to create a github issue if you see this. I included the output below.

{ returnCode: 0, token: 'removing-this-for-security-reasons' } { returnCode: 0, devices: [ { id: removing-this-for-security-reasons, typeId: 7, typeName: 'VGDO', serialNumber: 'removing-this-for-security-reasons', online: true, doorState: 2, doorStateDescription: 'closed', doorStateUpdated: 1597624376755, name: 'Garage Door' } ] } { returnCode: 11, message: 'Something unexpected happened. Please wait a bit and try again.', unhandledError: { Error: Request failed with status code 500 at createError (/Users/danielgarcia/Documents/garage-door-controller/node_modules/axios/lib/core/createError.js:16:15) at settle (/Users/danielgarcia/Documents/garage-door-controller/node_modules/axios/lib/core/settle.js:18:12) at IncomingMessage.handleStreamEnd (/Users/danielgarcia/Documents/garage-door-controller/node_modules/axios/lib/adapters/http.js:201:11) at IncomingMessage.emit (events.js:203:15) at endReadableNT (_stream_readable.js:1145:12) at process._tickCallback (internal/process/next_tick.js:63:19) config: { adapter: [Function: httpAdapter], transformRequest: [Object], transformResponse: [Object], timeout: 0, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, validateStatus: [Function: validateStatus], headers: [Object], method: 'put', url: 'https://myqexternal.myqdevice.com/api/v4/deviceattribute/putdeviceattribute', data: '{"MyQDeviceId":"removing-this-for-security-reasons","AttributeName":"desireddoorstate","AttributeValue":1}' }, request: ClientRequest { _events: [Object], _eventsCount: 7, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: true, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: [TLSSocket], connection: [TLSSocket], _header: 'PUT /api/v4/deviceattribute/putdeviceattribute HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: application/json;charset=utf-8\r\nMyQApplicationId: NWknvuBd7LoFHfXmKNMBcgajXtZEgKUh4V7WNzMidrpUUluDpVYVZx+xT4PCM5Kx\r\nSecurityToken: 871ca9f0-ed35-4c87-9ba1-5f0637753388\r\nUser-Agent: axios/0.18.0\r\nContent-Length: 84\r\nHost: myqexternal.myqdevice.com\r\nConnection: close\r\n\r\n', _onPendingData: [Function: noopPendingOutput], agent: [Agent], socketPath: undefined, timeout: undefined, method: 'PUT', insecureHTTPParser: undefined, path: '/api/v4/deviceattribute/putdeviceattribute', _ended: true, res: [IncomingMessage], aborted: undefined, timeoutCb: null, upgradeOrConnect: false, parser: null, maxHeadersCount: null, _redirectable: [Writable], [Symbol(isCorked)]: false, [Symbol(outHeadersKey)]: [Object] }, response: { status: 500, statusText: 'Internal Server Error', headers: [Object], config: [Object], request: [ClientRequest], data: [Object] } } }

Device with serial number '$validserial' is not a door.

Hello,

I'd like to interface with a MYQ-G0301. Call attempts result in ERR_MYQ_INVALID_DEVICE. The serial is correct -- in that it is identical to what's displayed in the myq smart phone application. Have I encountered a bug or am I trying to use the API for an unsupported device?

Happy to provide serial if needed.

MyQError: Device with serial number '$validserial' is not a door.
    at MyQ.getDoorState (/Users/$user/Git/myq-alexa/node_modules/myq-api/src/MyQ.js:245:15)
    at processTicksAndRejections (<node_internals>/internal/process/task_queues.js:93:5)
    at async doorStatus (/Users/$user/Git/myq-alexa/index.js:17:22)
    at async Object.handle (/Users/$user/Git/myq-alexa/index.js:106:40) {name: 'MyQError', code: 'ERR_MYQ_INVALID_DEVICE', stack: 'MyQError: Device with serial number 'GW230000…Users/$user/Git/myq-alexa/index.js:106:40)', message: 'Device with serial number '$validserial'' is not a door.'}
index.js:20

code:'ERR_MYQ_INVALID_DEVICE'
message:'Device with serial number '$validserial' is not a door.'
name:'MyQError'
stack:'MyQError: Device with serial number '$validserial' is not a door.\n    at MyQ.getDoorState (/Users/$user/Git/myq-alexa/node_modules/myq-api/src/MyQ.js:245:15)\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)\n    at async doorStatus (/Users/$user/Git/myq-alexa/index.js:17:22)\n    at async Object.handle (/Users/$user/Git/myq-alexa/index.js:106:40)'
__proto__:Error
constructor:class MyQError extends Error {\n  /**\n   * Construct an error to be returned by the myQ API.\n   *\n   * @param {string} message Error message\n   * @param {string} code Error code\n   * @param {object} _serviceError Optional raw service error\n   */\n  constructor(message, code, _serviceError) {\n    super(message);\n    this.name = this.constructor.name;\n    this.code = code;\n    if (_serviceError !== undefined) {\n      this._serviceError = _serviceError;\n    }\n  }\n}

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.