dave-atx / homebridge-platform-smartac

A homebridge plug-in for ThinkEco SmartAC thermostats.
MIT License
14 stars 10 forks source link

Unhandled promise rejection #7

Open maxmulready opened 6 years ago

maxmulready commented 6 years ago

Hi,

This plugin has been working great for months, but today it stopped and I noticed that I'm getting an unhandled promise rejection warning when I try to run homebridge. Seems like ThinkEco has updated their website...maybe this has something to do with it?

dave-atx commented 6 years ago

Ah, yep, you're right -- looks like the website got redesigned. I'll try to see if I can make some updates over the weekend to fix things.

wezmininger commented 6 years ago

This is the error I see from within homebridge plugin in Hassio.

Hope the new website is more responsive, faster and just better overall than it has been the last couple years.

(node:713) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): StatusCodeError: 302 - "<html><head><title>Object moved</title></head><body>\r\n<h2>Object moved to <a href=\"/Account/Login\">here</a>.</h2>\r\n</body></html>\r\n"

(node:713) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
rodalpho commented 6 years ago

Their site would almost have to be better!

matthew-gerstman commented 6 years ago

I've been attempting to get this to work but no luck. For some reason It's either not logging in or the cookie is not persiting

  async auth() {
    if (Date.now() - this.lastLogin > LOGIN_FREQUENCY) {
      this.log('api', 'logging in...');
      const response = await this.session.post(
        'https://web.mymodlet.com/Account/Login',
        {
          // form: {'returnUrl': '/Dashboard/Index'},
          json: {data: {'Email': this.username, 'Password': this.password}},
          followRedirect: false,
          simple: false,          
        }
      );
      return response;
    }
  }

  // return an iterable of all of the Thermostats in the account
  // will retain a reference to and update the current status of
  // all returned Thermostats each time it's called
  async getThermostats() {
    // we only want a single concurrent call to mymodlet.com
    // because this is quite expensive. without a lock, multiple
    // concurrent operations here makes updating multiple attributes
    // on a thermostat(s) is pretty slow.
    await this.lock.acquire();
    if (Date.now() - this.lastUpdate > UPDATE_FREQUENCY) {
      this.log('api', 'updating thermostat status...');
      const auth = await this.auth();

      const statusTxt = await this.session.get('https://web.mymodlet.com/Devices/UpdateData');
      console.log(statusTxt);      
DFurnes commented 6 years ago

I was able to get this working in #5. For whatever reason, responses are given as stringified JSON and requests must be formatted as stringified JSON inside a data property... 🤔

maxmulready commented 6 years ago

Not to be a pain, but I am now getting an error that says Unable to read/write thermostat. at Thermostat.handleErrors (/usr/local/lib/node_modules/homebridge-platform-smartac/index.js:191:19) at /usr/local/lib/node_modules/homebridge-platform-smartac/index.js:247:12 at at process._tickCallback (internal/process/next_tick.js:188:7) (node:39542) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:39542) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Something on my end perhaps?

**To clarify, the plugin will run fine until I initiate any commands through the Home iOS app, and then this error occurs

MRyanNYC commented 6 years ago

Not a programmer, just a regular user of this extension.

Dave-ATX - Thanks for your hard work and I am sure you'll get this resolved. DFurnes - Reading over your changes in #5, I hope that Dave will implement them.

StJoHo commented 6 years ago

I Can’t tell you how much I miss this app working, and now that I know a fix is in sight I’m hopeful, given the current heat in NYC that my favourite and most used home automation app returns soon. You really forget how reliant you are on them and after having such great control it’s awful to now be back at 4am waking up because the ac is back to its old tricks and the rooms so cold you need the comforter. I know everyone does this in spare time and it’s appreciated.

Imagine much begging to see it working again as I realise my apt just hit 90 and the Modlets have all disconnected.

Help me Obi AC Kenobi. You’re my only hope.

RickyRomero commented 6 years ago

For what it's worth, this works for me:

npm i https://github.com/DFurnes/homebridge-platform-smartac/tarball/heater-cooler

This will add @DFurnes's fixed branch as a dependency directly, so you don't have to wait for #5 to be merged.

Alternatively, you can replace the dependency manually in package.json:

From:
"homebridge-platform-smartac": "^1.1.2"

To:
"homebridge-platform-smartac": "https://github.com/DFurnes/homebridge-platform-smartac/tarball/heater-cooler"

Stay cool. ❄️

MRyanNYC commented 6 years ago

Sorry to be such a newb, but can you let me know the full path to the file I need to change? Stumbling around I had found two different config.json files (one for SmartAC and one for Homebridge itself) but didn't find the line you reference in either. Thanks!

RickyRomero commented 6 years ago

@MRyanNYC That line goes in package.json. If you have vanilla homebridge, try running:

sudo npm uninstall -g homebridge-platform-smartac
sudo npm i -g https://github.com/DFurnes/homebridge-platform-smartac/tarball/heater-cooler
MRyanNYC commented 6 years ago

@RickyRomero Thanks, that worked for me. @DFurnes Thank you as well.

wezmininger commented 6 years ago

I am running Hassio using the builtin Homekit library (the homebridge addon is being deprecated as the homekit integration is built out) Is it possible to install into latest Hassio 74.2 on HassOS (the newest non resin based)

metameric commented 6 years ago

These modlets are so much more useful when they're working through Homebridge. I've learned a ton from the coding efforts here - kudos @dave-atx. Thanks @RickyRomero for noting @DFurnes fork with those great fixes. They're working for me and hope they can be incorporated in the master.

ifunlisted commented 6 years ago

Couldn't agree more @metameric. Without Homebridge and this platform, they are more frustrating than useful. It astounds me how bad the smartAC app is and how ThinkEco could let it go for this long without any updates...especially when the modlets themselves are so valuable and in demand.

Anyway, one odd thing... my temp selector will not stop at 79 degrees. It just skips from 78 to 80. Is anyone else seeing this?

MRyanNYC commented 6 years ago

Both my Smart AC units are showing the dreaded "No Response" message. Rebooted my computer, where HomeBridge runs, and still nothing. All other non-HomeBridge Homekit items are working.

Anyone else seeing this? SmartAC issue?

StJoHo commented 6 years ago

Mines is still working and all ac u it’s connectwd and working.